]> git.sesse.net Git - vlc/blob - Makefile
Fixed ATTR_ALIGN configure test.
[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 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 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
137 libdvdcss-clean:
138         -cd extras/libdvdcss && $(MAKE) clean
139
140 plugins-clean:
141         for dir in $(PLUGINS_DIR) ; do \
142                 ( cd plugins/$${dir} && $(MAKE) clean ) ; done
143         rm -f plugins/*/*.o plugins/*/*.moc plugins/*/*.bak
144
145 vlc-clean:
146         rm -f $(C_OBJ) $(CPP_OBJ)
147         rm -f vlc gnome-vlc gvlc kvlc qvlc vlc.exe
148         rm -Rf vlc.app
149
150 distclean: clean
151         rm -f **/*.o **/*~ *.log
152         rm -f Makefile.opts
153         rm -f include/defs.h include/config.h include/modules_builtin.h
154         rm -f src/misc/modules_builtin.h
155         rm -f config*status config*cache config*log
156         rm -f gmon.out core build-stamp
157         rm -Rf .dep
158         rm -f .gdb_history
159
160 #
161 # Install/uninstall rules
162 #
163 install: libdvdcss-install vlc-install plugins-install
164
165 uninstall: libdvdcss-uninstall vlc-uninstall plugins-uninstall
166
167 vlc-install:
168         mkdir -p $(DESTDIR)$(bindir)
169         $(INSTALL) vlc $(DESTDIR)$(bindir)
170 ifneq (,$(ALIASES))
171         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias && ln -s vlc $(DESTDIR)$(bindir)/$$alias ; fi ; done
172 endif
173         mkdir -p $(DESTDIR)$(datadir)/videolan
174         $(INSTALL) -m 644 share/*.psf $(DESTDIR)$(datadir)/videolan
175         $(INSTALL) -m 644 share/*.png $(DESTDIR)$(datadir)/videolan
176         $(INSTALL) -m 644 share/*.xpm $(DESTDIR)$(datadir)/videolan
177
178 vlc-uninstall:
179         rm -f $(DESTDIR)$(bindir)/vlc
180 ifneq (,$(ALIASES))
181         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias ; fi ; done
182 endif
183         rm -f $(DESTDIR)$(datadir)/videolan/*.psf
184         rm -f $(DESTDIR)$(datadir)/videolan/*.png
185         rm -f $(DESTDIR)$(datadir)/videolan/*.xpm
186
187 plugins-install:
188         mkdir -p $(DESTDIR)$(libdir)/videolan/vlc
189 ifneq (,$(PLUGINS))
190         $(INSTALL) -m 644 $(PLUGINS:%=plugins/%.so) $(DESTDIR)$(libdir)/videolan/vlc
191 endif
192
193 plugins-uninstall:
194         rm -f $(DESTDIR)$(libdir)/videolan/vlc/*.so
195
196 libdvdcss-install:
197         -cd extras/libdvdcss && $(MAKE) install
198
199 libdvdcss-uninstall:
200         -cd extras/libdvdcss && $(MAKE) uninstall
201
202 #
203 # Package generation rules
204 #
205 snapshot-common:
206         # Check that tmp isn't in the way
207         @if test -e tmp; then \
208                 echo "Error: please remove ./tmp, it is in the way"; false; \
209         else \
210                 echo "OK."; mkdir tmp; \
211         fi
212         # Copy directory structure in tmp
213         find -type d | grep -v '\(\.dep\|snapshot\|CVS\)' | while read i ; \
214                 do mkdir -p tmp/vlc/$$i ; \
215         done
216         rm -Rf tmp/vlc/tmp
217         find debian -mindepth 1 -maxdepth 1 -type d | \
218                 while read i ; do rm -Rf tmp/vlc/$$i ; done
219         # Copy .c .h .in .cpp and .glade files
220         find include src plugins -type f -name '*.[chig]*' | while read i ; \
221                 do cp $$i tmp/vlc/$$i ; done
222         # Copy plugin Makefiles
223         find plugins -type f -name Makefile | while read i ; \
224                 do cp $$i tmp/vlc/$$i ; done
225         # Copy extra programs and documentation
226         cp -a extras/* tmp/vlc/extras
227         cp -a doc/* tmp/vlc/doc
228         find tmp/vlc/extras tmp/vlc/doc \
229                 -type d -name CVS -o -name '.*' -o -name '*.[o]' | \
230                         while read i ; do rm -Rf $$i ; done
231         # Copy misc files
232         cp vlc.spec AUTHORS COPYING TODO todo.pl ChangeLog* README* INSTALL* \
233                 Makefile Makefile.opts.in Makefile.dep Makefile.modules \
234                 configure configure.in install-sh config.sub config.guess \
235                         tmp/vlc/
236         # Copy Debian control files
237         for file in debian/*dirs debian/*docs debian/*menu debian/*desktop \
238                 debian/*copyright ; do cp $$file tmp/vlc/debian ; done
239         for file in control changelog rules ; do \
240                 cp debian/$$file tmp/vlc/debian/ ; done
241         # Copy fonts and icons
242         for file in share/*png share/*xpm share/*psf ; do \
243                 cp $$file tmp/vlc/share ; done
244         for file in vlc_beos.rsrc vlc.icns gvlc_win32.ico vlc_win32_rc.rc ; do \
245                         cp share/$$file tmp/vlc/share/ ; done
246
247 snapshot: snapshot-common
248         # Build archives
249         F=vlc-${VLC_QUICKVERSION}; \
250         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$F.tar $$F); \
251         bzip2 -f -9 < tmp/$$F.tar > $$F.tar.bz2; \
252         gzip -f -9 tmp/$$F.tar ; mv tmp/$$F.tar.gz .
253         # Clean up
254         rm -Rf tmp
255
256 snapshot-nocss: snapshot-common
257         # Remove libdvdcss
258         rm -Rf tmp/vlc/extras/libdvdcss
259         rm -f tmp/vlc/*.libdvdcss
260         # Fix debian information
261         rm -f tmp/vlc/debian/libdvdcss*
262         rm -f tmp/vlc/debian/control
263         sed -e 's#^ DVDs# unencrypted DVDs#' < debian/control \
264                 | awk '{if(gsub("Package: libdvdcss",$$0))a=1;if(a==0)print $$0;if(a==1&&$$0=="")a=0}' \
265                 > tmp/vlc/debian/control
266         rm -f tmp/vlc/debian/rules
267         sed -e 's#^\(export LIBDVDCSS_FLAGS=\).*#\1"--without-dvdcss"#' < debian/rules \
268                 | awk '{if($$0=="# libdvdcss start")a=1;if(a==0)print $$0;if($$0=="# libdvdcss stop")a=0}' \
269                 > tmp/vlc/debian/rules
270         chmod +x tmp/vlc/debian/rules
271         # Build css-disabled archives
272         F=vlc-${VLC_QUICKVERSION}; G=vlc-${VLC_QUICKVERSION}-nocss; \
273         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$G.tar $$F); \
274         bzip2 -f -9 < tmp/$$G.tar > $$G.tar.bz2; \
275         gzip -f -9 tmp/$$G.tar ; mv tmp/$$G.tar.gz .
276         # Clean up
277         rm -Rf tmp
278
279 libdvdcss-snapshot: snapshot-common
280         # Remove vlc sources and icons, doc, debian directory...
281         rm -Rf tmp/vlc/src tmp/vlc/share tmp/vlc/plugins tmp/vlc/doc
282         rm -Rf tmp/vlc/extras/GNUgetopt tmp/vlc/extras/MacOSX_app
283         rm -Rf tmp/vlc/debian
284         # Remove useless headers
285         rm -f tmp/vlc/include/*
286         for file in defs.h.in config.h.in common.h int_types.h ; \
287                 do cp include/$$file tmp/vlc/include/ ; done
288         # Remove misc files (??? - maybe not really needed)
289         rm -f tmp/vlc/vlc.spec tmp/vlc/INSTALL-win32.txt
290         mv tmp/vlc/INSTALL.libdvdcss tmp/vlc/INSTALL
291         mv tmp/vlc/README.libdvdcss tmp/vlc/README
292         mv tmp/vlc/ChangeLog.libdvdcss tmp/vlc/ChangeLog
293         # Fix Makefile
294         rm -f tmp/vlc/Makefile
295         sed -e 's#^install:#install-unused:#' \
296                 -e 's#^uninstall:#uninstall-unused:#' \
297                 -e 's#^clean:#clean-unused:#' \
298                 -e 's#^all:.*#all: libdvdcss#' \
299                 -e 's#^libdvdcss-install:#install:#' \
300                 -e 's#^libdvdcss-uninstall:#uninstall:#' \
301                 -e 's#^libdvdcss-clean:#clean:#' \
302                 < Makefile > tmp/vlc/Makefile
303         # Build archives
304         F=libdvdcss-${LIBDVDCSS_QUICKVERSION}; \
305         mv tmp/vlc tmp/$$F; (cd tmp ; tar cf $$F.tar $$F); \
306         bzip2 -f -9 < tmp/$$F.tar > $$F.tar.bz2; \
307         gzip -f -9 tmp/$$F.tar ; mv tmp/$$F.tar.gz .
308         # Clean up
309         rm -Rf tmp
310
311 deb:
312         dpkg-buildpackage -rfakeroot -us -uc
313
314 #
315 # Gtk/Gnome/* aliases and OS X application
316 #
317 gnome-vlc gvlc kvlc qvlc: vlc
318         rm -f $@ && ln -s vlc $@
319
320 .PHONY: vlc.app
321 vlc.app: Makefile.opts
322 ifneq (,$(findstring darwin,$(SYS)))
323         rm -Rf vlc.app
324         mkdir -p vlc.app/Contents/Resources
325         mkdir -p vlc.app/Contents/MacOS/lib
326         mkdir -p vlc.app/Contents/MacOS/share
327         $(INSTALL) -m 644 extras/MacOSX_app/Contents/Info.plist vlc.app/Contents/
328         $(INSTALL) -m 644 extras/MacOSX_app/Contents/PkgInfo vlc.app/Contents/
329         $(INSTALL) vlc vlc.app/Contents/MacOS/
330         $(INSTALL) share/vlc.icns vlc.app/Contents/Resources/
331 ifneq (,$(PLUGINS))
332         $(INSTALL) $(PLUGINS:%=plugins/%.so) vlc.app/Contents/MacOS/plugins
333 endif
334         $(INSTALL) -m 644 share/*.psf vlc.app/Contents/MacOS/share
335 endif
336
337 FORCE:
338
339 #
340 # Generic rules (see below)
341 #
342 $(C_DEP): %.d: FORCE
343         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
344
345 $(CPP_DEP): %.dpp: FORCE
346         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
347
348 $(H_OBJ): Makefile.opts Makefile.dep Makefile
349         rm -f $@ && cp $@.in $@
350 ifneq (,$(BUILTINS))
351         for i in $(BUILTINS) ; do \
352                 echo "int module_"$$i"_InitModule( module_t* );" >> $@ ; \
353                 echo "int module_"$$i"_ActivateModule( module_t* );" >> $@ ; \
354                 echo "int module_"$$i"_DeactivateModule( module_t* );" >> $@ ; \
355         done
356         echo "" >> $@ ;
357         printf "#define ALLOCATE_ALL_BUILTINS() do { " >> $@ ;
358         for i in $(BUILTINS) ; do \
359                 printf "ALLOCATE_BUILTIN("$$i"); " >> $@ ; \
360         done
361         echo "} while( 0 );" >> $@ ;
362         echo "" >> $@ ;
363 endif
364
365 $(C_OBJ): %.o: Makefile.opts Makefile.dep Makefile
366 $(C_OBJ): %.o: .dep/%.d
367 $(C_OBJ): %.o: %.c
368         $(CC) $(CFLAGS) -c -o $@ $<
369
370 $(CPP_OBJ): %.o: Makefile.opts Makefile.dep Makefile
371 $(CPP_OBJ): %.o: .dep/%.dpp
372 $(CPP_OBJ): %.o: %.cpp
373         $(CC) $(CFLAGS) -c -o $@ $<
374
375 $(RESOURCE_OBJ): %.o: Makefile.dep Makefile
376 ifneq (,(findstring mingw32,$(SYS)))
377 $(RESOURCE_OBJ): %.o: %.rc
378         $(WINDRES) -i $< -o $@
379 endif
380
381 #
382 # Main application target
383 #
384 vlc: Makefile.opts Makefile.dep Makefile $(H_OBJ) $(VLC_OBJ) $(BUILTIN_OBJ) plugins
385         $(CC) $(CFLAGS) -o $@ $(VLC_OBJ) $(BUILTIN_OBJ) $(LCFLAGS)
386 ifeq ($(SYS),beos)
387         xres -o $@ ./share/vlc_beos.rsrc
388         mimeset -f $@
389 endif
390
391 #
392 # Plugins target
393 #
394 plugins: Makefile.modules Makefile.opts Makefile.dep Makefile $(PLUGIN_OBJ)
395 $(PLUGIN_OBJ): FORCE
396         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.so=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:plugins/%=../%)
397
398 #
399 # Built-in modules target
400 #
401 builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
402 $(BUILTIN_OBJ): FORCE
403         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.a=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:plugins/%=../%)
404
405 #
406 # libdvdcss target
407 #
408 libdvdcss: Makefile.opts
409         cd extras/libdvdcss && $(MAKE)
410