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