]> git.sesse.net Git - vlc/blob - Makefile
10e0ea8fb2313e1767a906e32cb7c4ab64c84c76
[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 vcd 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 idct/idctaltivec imdct/imdct imdct/imdct3dn imdct/imdctsse kde/kde macosx/macosx macosx/macosx_qt mga/mga motion/motion motion/motionmmx motion/motionmmxext motion/motion3dnow motion/motionaltivec mpeg/es mpeg/ps mpeg/ts qt/qt sdl/sdl text/ncurses text/rc vcd/vcd 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 ($(NEED_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 VLC_OBJ := $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(RESOURCE_OBJ)
70
71 #
72 # Generated header
73 #
74 H_OBJ :=        src/misc/modules_builtin.h
75
76 #
77 # Other lists of files
78 #
79 C_DEP := $(C_OBJ:%.o=.dep/%.d)
80 CPP_DEP := $(CPP_OBJ:%.o=.dep/%.dpp)
81
82 #
83 # Translate plugin names
84 #
85 ifneq (,$(PLUGINS))
86 PLUGIN_OBJ := $(shell for i in $(PLUGINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@plugins/\1.so@' -e 's@^ .*@@' ; done)
87 endif
88 ifneq (,$(BUILTINS))
89 BUILTIN_OBJ := $(shell for i in $(BUILTINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@plugins/\1.a@' -e 's@^ .*@@' ; done)
90 endif
91
92 #
93 # Misc variables
94 #
95 VLC_QUICKVERSION := $(shell grep '^ *VLC_VERSION=' configure.in | cut -f2 -d=)
96 LIBDVDCSS_QUICKVERSION := $(shell grep '^ *LIBDVDCSS_VERSION=' configure.in | cut -f2 -d=)
97
98
99 # All symbols must be exported
100 export
101
102 ###############################################################################
103 # Targets
104 ###############################################################################
105
106 #
107 # Virtual targets
108 #
109 all: Makefile.opts vlc ${ALIASES} vlc.app
110
111 Makefile.opts:
112         @echo "**** No configuration found, running ./configure..."
113         ./configure
114         $(MAKE) $(MAKECMDGOALS)
115         exit
116
117 show:
118         @echo CC: $(CC)
119         @echo CFLAGS: $(CFLAGS)
120         @echo DCFLAGS: $(DCFLAGS)
121         @echo LCFLAGS: $(LCFLAGS)
122         @echo PCFLAGS: $(PCFLAGS)
123         @echo PLCFLAGS: $(PLCFLAGS)
124         @echo C_OBJ: $(C_OBJ)
125         @echo CPP_OBJ: $(CPP_OBJ)
126         @echo PLUGIN_OBJ: $(PLUGIN_OBJ)
127         @echo BUILTIN_OBJ: $(BUILTIN_OBJ)
128
129 #
130 # Cleaning rules
131 #
132 clean: libdvdcss-clean plugins-clean vlc-clean
133         rm -f src/*/*.o extras/*/*.o
134         rm -f lib/*.so* lib/*.a
135         rm -f plugins/*.so plugins/*.a
136         rm -rf extras/MacOSX/build
137
138 libdvdcss-clean:
139         -cd extras/libdvdcss && $(MAKE) clean
140
141 plugins-clean:
142         for dir in $(PLUGINS_DIR) ; do \
143                 ( cd plugins/$${dir} && $(MAKE) clean ) ; done
144         rm -f plugins/*/*.o plugins/*/*.moc plugins/*/*.bak
145
146 vlc-clean:
147         rm -f $(C_OBJ) $(CPP_OBJ)
148         rm -f vlc gnome-vlc gvlc kvlc qvlc vlc.exe
149         rm -Rf vlc.app
150
151 distclean: clean
152         rm -f **/*.o **/*~ *.log
153         rm -f Makefile.opts
154         rm -f include/defs.h include/config.h include/modules_builtin.h
155         rm -f src/misc/modules_builtin.h
156         rm -f config*status config*cache config*log
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: libdvdcss-install vlc-install plugins-install
165
166 uninstall: libdvdcss-uninstall vlc-uninstall plugins-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)/videolan
175         $(INSTALL) -m 644 share/*.psf $(DESTDIR)$(datadir)/videolan
176         $(INSTALL) -m 644 share/*.png $(DESTDIR)$(datadir)/videolan
177         $(INSTALL) -m 644 share/*.xpm $(DESTDIR)$(datadir)/videolan
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)/videolan/*.psf
185         rm -f $(DESTDIR)$(datadir)/videolan/*.png
186         rm -f $(DESTDIR)$(datadir)/videolan/*.xpm
187
188 plugins-install:
189         mkdir -p $(DESTDIR)$(libdir)/videolan/vlc
190 ifneq (,$(PLUGINS))
191         $(INSTALL) -m 644 $(PLUGINS:%=plugins/%.so) $(DESTDIR)$(libdir)/videolan/vlc
192 endif
193
194 plugins-uninstall:
195         rm -f $(DESTDIR)$(libdir)/videolan/vlc/*.so
196
197 libdvdcss-install:
198         -cd extras/libdvdcss && $(MAKE) install
199
200 libdvdcss-uninstall:
201         -cd extras/libdvdcss && $(MAKE) uninstall
202
203 #
204 # Package generation rules
205 #
206 snapshot-common:
207         # Check that tmp isn't in the way
208         @if test -e tmp; then \
209                 echo "Error: please remove ./tmp, it is in the way"; false; \
210         else \
211                 echo "OK."; mkdir tmp; \
212         fi
213         # Copy directory structure in tmp
214         find -type d | grep -v '\(\.dep\|snapshot\|CVS\)' | while read i ; \
215                 do mkdir -p tmp/vlc/$$i ; \
216         done
217         rm -Rf tmp/vlc/tmp
218         find debian -mindepth 1 -maxdepth 1 -type d | \
219                 while read i ; do rm -Rf tmp/vlc/$$i ; done
220         # Copy .c .h .in .cpp and .glade files
221         find include src plugins -type f -name '*.[chig]*' | while read i ; \
222                 do cp $$i tmp/vlc/$$i ; done
223         # Copy plugin Makefiles
224         find plugins -type f -name Makefile | while read i ; \
225                 do cp $$i tmp/vlc/$$i ; done
226         # Copy extra programs and documentation
227         cp -a extras/* tmp/vlc/extras
228         cp -a doc/* tmp/vlc/doc
229         find tmp/vlc/extras tmp/vlc/doc \
230                 -type d -name CVS -o -name '.*' -o -name '*.[o]' | \
231                         while read i ; do rm -Rf $$i ; done
232         # Copy misc files
233         cp vlc.spec AUTHORS COPYING TODO todo.pl ChangeLog* README* INSTALL* \
234                 Makefile Makefile.opts.in Makefile.dep Makefile.modules \
235                 configure configure.in install-sh config.sub config.guess \
236                         tmp/vlc/
237         # Copy Debian control files
238         for file in debian/*dirs debian/*docs debian/*menu debian/*desktop \
239                 debian/*copyright ; do cp $$file tmp/vlc/debian ; done
240         for file in control changelog rules ; do \
241                 cp debian/$$file tmp/vlc/debian/ ; done
242         # Copy fonts and icons
243         for file in share/*png share/*xpm share/*psf ; do \
244                 cp $$file tmp/vlc/share ; done
245         for file in vlc_beos.rsrc vlc.icns gvlc_win32.ico vlc_win32_rc.rc ; do \
246                         cp share/$$file tmp/vlc/share/ ; done
247
248 snapshot: snapshot-common
249         # Build archives
250         F=vlc-${VLC_QUICKVERSION}; \
251         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$F.tar $$F); \
252         bzip2 -f -9 < tmp/$$F.tar > $$F.tar.bz2; \
253         gzip -f -9 tmp/$$F.tar ; mv tmp/$$F.tar.gz .
254         # Clean up
255         rm -Rf tmp
256
257 snapshot-nocss: snapshot-common
258         # Remove libdvdcss
259         rm -Rf tmp/vlc/extras/libdvdcss
260         rm -f tmp/vlc/*.libdvdcss
261         # Fix debian information
262         rm -f tmp/vlc/debian/libdvdcss*
263         rm -f tmp/vlc/debian/control
264         sed -e 's#^ DVDs# unencrypted DVDs#' < debian/control \
265                 | awk '{if(gsub("Package: libdvdcss",$$0))a=1;if(a==0)print $$0;if(a==1&&$$0=="")a=0}' \
266                 > tmp/vlc/debian/control
267         rm -f tmp/vlc/debian/rules
268         sed -e 's#^\(export LIBDVDCSS_FLAGS=\).*#\1"--without-dvdcss"#' < debian/rules \
269                 | awk '{if($$0=="# libdvdcss start")a=1;if(a==0)print $$0;if($$0=="# libdvdcss stop")a=0}' \
270                 > tmp/vlc/debian/rules
271         chmod +x tmp/vlc/debian/rules
272         # Build css-disabled archives
273         F=vlc-${VLC_QUICKVERSION}; G=vlc-${VLC_QUICKVERSION}-nocss; \
274         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$G.tar $$F); \
275         bzip2 -f -9 < tmp/$$G.tar > $$G.tar.bz2; \
276         gzip -f -9 tmp/$$G.tar ; mv tmp/$$G.tar.gz .
277         # Clean up
278         rm -Rf tmp
279
280 libdvdcss-snapshot: snapshot-common
281         # Remove vlc sources and icons, doc, debian directory...
282         rm -Rf tmp/vlc/src tmp/vlc/share tmp/vlc/plugins tmp/vlc/doc
283         rm -Rf tmp/vlc/extras/GNUgetopt tmp/vlc/extras/MacOSX
284         rm -Rf tmp/vlc/debian
285         # Remove useless headers
286         rm -f tmp/vlc/include/*
287         for file in defs.h.in config.h.in common.h int_types.h ; \
288                 do cp include/$$file tmp/vlc/include/ ; done
289         # Remove misc files (??? - maybe not really needed)
290         rm -f tmp/vlc/vlc.spec tmp/vlc/INSTALL-win32.txt
291         mv tmp/vlc/INSTALL.libdvdcss tmp/vlc/INSTALL
292         mv tmp/vlc/README.libdvdcss tmp/vlc/README
293         mv tmp/vlc/ChangeLog.libdvdcss tmp/vlc/ChangeLog
294         # Fix Makefile
295         rm -f tmp/vlc/Makefile
296         sed -e 's#^install:#install-unused:#' \
297                 -e 's#^uninstall:#uninstall-unused:#' \
298                 -e 's#^clean:#clean-unused:#' \
299                 -e 's#^all:.*#all: libdvdcss#' \
300                 -e 's#^libdvdcss-install:#install:#' \
301                 -e 's#^libdvdcss-uninstall:#uninstall:#' \
302                 -e 's#^libdvdcss-clean:#clean:#' \
303                 < Makefile > tmp/vlc/Makefile
304         # Build archives
305         F=libdvdcss-${LIBDVDCSS_QUICKVERSION}; \
306         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$F.tar $$F); \
307         bzip2 -f -9 < tmp/$$F.tar > $$F.tar.bz2; \
308         gzip -f -9 tmp/$$F.tar ; mv tmp/$$F.tar.gz .
309         # Clean up
310         rm -Rf tmp
311
312 deb:
313         dpkg-buildpackage -rfakeroot -us -uc
314
315 #
316 # Gtk/Gnome/* aliases and OS X application
317 #
318 gnome-vlc gvlc kvlc qvlc: vlc
319         rm -f $@ && ln -s vlc $@
320
321 .PHONY: vlc.app
322 vlc.app: Makefile.opts
323 ifneq (,$(findstring darwin,$(SYS)))
324         rm -Rf vlc.app
325         cd extras/MacOSX ; pbxbuild | grep -v '^ ' | grep -v '^\t'
326         cp -r extras/MacOSX/build/vlc.bundle ./vlc.app
327         $(INSTALL) -d vlc vlc.app/Contents/MacOS/share
328         $(INSTALL) -d vlc vlc.app/Contents/MacOS/plugins
329         $(INSTALL) vlc vlc.app/Contents/MacOS/
330 ifneq (,$(PLUGINS))
331         $(INSTALL) $(PLUGINS:%=plugins/%.so) vlc.app/Contents/MacOS/plugins
332 endif
333         $(INSTALL) -m 644 share/*.psf vlc.app/Contents/MacOS/share
334 endif
335
336 FORCE:
337
338 #
339 # Generic rules (see below)
340 #
341 $(C_DEP): %.d: FORCE
342         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
343
344 $(CPP_DEP): %.dpp: FORCE
345         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
346
347 $(H_OBJ): Makefile.opts Makefile.dep Makefile
348         rm -f $@ && cp $@.in $@
349 ifneq (,$(BUILTINS))
350         for i in $(BUILTINS) ; do \
351                 echo "int module_"$$i"_InitModule( module_t* );" >> $@ ; \
352                 echo "int module_"$$i"_ActivateModule( module_t* );" >> $@ ; \
353                 echo "int module_"$$i"_DeactivateModule( module_t* );" >> $@ ; \
354         done
355         echo "" >> $@ ;
356         printf "#define ALLOCATE_ALL_BUILTINS() do { " >> $@ ;
357         for i in $(BUILTINS) ; do \
358                 printf "ALLOCATE_BUILTIN("$$i"); " >> $@ ; \
359         done
360         echo "} while( 0 );" >> $@ ;
361         echo "" >> $@ ;
362 endif
363
364 $(C_OBJ): %.o: Makefile.opts Makefile.dep Makefile
365 $(C_OBJ): %.o: .dep/%.d
366 $(C_OBJ): %.o: %.c
367         $(CC) $(CFLAGS) -c -o $@ $<
368
369 $(CPP_OBJ): %.o: Makefile.opts Makefile.dep Makefile
370 $(CPP_OBJ): %.o: .dep/%.dpp
371 $(CPP_OBJ): %.o: %.cpp
372         $(CC) $(CFLAGS) -c -o $@ $<
373
374 $(RESOURCE_OBJ): %.o: Makefile.dep Makefile
375 ifneq (,(findstring mingw32,$(SYS)))
376 $(RESOURCE_OBJ): %.o: %.rc
377         $(WINDRES) -i $< -o $@
378 endif
379
380 #
381 # Main application target
382 #
383 vlc: Makefile.opts Makefile.dep Makefile $(H_OBJ) $(VLC_OBJ) $(BUILTIN_OBJ) plugins
384         $(CC) $(CFLAGS) -o $@ $(VLC_OBJ) $(BUILTIN_OBJ) $(LCFLAGS)
385 ifeq ($(SYS),beos)
386         xres -o $@ ./share/vlc_beos.rsrc
387         mimeset -f $@
388 endif
389
390 #
391 # Plugins target
392 #
393 plugins: Makefile.modules Makefile.opts Makefile.dep Makefile $(PLUGIN_OBJ)
394 $(PLUGIN_OBJ): FORCE
395         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.so=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:plugins/%=../%)
396
397 #
398 # Built-in modules target
399 #
400 builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
401 $(BUILTIN_OBJ): FORCE
402         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.a=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:plugins/%=../%)
403
404 #
405 # libdvdcss target
406 #
407 libdvdcss: Makefile.opts
408         cd extras/libdvdcss && $(MAKE)
409