]> git.sesse.net Git - vlc/blob - Makefile
* Added a dummy libdvdcss so that the DVD plugin can be used without
[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 beos darwin directx dsp dummy dvd esd fb ggi glide gtk downmix idct imdct kde macosx mga motion mpeg qt sdl text x11 yuv
17
18 #
19 # All possible plugin objects
20 #
21 PLUGINS_TARGETS := alsa/alsa beos/beos darwin/darwin directx/directx dsp/dsp dummy/dummy dummy/null dvd/dvd esd/esd fb/fb ggi/ggi glide/glide gtk/gnome gtk/gtk downmix/downmix downmix/downmixsse downmix/downmix3dn idct/idct idct/idctclassic idct/idctmmx idct/idctmmxext imdct/imdct imdct/imdct3dn imdct/imdctsse kde/kde macosx/macosx mga/mga motion/motion motion/motionmmx motion/motionmmxext mpeg/es mpeg/ps mpeg/ts qt/qt sdl/sdl text/ncurses text/rc x11/x11 x11/xvideo yuv/yuv yuv/yuvmmx
22
23 #
24 # C Objects
25
26 INTERFACE := main interface intf_msg intf_playlist intf_channels
27 INPUT := input input_ext-dec input_ext-intf input_dec input_programs input_netlist input_clock mpeg_system
28 VIDEO_OUTPUT := video_output video_text video_spu video_yuv
29 AUDIO_OUTPUT := audio_output aout_ext-dec aout_u8 aout_s8 aout_u16 aout_s16 aout_spdif
30 AC3_DECODER := ac3_decoder_thread ac3_decoder ac3_parse ac3_exponent ac3_bit_allocate ac3_mantissa ac3_rematrix ac3_imdct
31 AC3_SPDIF := ac3_spdif ac3_iec958
32 LPCM_DECODER := lpcm_decoder_thread
33 AUDIO_DECODER := audio_decoder adec_generic adec_layer1 adec_layer2 adec_math
34 SPU_DECODER := spu_decoder
35 VIDEO_DECODER := video_parser vpar_headers vpar_blocks vpar_synchro vpar_pool video_decoder
36 MISC := mtime tests modules netutils
37
38 C_OBJ :=        $(INTERFACE:%=src/interface/%.o) \
39                 $(INPUT:%=src/input/%.o) \
40                 $(VIDEO_OUTPUT:%=src/video_output/%.o) \
41                 $(AUDIO_OUTPUT:%=src/audio_output/%.o) \
42                 $(AC3_DECODER:%=src/ac3_decoder/%.o) \
43                 $(AC3_SPDIF:%=src/ac3_spdif/%.o) \
44                 $(LPCM_DECODER:%=src/lpcm_decoder/%.o) \
45                 $(AUDIO_DECODER:%=src/audio_decoder/%.o) \
46                 $(SPU_DECODER:%=src/spu_decoder/%.o) \
47                 $(VIDEO_DECODER:%=src/video_decoder/%.o) \
48                 $(MISC:%=src/misc/%.o)
49
50 #
51 # Misc Objects
52
53 ifeq ($(GETOPT),1)
54 C_OBJ += extras/GNUgetopt/getopt.o extras/GNUgetopt/getopt1.o 
55 endif
56
57 ifeq ($(SYS),beos)
58 CPP_OBJ :=      src/misc/beos_specific.o
59 endif
60
61 ifneq (,$(findstring darwin,$(SYS)))
62 C_OBJ +=        src/misc/darwin_specific.o
63 endif
64
65 ifneq (,$(findstring mingw32,$(SYS)))
66 RESOURCE_OBJ := share/vlc_win32_rc.o
67 endif
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 := $(shell for i in $(PLUGINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@plugins/\1.so@' -e 's@^ .*@@' ; done)
85 endif
86 ifneq (,$(BUILTINS))
87 BUILTIN_OBJ := $(shell for i in $(BUILTINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@plugins/\1.a@' -e 's@^ .*@@' ; done)
88 endif
89
90 #
91 # Misc variables
92 #
93 VLC_QUICKVERSION := $(shell grep 'VLC_VERSION=' configure.in | cut -f2 -d=)
94 LIBDVDCSS_QUICKVERSION := $(shell grep 'LIBDVDCSS_VERSION=' configure.in | cut -f2 -d=)
95
96
97 # All symbols must be exported
98 export
99
100 ###############################################################################
101 # Targets
102 ###############################################################################
103
104 #
105 # Virtual targets
106 #
107 all: Makefile.opts vlc ${ALIASES} vlc.app
108
109 Makefile.opts:
110         @echo "**** No configuration found, running ./configure..."
111         ./configure
112
113 # Include Makefile.opts again in case we just generated it
114 ifneq (1,$(HAVE_MAKEFILE_OPTS))
115     -include Makefile.opts
116 endif
117
118 show:
119         @echo CC: $(CC)
120         @echo CFLAGS: $(CFLAGS)
121         @echo DCFLAGS: $(DCFLAGS)
122         @echo LCFLAGS: $(LCFLAGS)
123         @echo C_OBJ: $(C_OBJ)
124         @echo CPP_OBJ: $(CPP_OBJ)
125         @echo PLUGIN_OBJ: $(PLUGIN_OBJ)
126         @echo BUILTIN_OBJ: $(BUILTIN_OBJ)
127
128 #
129 # Cleaning rules
130 #
131 clean: libdvdcss-clean plugins-clean vlc-clean
132         rm -f src/*/*.o extras/*/*.o
133         rm -f lib/*.so* lib/*.a
134         rm -f plugins/*.so plugins/*.a
135
136 libdvdcss-clean:
137         -cd extras/libdvdcss && $(MAKE) clean
138
139 plugins-clean:
140         for dir in $(PLUGINS_DIR) ; do \
141                 ( cd plugins/$${dir} && $(MAKE) clean ) ; done
142         rm -f plugins/*/*.o plugins/*/*.moc plugins/*/*.bak
143
144 vlc-clean:
145         rm -f $(C_OBJ) $(CPP_OBJ)
146         rm -f vlc gnome-vlc gvlc kvlc qvlc vlc.exe
147         rm -Rf vlc.app
148
149 distclean: clean
150         rm -f **/*.o **/*~ *.log
151         rm -f Makefile.opts
152         rm -f include/defs.h include/config.h include/modules_builtin.h
153         rm -f src/misc/modules_builtin.h
154         rm -f config*status config*cache config*log
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: libdvdcss-install vlc-install plugins-install
163
164 uninstall: libdvdcss-uninstall vlc-uninstall plugins-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)/videolan
173         $(INSTALL) -m 644 share/*.psf $(DESTDIR)$(datadir)/videolan
174         $(INSTALL) -m 644 share/*.png $(DESTDIR)$(datadir)/videolan
175         $(INSTALL) -m 644 share/*.xpm $(DESTDIR)$(datadir)/videolan
176
177 vlc-uninstall:
178         rm vlc $(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)/videolan/*.psf
183         rm -f $(DESTDIR)$(datadir)/videolan/*.png
184         rm -f $(DESTDIR)$(datadir)/videolan/*.xpm
185
186 plugins-install:
187         mkdir -p $(DESTDIR)$(libdir)/videolan/vlc
188 ifneq (,$(PLUGINS))
189         $(INSTALL) -m 644 $(PLUGINS:%=plugins/%.so) $(DESTDIR)$(libdir)/videolan/vlc
190 endif
191
192 plugins-uninstall:
193         rm -f $(DESTDIR)$(libdir)/videolan/vlc/*.so
194
195 libdvdcss-install:
196         -cd extras/libdvdcss && $(MAKE) install
197
198 libdvdcss-uninstall:
199         -cd extras/libdvdcss && $(MAKE) uninstall
200
201 #
202 # Package generation rules
203 #
204 snapshot-common: clean
205         rm -Rf /tmp/vlc
206         # Copy directory structure in /tmp
207         find -type d | grep -v CVS | grep -v '\.dep' | while read i ; \
208                 do mkdir -p /tmp/vlc/$$i ; \
209         done
210         find debian -mindepth 1 -maxdepth 1 -type d | \
211                 while read i ; do rm -Rf /tmp/vlc/$$i ; done
212         # Copy .c .h .in .cpp and .glade files
213         find include src plugins -type f -name '*.[chig]*' | while read i ; \
214                 do cp $$i /tmp/vlc/$$i ; done
215         # Copy plugin Makefiles
216         find plugins -type f -name Makefile | while read i ; \
217                 do cp $$i /tmp/vlc/$$i ; done
218         # Copy extra programs and documentation
219         cp -a extras/* /tmp/vlc/extras
220         cp -a doc/* /tmp/vlc/doc
221         find /tmp/vlc/extras /tmp/vlc/doc \
222                 -type d -name CVS -o -type f -name '.*' | while read i ; \
223                         do rm -Rf $$i ; done
224         # Copy misc files
225         cp vlc.spec AUTHORS COPYING TODO todo.pl ChangeLog README* INSTALL* \
226                 Makefile Makefile.opts.in Makefile.dep Makefile.modules \
227                 configure configure.in install-sh config.sub config.guess \
228                         /tmp/vlc/
229         # Copy Debian control files
230         for file in debian/*dirs debian/*menu debian/*desktop ; do \
231                 cp $$file /tmp/vlc/debian ; done
232         for file in control changelog rules vlc.copyright vlc.docs ; do \
233                 cp debian/$$file /tmp/vlc/debian/ ; done
234         # Copy fonts and icons
235         for file in share/*png share/*xpm share/*psf ; do \
236                 cp $$file /tmp/vlc/share ; done
237         for file in vlc_beos.rsrc vlc.icns gvlc_win32.ico vlc_win32_rc.rc ; do \
238                         cp share/$$file /tmp/vlc/share/ ; done
239
240 snapshot: snapshot-common
241         # Build archives and clean up
242         F=vlc-${VLC_QUICKVERSION}; \
243         rm -Rf /tmp/$$F ; mv /tmp/vlc /tmp/$$F; \
244         (cd /tmp ; tar cf $$F.tar $$F ; bzip2 -f -9 < $$F.tar > $$F.tar.bz2; \
245                 gzip -f -9 $$F.tar ); mv /tmp/$$F.tar.gz /tmp/$$F.tar.bz2 ..; \
246         rm -Rf /tmp/$$F
247
248 snapshot-nocss: snapshot-common
249         # Remove libdvdcss
250         rm -Rf /tmp/vlc/extras/libdvdcss
251         rm -f /tmp/vlc/*.libdvdcss
252         # Fix debian information
253         rm -f /tmp/vlc/debian/libdvdcss*
254         rm -f /tmp/vlc/debian/control
255         sed -e 's#^ DVDs# unencrypted DVDs#' < debian/control \
256                 | awk '{if(gsub("Package: libdvdcss",$$0))a=1;if(a==0)print $$0;if(a==1&&$$0=="")a=0}' \
257                 > /tmp/vlc/debian/control
258         rm -f /tmp/vlc/debian/rules
259         sed -e 's#^\(export LIBDVDCSS_FLAGS=\).*#\1"--without-dvdcss"#' < debian/rules \
260                 | awk '{if($$0=="# libdvdcss start")a=1;if(a==0)print $$0;if($$0=="# libdvdcss stop")a=0}' \
261                 > /tmp/vlc/debian/rules
262         chmod +x /tmp/vlc/debian/rules
263         # Build css-disabled archives and clean up
264         F=vlc-${VLC_QUICKVERSION}; G=vlc-${VLC_QUICKVERSION}-nocss; \
265         rm -Rf /tmp/$$F ; mv /tmp/vlc /tmp/$$F; \
266         (cd /tmp ; tar cf $$G.tar $$F ; bzip2 -f -9 < $$G.tar > $$G.tar.bz2; \
267                 gzip -f -9 $$G.tar ); mv /tmp/$$G.tar.gz /tmp/$$G.tar.bz2 ..; \
268         rm -Rf /tmp/$$F
269
270 libdvdcss-snapshot: snapshot-common
271         # Remove vlc sources and icons, doc, debian directory...
272         rm -Rf /tmp/vlc/src /tmp/vlc/share /tmp/vlc/plugins /tmp/vlc/doc
273         rm -Rf /tmp/vlc/extras/GNUgetopt /tmp/vlc/extras/MacOSX_app
274         rm -Rf /tmp/vlc/debian
275         # Remove useless headers
276         rm -f /tmp/vlc/include/*
277         for file in defs.h.in config.h.in common.h int_types.h ; \
278                 do cp include/$$file /tmp/vlc/include/ ; done
279         # Remove misc files (??? - maybe not really needed)
280         rm -f /tmp/vlc/vlc.spec /tmp/vlc/INSTALL-win32.txt
281         mv /tmp/vlc/INSTALL.libdvdcss /tmp/vlc/INSTALL
282         mv /tmp/vlc/README.libdvdcss /tmp/vlc/README
283         # Fix Makefile
284         rm -f /tmp/vlc/Makefile
285         sed -e 's#^install:#install-unused:#' \
286                 -e 's#^uninstall:#uninstall-unused:#' \
287                 -e 's#^clean:#clean-unused:#' \
288                 -e 's#^all:.*#all: libdvdcss#' \
289                 -e 's#^libdvdcss-install:#install:#' \
290                 -e 's#^libdvdcss-uninstall:#uninstall:#' \
291                 -e 's#^libdvdcss-clean:#clean:#' \
292                 < Makefile > /tmp/vlc/Makefile
293         # Build archives and clean up
294         F=libdvdcss-${LIBDVDCSS_QUICKVERSION}; \
295         rm -Rf /tmp/$$F ; mv /tmp/vlc /tmp/$$F; \
296         (cd /tmp ; tar cf $$F.tar $$F ; bzip2 -f -9 < $$F.tar > $$F.tar.bz2; \
297                 gzip -f -9 $$F.tar ); mv /tmp/$$F.tar.gz /tmp/$$F.tar.bz2 ..; \
298         rm -Rf /tmp/$$F
299
300 deb:
301         dpkg-buildpackage -rfakeroot -us -uc
302
303 #
304 # Gtk/Gnome/* aliases and OS X application
305 #
306 gnome-vlc gvlc kvlc qvlc: vlc
307         rm -f $@ && ln -s vlc $@
308
309 .PHONY: vlc.app
310 vlc.app: Makefile.opts
311 ifneq (,$(findstring darwin,$(SYS)))
312         rm -Rf vlc.app
313         mkdir -p vlc.app/Contents/Resources
314         mkdir -p vlc.app/Contents/MacOS/lib
315         mkdir -p vlc.app/Contents/MacOS/share
316         $(INSTALL) -m 644 extras/MacOSX_app/Contents/Info.plist vlc.app/Contents/
317         $(INSTALL) -m 644 extras/MacOSX_app/Contents/PkgInfo vlc.app/Contents/
318         $(INSTALL) vlc vlc.app/Contents/MacOS/
319         $(INSTALL) share/vlc.icns vlc.app/Contents/Resources/
320 ifneq (,$(PLUGINS))
321         $(INSTALL) $(PLUGINS:%=plugins/%.so) vlc.app/Contents/MacOS/plugins
322 endif
323         $(INSTALL) -m 644 share/*.psf vlc.app/Contents/MacOS/share
324 endif
325
326 FORCE:
327
328 #
329 # Generic rules (see below)
330 #
331 $(C_DEP): %.d: FORCE
332         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
333
334 $(CPP_DEP): %.dpp: FORCE
335         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
336
337 $(H_OBJ): Makefile.opts Makefile.dep Makefile
338         rm -f $@ && cp $@.in $@
339 ifneq (,$(BUILTINS))
340         for i in $(BUILTINS) ; do \
341                 echo "int module_"$$i"_InitModule( module_t* );" >> $@ ; \
342                 echo "int module_"$$i"_ActivateModule( module_t* );" >> $@ ; \
343                 echo "int module_"$$i"_DeactivateModule( module_t* );" >> $@ ; \
344         done
345         echo "" >> $@ ;
346         printf "#define ALLOCATE_ALL_BUILTINS() do { " >> $@ ;
347         for i in $(BUILTINS) ; do \
348                 printf "ALLOCATE_BUILTIN("$$i"); " >> $@ ; \
349         done
350         echo "} while( 0 );" >> $@ ;
351         echo "" >> $@ ;
352 endif
353
354 $(C_OBJ): %.o: Makefile.opts Makefile.dep Makefile
355 $(C_OBJ): %.o: .dep/%.d
356 $(C_OBJ): %.o: %.c
357         $(CC) $(CFLAGS) -c -o $@ $<
358
359 $(CPP_OBJ): %.o: Makefile.opts Makefile.dep Makefile
360 $(CPP_OBJ): %.o: .dep/%.dpp
361 $(CPP_OBJ): %.o: %.cpp
362         $(CC) $(CFLAGS) -c -o $@ $<
363
364 $(RESOURCE_OBJ): %.o: Makefile.dep Makefile
365 ifneq (,(findstring mingw32,$(SYS)))
366 $(RESOURCE_OBJ): %.o: %.rc
367         $(WINDRES) -i $< -o $@
368 endif
369
370 #
371 # Main application target
372 #
373 vlc: Makefile.opts Makefile.dep Makefile $(H_OBJ) $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(RESOURCE_OBJ) plugins
374         $(CC) $(CFLAGS) -o $@ $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(RESOURCE_OBJ) $(LCFLAGS)
375 ifeq ($(SYS),beos)
376         xres -o $@ ./share/vlc_beos.rsrc
377         mimeset -f $@
378 endif
379
380 #
381 # Plugins target
382 #
383 plugins: Makefile.modules Makefile.opts Makefile.dep Makefile $(PLUGIN_OBJ)
384 $(PLUGIN_OBJ): FORCE
385         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.so=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:plugins/%=../%)
386
387 #
388 # Built-in modules target
389 #
390 builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
391 $(BUILTIN_OBJ): FORCE
392         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.a=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:plugins/%=../%)
393
394 #
395 # libdvdcss target
396 #
397 libdvdcss: Makefile.opts
398         cd extras/libdvdcss && $(MAKE)
399