]> git.sesse.net Git - vlc/blob - Makefile
bef5e835a6527a07cb1fabc7d331d94564a1e32d
[vlc] / Makefile
1 ###############################################################################
2 # vlc (VideoLAN Client) main Makefile - (c)1998 VideoLAN
3 ###############################################################################
4
5 ifeq ($(shell [ ! -r Makefile.opts ] && echo 1),)
6     include Makefile.opts
7 endif
8 ifeq ($(shell [ ! -r Makefile.config ] && echo 1),)
9     include Makefile.config
10 endif
11
12 ###############################################################################
13 # Objects and files
14 ###############################################################################
15
16 #
17 # C Objects
18
19 VLC := vlc
20 LIBVLC := libvlc
21 INTERFACE := interface intf_eject
22 PLAYLIST := playlist
23 INPUT := input input_ext-plugins input_ext-dec input_ext-intf input_dec input_programs input_clock input_info
24 VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
25 AUDIO_OUTPUT := audio_output filters input mixer output
26 MISC := mtime modules threads cpu configuration netutils iso_lang messages objects extras
27
28 LIBVLC_OBJ :=   $(LIBVLC:%=src/%.o) \
29                 $(INTERFACE:%=src/interface/%.o) \
30                 $(PLAYLIST:%=src/playlist/%.o) \
31                 $(INPUT:%=src/input/%.o) \
32                 $(VIDEO_OUTPUT:%=src/video_output/%.o) \
33                 $(AUDIO_OUTPUT:%=src/audio_output/%.o) \
34                 $(MISC:%=src/misc/%.o)
35
36 VLC_OBJ := $(VLC:%=src/%.o)
37
38 C_OBJ := $(VLC_OBJ) $(LIBVLC_OBJ)
39
40 #
41 # Misc Objects
42
43 ifeq ($(NEED_GETOPT),1)
44 LIBVLC_OBJ += extras/GNUgetopt/getopt.o extras/GNUgetopt/getopt1.o 
45 endif
46
47 ifeq ($(NEED_SYMBOLS),1)
48 LIBVLC_OBJ += src/misc/symbols.o
49 endif
50
51 ifeq ($(SYS),beos)
52 CPP_OBJ :=      src/misc/beos_specific.o
53 endif
54
55 ifneq (,$(findstring darwin,$(SYS)))
56 LIBVLC_OBJ +=   src/misc/darwin_specific.o
57 endif
58
59 ifneq (,$(findstring mingw32,$(SYS)))
60 LIBVLC_OBJ +=   src/misc/win32_specific.o
61 RESOURCE_OBJ := share/vlc_win32_rc.o
62 endif
63
64 LIBVLC_OBJ += $(CPP_OBJ) $(M_OBJ) $(BUILTIN_OBJ)
65 VLC_OBJ += $(RESOURCE_OBJ)
66
67 #
68 # Generated header
69 #
70 H_OBJ :=        src/misc/modules_builtin.h
71
72 #
73 # Other lists of files
74 #
75 C_DEP := $(C_OBJ:%.o=.dep/%.d)
76 CPP_DEP := $(CPP_OBJ:%.o=.dep/%.dpp)
77
78 #
79 # Translate plugin names
80 #
81 ifneq (,$(PLUGINS))
82 PLUGIN_OBJ := $(PLUGINS:%=modules/%.so)
83 endif
84 ifneq (,$(BUILTINS))
85 BUILTIN_OBJ := $(BUILTINS:%=modules/%.a)
86 endif
87
88 #
89 # Misc variables
90 #
91 VERSION := $(shell grep '^ *VERSION=' configure.in | head -1 | sed 's/"//g' | cut -f2 -d=)
92
93 # All symbols must be exported
94 export
95
96 ###############################################################################
97 # Targets
98 ###############################################################################
99
100 #
101 # Virtual targets
102 #
103 all: Makefile.opts vlc ${ALIASES} vlc.app plugins po mozilla/libvlcplugin.so
104
105 Makefile.opts:
106         @echo "**** No configuration found, please run ./configure"
107         @exit 1
108 #       ./configure
109 #       $(MAKE) $(MAKECMDGOALS)
110 #       exit    
111
112 show:
113         @echo CC: $(CC)
114         @echo CFLAGS: $(CFLAGS)
115         @echo LDFLAGS: $(LDFLAGS)
116         @echo plugins_CFLAGS: $(plugins_CFLAGS)
117         @echo plugins_LDFLAGS: $(plugins_LDFLAGS)
118         @echo builtins_CFLAGS: $(builtins_CFLAGS)
119         @echo builtins_LDFLAGS: $(builtins_LDFLAGS)
120         @echo C_OBJ: $(C_OBJ)
121         @echo CPP_OBJ: $(CPP_OBJ)
122         @echo PLUGIN_OBJ: $(PLUGIN_OBJ)
123         @echo BUILTIN_OBJ: $(BUILTIN_OBJ)
124
125 #
126 # Cleaning rules
127 #
128 clean: plugins-clean po-clean vlc-clean mozilla-clean
129         rm -f src/*/*.o extras/*/*.o
130         rm -f lib/*.so* lib/*.a
131         rm -f plugins/*.so plugins/*.a plugins/*.lib plugins/*.tds
132         rm -Rf extras/MacOSX/build
133
134 po-clean:
135         -cd po && $(MAKE) clean
136
137 plugins-clean:
138         for dir in $(shell echo $(PLUGIN_OBJ) $(BUILTIN_OBJ) | sed 's@\([^ ]*\)/[^ ]*@\1@g' ) ; do ( PARENT=`pwd` ; cd $${dir} && $(MAKE) -f $$PARENT/Makefile.modules clean PARENT=$$PARENT ) ; done
139
140 vlc-clean:
141         rm -f $(C_OBJ) $(CPP_OBJ)
142         rm -f vlc gnome-vlc gvlc kvlc qvlc vlc.exe
143         rm -Rf vlc.app
144
145 mozilla-clean:
146         -cd mozilla && $(MAKE) clean
147
148 distclean: clean
149         -cd po && $(MAKE) maintainer-clean
150         rm -f **/*.o **/*~ *.log
151         rm -f Makefile.opts Makefile.config vlc-config
152         rm -f include/defs.h include/modules_builtin.h
153         rm -f src/misc/modules_builtin.h
154         rm -f config*status config*cache config*log conftest*
155         rm -f gmon.out core build-stamp
156         rm -Rf .dep
157         rm -f .gdb_history
158
159 #
160 # Install/uninstall rules
161 #
162 install: vlc-install plugins-install builtins-install libvlc-install po-install mozilla-install
163
164 uninstall: vlc-uninstall plugins-uninstall builtins-uninstall libvlc-uninstall po-uninstall mozilla-uninstall
165
166 vlc-install:
167         mkdir -p $(DESTDIR)$(bindir)
168         $(INSTALL) vlc $(DESTDIR)$(bindir)
169 ifneq (,$(ALIASES))
170         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias && ln -s vlc $(DESTDIR)$(bindir)/$$alias ; fi ; done
171 endif
172         mkdir -p $(DESTDIR)$(datadir)/vlc
173         $(INSTALL) -m 644 share/*.psf $(DESTDIR)$(datadir)/vlc
174         $(INSTALL) -m 644 share/*.png $(DESTDIR)$(datadir)/vlc
175         $(INSTALL) -m 644 share/*.xpm $(DESTDIR)$(datadir)/vlc
176
177 vlc-uninstall:
178         rm -f $(DESTDIR)$(bindir)/vlc
179 ifneq (,$(ALIASES))
180         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias ; fi ; done
181 endif
182         rm -f $(DESTDIR)$(datadir)/vlc/*.psf
183         rm -f $(DESTDIR)$(datadir)/vlc/*.png
184         rm -f $(DESTDIR)$(datadir)/vlc/*.xpm
185         -rmdir $(DESTDIR)$(datadir)/vlc
186
187 plugins-install:
188         mkdir -p $(DESTDIR)$(libdir)/vlc
189 ifneq (,$(PLUGINS))
190         for plugin in $(PLUGINS) ; \
191                 do dir=`echo $$plugin | sed -e 's@/[^ ]*@@g'` ; \
192                 mkdir -p $(DESTDIR)$(libdir)/vlc/$$dir ; \
193                 cp modules/$${plugin}.so $(DESTDIR)$(libdir)/vlc/$$dir ; \
194         done
195 endif
196
197 plugins-uninstall:
198         rm -f $(DESTDIR)$(libdir)/vlc/*/*.so
199         -rmdir $(DESTDIR)$(libdir)/vlc/*
200         -rmdir $(DESTDIR)$(libdir)/vlc
201
202 builtins-install:
203         mkdir -p $(DESTDIR)$(libdir)/vlc
204 ifneq (,$(BUILTINS))
205         $(INSTALL) -m 644 $(BUILTINS:%=modules/%.a) $(DESTDIR)$(libdir)/vlc
206 endif
207
208 builtins-uninstall:
209         rm -f $(DESTDIR)$(libdir)/vlc/*.a
210         -rmdir $(DESTDIR)$(libdir)/vlc
211
212 libvlc-install:
213         mkdir -p $(DESTDIR)$(bindir)
214         $(INSTALL) vlc-config $(DESTDIR)$(bindir)
215         mkdir -p $(DESTDIR)$(includedir)/vlc
216         $(INSTALL) -m 644 include/vlc/*.h $(DESTDIR)$(includedir)/vlc
217         mkdir -p $(DESTDIR)$(libdir)
218         $(INSTALL) -m 644 lib/libvlc.a $(DESTDIR)$(libdir)
219
220 libvlc-uninstall:
221         rm -f $(DESTDIR)$(bindir)/vlc-config
222         rm -Rf $(DESTDIR)$(includedir)/vlc
223         rm -f $(DESTDIR)$(libdir)/libvlc.a
224
225 mozilla-install:
226 ifeq ($(MOZILLA),1)
227         -cd mozilla && $(MAKE) install
228 endif
229
230 mozilla-uninstall:
231 ifeq ($(MOZILLA),1)
232         -cd mozilla && $(MAKE) uninstall
233 endif
234
235 po-install:
236         -cd po && $(MAKE) install
237
238 po-uninstall:
239         -cd po && $(MAKE) uninstall
240
241 #
242 # Package generation rules
243 #
244 dist:
245         # Check that tmp isn't in the way
246         @if test -e tmp; then \
247                 echo "Error: please remove ./tmp, it is in the way"; false; \
248         else \
249                 echo "OK."; mkdir tmp; \
250         fi
251         # Copy directory structure in tmp
252         find -type d | grep -v '\(\.dep\|snapshot\|CVS\)' | while read i ; \
253                 do mkdir -p tmp/vlc/$$i ; \
254         done
255         rm -Rf tmp/vlc/tmp
256         find debian -mindepth 1 -maxdepth 1 -type d | \
257                 while read i ; do rm -Rf tmp/vlc/$$i ; done
258         # Copy .c .h .in .cpp .m and .glade files
259         find include src modules -type f -name '*.[bcdhigmrst]*' | while read i ; \
260                 do cp $$i tmp/vlc/$$i ; done
261         # Grmbl... special case...
262         for i in API BUGS DESIGN TODO ; \
263                 do cp modules/mad/$$i tmp/vlc/modules/mad ; done
264         # Copy plugin Makefiles
265         find modules -type f -name Makefile | while read i ; \
266                 do cp $$i tmp/vlc/$$i ; done
267         # Copy extra programs and documentation
268         cp -a extras/* tmp/vlc/extras
269         cp -a doc/* tmp/vlc/doc
270         find tmp/vlc/extras tmp/vlc/doc \
271                 -type d -name CVS -o -name '.*' -o -name '*.[o]' | \
272                         while read i ; do rm -Rf $$i ; done
273         # Copy gettext stuff
274         cp po/ChangeLog po/vlc.pot po/*.po tmp/vlc/po
275         for i in Makefile.in.in POTFILES.in ; do cp po/$$i tmp/vlc/po ; done
276         # Copy misc files
277         cp FAQ AUTHORS COPYING TODO todo.pl ChangeLog* README* INSTALL* \
278                 ABOUT-NLS BUGS MODULES vlc.spec \
279                 Makefile Makefile.*.in Makefile.dep Makefile.modules \
280                 configure configure.in install-sh install-win32 macosx-dmg \
281                 config.sub config.guess aclocal.m4 mkinstalldirs \
282                         tmp/vlc/
283         # Copy Debian control files
284         for file in debian/*dirs debian/*docs debian/*menu debian/*desktop \
285                 debian/*copyright ; do cp $$file tmp/vlc/debian ; done
286         for file in control changelog rules ; do \
287                 cp debian/$$file tmp/vlc/debian/ ; done
288         # Copy ipkg control files
289         for file in control rules patch ; do \
290                 cp ipkg/$$file tmp/vlc/ipkg/ ; done
291         # Copy fonts and icons
292         for file in share/*vlc* share/*psf; do \
293                 cp $$file tmp/vlc/share ; done
294         # Build archives
295         F=vlc-${VERSION}; \
296         mv tmp/vlc tmp/$$F; (cd tmp ; \
297                 cd $$F && $(MAKE) distclean && cd .. ; \
298                 tar czf ../$$F.tar.gz $$F);
299         # Clean up
300         rm -Rf tmp
301
302 package-win32:
303         # XXX: this rule is probably only useful to you if you have exactly
304         # the same setup as me. Contact sam@zoy.org if you need to use it.
305         #
306         # Check that tmp isn't in the way
307         @if test -e tmp; then \
308                 echo "Error: please remove ./tmp, it is in the way"; false; \
309         else \
310                 echo "OK."; mkdir tmp; \
311         fi
312         # Create installation script
313         cp install-win32 tmp/nsi
314         # Copy relevant files
315         cp vlc.exe tmp/ 
316         $(STRIP) tmp/vlc.exe
317         cp INSTALL.win32 tmp/INSTALL.txt ; unix2dos tmp/INSTALL.txt
318         for file in AUTHORS COPYING ChangeLog README FAQ TODO ; \
319                         do cp $$file tmp/$${file}.txt ; \
320                         unix2dos tmp/$${file}.txt ; done
321         mkdir tmp/plugins
322 ifneq (,$(PLUGINS))
323         for i in $(PLUGINS) ; do \
324                 DIR=`echo $$i | cut -f1 -d/` ; \
325                 mkdir -p tmp/plugins/$$DIR ; \
326                 cp modules/$$i.so tmp/plugins/$$DIR ; \
327                 if test $$i != gui/win32/win32 ; then \
328                         $(STRIP) \
329                         tmp/plugins/$$DIR/`echo $$i | sed -e 's@.*/@@'`.so ; \
330                 fi ; \
331         done
332 endif
333         mkdir tmp/share
334         for file in default8x16.psf default8x9.psf ; \
335                 do cp share/$$file tmp/share/ ; done
336         # Create package 
337         wine ~/.wine/fake_windows/Program\ Files/NSIS/makensis.exe -- /DVERSION=${VERSION} /CD tmp/nsi
338         # Clean up
339         rm -Rf tmp
340
341 package-beos:
342         # Check that tmp isn't in the way
343         @if test -e tmp; then \
344                 echo "Error: please remove ./tmp, it is in the way"; false; \
345         else \
346                 echo "OK."; mkdir tmp; \
347         fi
348         
349         # Create dir
350         mkdir -p tmp/vlc/share
351         # Copy relevant files
352         cp vlc tmp/vlc/
353         strip tmp/vlc/vlc
354         xres -o tmp/vlc/vlc ./share/vlc_beos.rsrc
355         cp AUTHORS COPYING ChangeLog README FAQ TODO tmp/vlc/
356         for file in default8x16.psf default8x9.psf ; \
357                 do cp share/$$file tmp/vlc/share/ ; done
358         mkdir tmp/vlc/modules
359         cp $(PLUGINS:%=modules/%.so) tmp/vlc/modules/ 
360         strip $(PLUGINS:%=tmp/vlc/modules/%.so)
361         # Create package 
362         mv tmp/vlc tmp/vlc-${VERSION}
363         (cd tmp ; find vlc-${VERSION} | \
364         zip -9 -@ vlc-${VERSION}-BeOS-x86.zip )
365         mv tmp/vlc-${VERSION}-BeOS-x86.zip .
366         # Clean up
367         rm -Rf tmp
368
369 package-macosx:
370         # Check that tmp isn't in the way
371         @if test -e tmp; then \
372                 echo "Error: please remove ./tmp, it is in the way"; false; \
373         else \
374                 echo "OK."; mkdir tmp; \
375         fi
376
377         # Copy relevant files 
378         cp -R vlc.app tmp/
379         cp AUTHORS COPYING ChangeLog README README.MacOSX.rtf FAQ TODO tmp/
380
381         # Create disk image 
382         ./macosx-dmg 0 "vlc-${VERSION}" tmp/* 
383
384         # Clean up
385         rm -Rf tmp
386
387 #
388 # Gtk/Gnome/* aliases and OS X application
389 #
390 gnome-vlc gvlc kvlc qvlc: vlc
391         rm -f $@ && ln -s vlc $@
392
393 .PHONY: vlc.app
394 vlc.app: vlc plugins
395 ifneq (,$(findstring darwin,$(SYS)))
396         rm -Rf vlc.app
397         cd extras/MacOSX ; pbxbuild | grep -v '^ ' | grep -v '^\t' | grep -v "^$$"
398         cp -r extras/MacOSX/build/vlc.bundle ./vlc.app
399         $(INSTALL) -d vlc.app/Contents/MacOS/share
400         $(INSTALL) -d vlc.app/Contents/MacOS/modules
401         $(INSTALL) vlc vlc.app/Contents/MacOS/
402 ifneq (,$(PLUGINS))
403         $(INSTALL) $(PLUGINS:%=modules/%.so) vlc.app/Contents/MacOS/modules
404 endif
405         $(INSTALL) -m 644 share/*.psf vlc.app/Contents/MacOS/share
406 endif
407
408 FORCE:
409
410 #
411 # Generic rules (see below)
412 #
413 src/misc/modules_builtin.h: Makefile.opts Makefile Makefile.config
414         @echo "make[$(MAKELEVEL)]: Creating \`$@'"
415         @rm -f $@ && cp $@.in $@
416 ifneq (,$(BUILTINS))
417         @for i in $(BUILTINS) ; do \
418                 echo "int vlc_entry__modules_"`echo $$i | sed -e 'y@/@_@' -e 's@\..*@@'`"( module_t* );" >>$@; \
419         done
420         @echo "" >> $@ ;
421 endif
422         @echo "#define ALLOCATE_ALL_BUILTINS() \\" >> $@ ;
423         @echo "    do \\" >> $@ ;
424         @echo "    { \\" >> $@ ;
425 ifneq (,$(BUILTINS))
426         @for i in $(BUILTINS) ; do \
427                 echo "        ALLOCATE_BUILTIN(modules_"`echo $$i | sed -e 'y@/@_@' -e 's@\..*@@'`"); \\" >> $@ ; \
428         done
429 endif
430         @echo "    } while( 0 );" >> $@ ;
431         @echo "" >> $@ ;
432
433 $(C_DEP): %.d: FORCE
434         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
435
436 $(CPP_DEP): %.dpp: FORCE
437         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
438
439 $(C_OBJ): %.o: Makefile.opts Makefile.dep Makefile
440 $(C_OBJ): %.o: $(H_OBJ)
441 $(C_OBJ): %.o: .dep/%.d
442 $(C_OBJ): %.o: %.c
443         $(CC) $(CFLAGS) $(vlc_CFLAGS) -c -o $@ $<
444
445 $(CPP_OBJ): %.o: Makefile.opts Makefile.dep Makefile
446 $(CPP_OBJ): %.o: $(H_OBJ)
447 $(CPP_OBJ): %.o: .dep/%.dpp
448 $(CPP_OBJ): %.o: %.cpp
449         $(CC) $(CFLAGS) $(vlc_CFLAGS) -c -o $@ $<
450
451 $(M_OBJ): %.o: Makefile.opts Makefile.dep Makefile
452 $(M_OBJ): %.o: $(H_OBJ)
453 $(M_OBJ): %.o: .dep/%.dm
454 $(M_OBJ): %.o: %.m
455         $(CC) $(CFLAGS) $(vlc_CFLAGS) -c -o $@ $<
456
457 $(RESOURCE_OBJ): %.o: Makefile.dep Makefile
458 ifneq (,(findstring mingw32,$(SYS)))
459 $(RESOURCE_OBJ): %.o: %.rc
460         $(WINDRES) -i $< -o $@
461 endif
462
463 #
464 # Main application target
465 #
466 vlc: Makefile.config Makefile.opts Makefile.dep Makefile $(VLC_OBJ) lib/libvlc.a $(BUILTIN_OBJ)
467         $(CC) $(CFLAGS) -o $@ $(VLC_OBJ) lib/libvlc.a $(LDFLAGS) $(vlc_LDFLAGS) $(BUILTIN_OBJ) $(builtins_LDFLAGS)
468 ifeq ($(SYS),beos)
469         xres -o $@ ./share/vlc_beos.rsrc
470         mimeset -f $@
471 endif
472
473 #
474 # Main library target
475 #
476 lib/libvlc.a: Makefile.opts Makefile.dep Makefile $(LIBVLC_OBJ)
477         rm -f $@
478         ar rc $@ $(LIBVLC_OBJ)
479         $(RANLIB) $@
480
481 #
482 # DO NOT DISTRIBUTE SHARED VERSIONS OF LIBVLC UNTIL THE ABI IS STABLE
483 # OR BURN IN HELL -- Sam
484 #
485 #lib/libvlc.so: Makefile.opts Makefile.dep Makefile $(LIBVLC_OBJ)
486 #       $(CC) -shared $(LIBVLC_OBJ) $(LDFLAGS) $(vlc_LDFLAGS) -o $@
487
488 builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
489 plugins: Makefile.modules Makefile.opts Makefile.dep Makefile $(PLUGIN_OBJ)
490
491 modules/%.a modules/%.so: $(H_OBJ) FORCE
492         cd $(shell echo $@ | sed -e 's@\(.*\)/.*@\1@') && $(MAKE) -f $(shell echo $@ | sed -e 's@[^/]*/@../@g' -e 's@\(.*\)/.*@\1@')/Makefile.modules $(shell echo $@ | sed -e 's@.*/@@') PARENT=$(shell echo $@ | sed -e 's@[^/]*/@../@g' -e 's@\(.*\)/.*@\1@') MODULE_PATH=$(shell echo $@ | sed -e 'y@/@_@' -e 's@\..*@@')
493
494 #
495 # Mozilla plugin target
496 #
497 mozilla/libvlcplugin.so: FORCE
498 ifeq ($(MOZILLA),1)
499         @cd mozilla && $(MAKE) builtins_LDFLAGS="$(builtins_LDFLAGS)"
500 endif
501
502 #
503 # gettext target
504 #
505 po: FORCE
506         @cd po && $(MAKE)
507