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