]> git.sesse.net Git - vlc/blob - Makefile
-Fixed bug with MPEG audio in TS streams: MPEG audio & LPCM are _not_
[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
9 ###############################################################################
10 # Objects and files
11 ###############################################################################
12
13
14 # All possible plugin directories, needed for make clean
15 #
16 PLUGINS_DIR :=  alsa \
17                 beos \
18                 darwin \
19                 directx \
20                 dsp \
21                 dummy \
22                 dvd \
23                 esd \
24                 fb \
25                 ggi \
26                 glide \
27                 gtk \
28                 downmix \
29                 idct \
30                 imdct \
31                 kde \
32                 macosx \
33                 mga \
34                 motion \
35                 mpeg \
36                 qt \
37                 sdl \
38                 text \
39                 vcd \
40                 x11 \
41                 yuv
42
43 #
44 # All possible plugin objects
45 #
46 PLUGINS_TARGETS := alsa/alsa \
47                 beos/beos \
48                 darwin/darwin \
49                 directx/directx \
50                 dsp/dsp \
51                 dummy/dummy \
52                 dummy/null \
53                 dvd/dvd \
54                 esd/esd \
55                 fb/fb \
56                 ggi/ggi \
57                 glide/glide \
58                 gtk/gnome \
59                 gtk/gtk \
60                 downmix/downmix \
61                 downmix/downmixsse \
62                 downmix/downmix3dn \
63                 idct/idct \
64                 idct/idctclassic \
65                 idct/idctmmx \
66                 idct/idctmmxext \
67                 idct/idctaltivec \
68                 imdct/imdct \
69                 imdct/imdct3dn \
70                 imdct/imdctsse \
71                 kde/kde \
72                 macosx/macosx \
73                 macosx/macosx_qt \
74                 mga/mga \
75                 motion/motion \
76                 motion/motionmmx \
77                 motion/motionmmxext \
78                 motion/motion3dnow \
79                 motion/motionaltivec \
80                 mpeg/es \
81                 mpeg/ps \
82                 mpeg/ts \
83                 qt/qt \
84                 sdl/sdl \
85                 text/ncurses \
86                 text/rc \
87                 vcd/vcd \
88                 x11/x11 \
89                 x11/xvideo \
90                 yuv/yuv \
91                 yuv/yuvmmx
92
93 #
94 # C Objects
95
96 INTERFACE := main interface intf_msg intf_playlist intf_channels
97 INPUT := input input_ext-dec input_ext-intf input_dec input_programs input_netlist input_clock mpeg_system
98 VIDEO_OUTPUT := video_output video_text video_spu video_yuv
99 AUDIO_OUTPUT := audio_output aout_ext-dec aout_u8 aout_s8 aout_u16 aout_s16 aout_spdif
100 AC3_DECODER := ac3_decoder_thread ac3_decoder ac3_parse ac3_exponent ac3_bit_allocate ac3_mantissa ac3_rematrix ac3_imdct
101 AC3_SPDIF := ac3_spdif ac3_iec958
102 LPCM_DECODER := lpcm_decoder_thread
103 AUDIO_DECODER := audio_decoder adec_generic adec_layer1 adec_layer2 adec_math
104 SPU_DECODER := spu_decoder
105 VIDEO_DECODER := video_parser vpar_headers vpar_blocks vpar_synchro vpar_pool video_decoder
106 MISC := mtime tests modules netutils iso_lang
107
108 C_OBJ :=        $(INTERFACE:%=src/interface/%.o) \
109                 $(INPUT:%=src/input/%.o) \
110                 $(VIDEO_OUTPUT:%=src/video_output/%.o) \
111                 $(AUDIO_OUTPUT:%=src/audio_output/%.o) \
112                 $(AC3_DECODER:%=src/ac3_decoder/%.o) \
113                 $(AC3_SPDIF:%=src/ac3_spdif/%.o) \
114                 $(LPCM_DECODER:%=src/lpcm_decoder/%.o) \
115                 $(AUDIO_DECODER:%=src/audio_decoder/%.o) \
116                 $(SPU_DECODER:%=src/spu_decoder/%.o) \
117                 $(VIDEO_DECODER:%=src/video_decoder/%.o) \
118                 $(MISC:%=src/misc/%.o)
119
120 #
121 # Misc Objects
122
123 ifeq ($(NEED_GETOPT),1)
124 C_OBJ += extras/GNUgetopt/getopt.o extras/GNUgetopt/getopt1.o 
125 endif
126
127 ifeq ($(SYS),beos)
128 CPP_OBJ :=      src/misc/beos_specific.o
129 endif
130
131 ifneq (,$(findstring darwin,$(SYS)))
132 C_OBJ +=        src/misc/darwin_specific.o
133 endif
134
135 ifneq (,$(findstring mingw32,$(SYS)))
136 RESOURCE_OBJ := share/vlc_win32_rc.o
137 endif
138
139 VLC_OBJ := $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(RESOURCE_OBJ)
140
141 #
142 # Generated header
143 #
144 H_OBJ :=        src/misc/modules_builtin.h
145
146 #
147 # Other lists of files
148 #
149 C_DEP := $(C_OBJ:%.o=.dep/%.d)
150 CPP_DEP := $(CPP_OBJ:%.o=.dep/%.dpp)
151
152 #
153 # Translate plugin names
154 #
155 ifneq (,$(PLUGINS))
156 PLUGIN_OBJ := $(shell for i in $(PLUGINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@plugins/\1.so@' -e 's@^ .*@@' ; done)
157 endif
158 ifneq (,$(BUILTINS))
159 BUILTIN_OBJ := $(shell for i in $(BUILTINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@plugins/\1.a@' -e 's@^ .*@@' ; done)
160 endif
161
162 #
163 # Misc variables
164 #
165 VLC_QUICKVERSION := $(shell grep '^ *VLC_VERSION=' configure.in | cut -f2 -d=)
166 LIBDVDCSS_QUICKVERSION := $(shell grep '^ *LIBDVDCSS_VERSION=' configure.in | cut -f2 -d=)
167
168
169 # All symbols must be exported
170 export
171
172 ###############################################################################
173 # Targets
174 ###############################################################################
175
176 #
177 # Virtual targets
178 #
179 all: Makefile.opts vlc ${ALIASES} vlc.app
180
181 Makefile.opts:
182         @echo "**** No configuration found, running ./configure..."
183         ./configure
184         $(MAKE) $(MAKECMDGOALS)
185         exit
186
187 show:
188         @echo CC: $(CC)
189         @echo CFLAGS: $(CFLAGS)
190         @echo DCFLAGS: $(DCFLAGS)
191         @echo LCFLAGS: $(LCFLAGS)
192         @echo PCFLAGS: $(PCFLAGS)
193         @echo PLCFLAGS: $(PLCFLAGS)
194         @echo C_OBJ: $(C_OBJ)
195         @echo CPP_OBJ: $(CPP_OBJ)
196         @echo PLUGIN_OBJ: $(PLUGIN_OBJ)
197         @echo BUILTIN_OBJ: $(BUILTIN_OBJ)
198
199 #
200 # Cleaning rules
201 #
202 clean: libdvdcss-clean plugins-clean vlc-clean
203         rm -f src/*/*.o extras/*/*.o
204         rm -f lib/*.so* lib/*.a
205         rm -f plugins/*.so plugins/*.a
206         rm -rf extras/MacOSX/build
207
208 libdvdcss-clean:
209         -cd extras/libdvdcss && $(MAKE) clean
210
211 plugins-clean:
212         for dir in $(PLUGINS_DIR) ; do \
213                 ( cd plugins/$${dir} && $(MAKE) clean ) ; done
214         rm -f plugins/*/*.o plugins/*/*.moc plugins/*/*.bak
215
216 vlc-clean:
217         rm -f $(C_OBJ) $(CPP_OBJ)
218         rm -f vlc gnome-vlc gvlc kvlc qvlc vlc.exe
219         rm -Rf vlc.app
220
221 distclean: clean
222         rm -f **/*.o **/*~ *.log
223         rm -f Makefile.opts
224         rm -f include/defs.h include/config.h include/modules_builtin.h
225         rm -f src/misc/modules_builtin.h
226         rm -f config*status config*cache config*log
227         rm -f gmon.out core build-stamp
228         rm -Rf .dep
229         rm -f .gdb_history
230
231 #
232 # Install/uninstall rules
233 #
234 install: libdvdcss-install vlc-install plugins-install
235
236 uninstall: libdvdcss-uninstall vlc-uninstall plugins-uninstall
237
238 vlc-install:
239         mkdir -p $(DESTDIR)$(bindir)
240         $(INSTALL) vlc $(DESTDIR)$(bindir)
241 ifneq (,$(ALIASES))
242         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias && ln -s vlc $(DESTDIR)$(bindir)/$$alias ; fi ; done
243 endif
244         mkdir -p $(DESTDIR)$(datadir)/videolan
245         $(INSTALL) -m 644 share/*.psf $(DESTDIR)$(datadir)/videolan
246         $(INSTALL) -m 644 share/*.png $(DESTDIR)$(datadir)/videolan
247         $(INSTALL) -m 644 share/*.xpm $(DESTDIR)$(datadir)/videolan
248
249 vlc-uninstall:
250         rm -f $(DESTDIR)$(bindir)/vlc
251 ifneq (,$(ALIASES))
252         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias ; fi ; done
253 endif
254         rm -f $(DESTDIR)$(datadir)/videolan/*.psf
255         rm -f $(DESTDIR)$(datadir)/videolan/*.png
256         rm -f $(DESTDIR)$(datadir)/videolan/*.xpm
257
258 plugins-install:
259         mkdir -p $(DESTDIR)$(libdir)/videolan/vlc
260 ifneq (,$(PLUGINS))
261         $(INSTALL) -m 644 $(PLUGINS:%=plugins/%.so) $(DESTDIR)$(libdir)/videolan/vlc
262 endif
263
264 plugins-uninstall:
265         rm -f $(DESTDIR)$(libdir)/videolan/vlc/*.so
266
267 libdvdcss-install:
268         -cd extras/libdvdcss && $(MAKE) install
269
270 libdvdcss-uninstall:
271         -cd extras/libdvdcss && $(MAKE) uninstall
272
273 #
274 # Package generation rules
275 #
276 snapshot-common:
277         # Check that tmp isn't in the way
278         @if test -e tmp; then \
279                 echo "Error: please remove ./tmp, it is in the way"; false; \
280         else \
281                 echo "OK."; mkdir tmp; \
282         fi
283         # Copy directory structure in tmp
284         find -type d | grep -v '\(\.dep\|snapshot\|CVS\)' | while read i ; \
285                 do mkdir -p tmp/vlc/$$i ; \
286         done
287         rm -Rf tmp/vlc/tmp
288         find debian -mindepth 1 -maxdepth 1 -type d | \
289                 while read i ; do rm -Rf tmp/vlc/$$i ; done
290         # Copy .c .h .in .cpp and .glade files
291         find include src plugins -type f -name '*.[chig]*' | while read i ; \
292                 do cp $$i tmp/vlc/$$i ; done
293         # Copy plugin Makefiles
294         find plugins -type f -name Makefile | while read i ; \
295                 do cp $$i tmp/vlc/$$i ; done
296         # Copy extra programs and documentation
297         cp -a extras/* tmp/vlc/extras
298         cp -a doc/* tmp/vlc/doc
299         find tmp/vlc/extras tmp/vlc/doc \
300                 -type d -name CVS -o -name '.*' -o -name '*.[o]' | \
301                         while read i ; do rm -Rf $$i ; done
302         # Copy misc files
303         cp vlc.spec AUTHORS COPYING TODO todo.pl ChangeLog* README* INSTALL* \
304                 Makefile Makefile.opts.in Makefile.dep Makefile.modules \
305                 configure configure.in install-sh config.sub config.guess \
306                         tmp/vlc/
307         # Copy Debian control files
308         for file in debian/*dirs debian/*docs debian/*menu debian/*desktop \
309                 debian/*copyright ; do cp $$file tmp/vlc/debian ; done
310         for file in control changelog rules ; do \
311                 cp debian/$$file tmp/vlc/debian/ ; done
312         # Copy fonts and icons
313         for file in share/*png share/*xpm share/*psf ; do \
314                 cp $$file tmp/vlc/share ; done
315         for file in vlc_beos.rsrc vlc.icns gvlc_win32.ico vlc_win32_rc.rc ; do \
316                         cp share/$$file tmp/vlc/share/ ; done
317
318 snapshot: snapshot-common
319         # Build archives
320         F=vlc-${VLC_QUICKVERSION}; \
321         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$F.tar $$F); \
322         bzip2 -f -9 < tmp/$$F.tar > $$F.tar.bz2; \
323         gzip -f -9 tmp/$$F.tar ; mv tmp/$$F.tar.gz .
324         # Clean up
325         rm -Rf tmp
326
327 snapshot-nocss: snapshot-common
328         # Remove libdvdcss
329         rm -Rf tmp/vlc/extras/libdvdcss
330         rm -f tmp/vlc/*.libdvdcss
331         # Fix debian information
332         rm -f tmp/vlc/debian/libdvdcss*
333         rm -f tmp/vlc/debian/control
334         sed -e 's#^ DVDs# unencrypted DVDs#' < debian/control \
335                 | awk '{if(gsub("Package: libdvdcss",$$0))a=1;if(a==0)print $$0;if(a==1&&$$0=="")a=0}' \
336                 > tmp/vlc/debian/control
337         rm -f tmp/vlc/debian/rules
338         sed -e 's#^\(export LIBDVDCSS_FLAGS=\).*#\1"--without-dvdcss"#' < debian/rules \
339                 | awk '{if($$0=="# libdvdcss start")a=1;if(a==0)print $$0;if($$0=="# libdvdcss stop")a=0}' \
340                 > tmp/vlc/debian/rules
341         chmod +x tmp/vlc/debian/rules
342         # Build css-disabled archives
343         F=vlc-${VLC_QUICKVERSION}; G=vlc-${VLC_QUICKVERSION}-nocss; \
344         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$G.tar $$F); \
345         bzip2 -f -9 < tmp/$$G.tar > $$G.tar.bz2; \
346         gzip -f -9 tmp/$$G.tar ; mv tmp/$$G.tar.gz .
347         # Clean up
348         rm -Rf tmp
349
350 libdvdcss-snapshot: snapshot-common
351         # Remove vlc sources and icons, doc, debian directory...
352         rm -Rf tmp/vlc/src tmp/vlc/share tmp/vlc/plugins tmp/vlc/doc
353         rm -Rf tmp/vlc/extras/GNUgetopt tmp/vlc/extras/MacOSX
354         rm -Rf tmp/vlc/debian
355         # Remove useless headers
356         rm -f tmp/vlc/include/*
357         for file in defs.h.in config.h.in common.h int_types.h ; \
358                 do cp include/$$file tmp/vlc/include/ ; done
359         # Remove misc files (??? - maybe not really needed)
360         rm -f tmp/vlc/vlc.spec tmp/vlc/INSTALL-win32.txt
361         mv tmp/vlc/INSTALL.libdvdcss tmp/vlc/INSTALL
362         mv tmp/vlc/README.libdvdcss tmp/vlc/README
363         mv tmp/vlc/ChangeLog.libdvdcss tmp/vlc/ChangeLog
364         # Fix Makefile
365         rm -f tmp/vlc/Makefile
366         sed -e 's#^install:#install-unused:#' \
367                 -e 's#^uninstall:#uninstall-unused:#' \
368                 -e 's#^clean:#clean-unused:#' \
369                 -e 's#^all:.*#all: libdvdcss#' \
370                 -e 's#^libdvdcss-install:#install:#' \
371                 -e 's#^libdvdcss-uninstall:#uninstall:#' \
372                 -e 's#^libdvdcss-clean:#clean:#' \
373                 < Makefile > tmp/vlc/Makefile
374         # Build archives
375         F=libdvdcss-${LIBDVDCSS_QUICKVERSION}; \
376         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$F.tar $$F); \
377         bzip2 -f -9 < tmp/$$F.tar > $$F.tar.bz2; \
378         gzip -f -9 tmp/$$F.tar ; mv tmp/$$F.tar.gz .
379         # Clean up
380         rm -Rf tmp
381
382 deb:
383         dpkg-buildpackage -rfakeroot -us -uc
384
385 #
386 # Gtk/Gnome/* aliases and OS X application
387 #
388 gnome-vlc gvlc kvlc qvlc: vlc
389         rm -f $@ && ln -s vlc $@
390
391 .PHONY: vlc.app
392 vlc.app: Makefile.opts
393 ifneq (,$(findstring darwin,$(SYS)))
394         rm -Rf vlc.app
395         cd extras/MacOSX ; pbxbuild | grep -v '^ ' | grep -v '^\t'
396         cp -r extras/MacOSX/build/vlc.bundle ./vlc.app
397         $(INSTALL) -d vlc vlc.app/Contents/MacOS/share
398         $(INSTALL) -d vlc vlc.app/Contents/MacOS/plugins
399         $(INSTALL) vlc vlc.app/Contents/MacOS/
400 ifneq (,$(PLUGINS))
401         $(INSTALL) $(PLUGINS:%=plugins/%.so) vlc.app/Contents/MacOS/plugins
402 endif
403         $(INSTALL) -m 644 share/*.psf vlc.app/Contents/MacOS/share
404 endif
405
406 FORCE:
407
408 #
409 # Generic rules (see below)
410 #
411 $(C_DEP): %.d: FORCE
412         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
413
414 $(CPP_DEP): %.dpp: FORCE
415         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
416
417 $(H_OBJ): Makefile.opts Makefile.dep Makefile
418         rm -f $@ && cp $@.in $@
419 ifneq (,$(BUILTINS))
420         for i in $(BUILTINS) ; do \
421                 echo "int module_"$$i"_InitModule( module_t* );" >> $@ ; \
422                 echo "int module_"$$i"_ActivateModule( module_t* );" >> $@ ; \
423                 echo "int module_"$$i"_DeactivateModule( module_t* );" >> $@ ; \
424         done
425         echo "" >> $@ ;
426         printf "#define ALLOCATE_ALL_BUILTINS() do { " >> $@ ;
427         for i in $(BUILTINS) ; do \
428                 printf "ALLOCATE_BUILTIN("$$i"); " >> $@ ; \
429         done
430         echo "} while( 0 );" >> $@ ;
431         echo "" >> $@ ;
432 endif
433
434 $(C_OBJ): %.o: Makefile.opts Makefile.dep Makefile
435 $(C_OBJ): %.o: .dep/%.d
436 $(C_OBJ): %.o: %.c
437         $(CC) $(CFLAGS) -c -o $@ $<
438
439 $(CPP_OBJ): %.o: Makefile.opts Makefile.dep Makefile
440 $(CPP_OBJ): %.o: .dep/%.dpp
441 $(CPP_OBJ): %.o: %.cpp
442         $(CC) $(CFLAGS) -c -o $@ $<
443
444 $(RESOURCE_OBJ): %.o: Makefile.dep Makefile
445 ifneq (,(findstring mingw32,$(SYS)))
446 $(RESOURCE_OBJ): %.o: %.rc
447         $(WINDRES) -i $< -o $@
448 endif
449
450 #
451 # Main application target
452 #
453 vlc: Makefile.opts Makefile.dep Makefile $(H_OBJ) $(VLC_OBJ) $(BUILTIN_OBJ) plugins
454         $(CC) $(CFLAGS) -o $@ $(VLC_OBJ) $(BUILTIN_OBJ) $(LCFLAGS)
455 ifeq ($(SYS),beos)
456         xres -o $@ ./share/vlc_beos.rsrc
457         mimeset -f $@
458 endif
459
460 #
461 # Plugins target
462 #
463 plugins: Makefile.modules Makefile.opts Makefile.dep Makefile $(PLUGIN_OBJ)
464 $(PLUGIN_OBJ): FORCE
465         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.so=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:plugins/%=../%)
466
467 #
468 # Built-in modules target
469 #
470 builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
471 $(BUILTIN_OBJ): FORCE
472         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.a=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:plugins/%=../%)
473
474 #
475 # libdvdcss target
476 #
477 libdvdcss: Makefile.opts
478         cd extras/libdvdcss && $(MAKE)