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