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