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