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