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