]> git.sesse.net Git - vlc/blob - Makefile
* ./src/interface/main.c: we no longer segfault if argc == 0.
[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 :=  a52 \
17                 aa \
18                 ac3_adec \
19                 ac3_spdif \
20                 access \
21                 alsa \
22                 arts \
23                 avi \
24                 beos \
25                 chroma \
26                 directx \
27                 downmix \
28                 dsp \
29                 dummy \
30                 dvd \
31                 dvdread \
32                 esd \
33                 fb \
34                 ffmpeg \
35                 filter \
36                 fx \
37                 ggi \
38                 glide \
39                 gtk \
40                 idct \
41                 imdct \
42                 kde \
43                 lirc \
44                 lpcm_adec \
45                 macosx \
46                 mad \
47                 memcpy \
48                 mga \
49                 motion \
50                 mpeg_system \
51                 mpeg_adec \
52                 mpeg_vdec \
53                 network \
54                 ogg \
55                 qnx \
56                 qt \
57                 satellite \
58                 sdl \
59                 spudec \
60                 text \
61                 vcd \
62                 win32 \
63                 x11
64
65 PLUGINS_TARGETS := a52/a52 \
66                 aa/aa \
67                 ac3_adec/ac3_adec \
68                 ac3_spdif/ac3_spdif \
69                 access/file \
70                 access/udp \
71                 access/http \
72                 alsa/alsa \
73                 arts/arts \
74                 avi/avi \
75                 beos/beos \
76                 chroma/chroma_i420_rgb \
77                 chroma/chroma_i420_rgb_mmx \
78                 chroma/chroma_i420_yuy2 \
79                 chroma/chroma_i420_yuy2_mmx \
80                 chroma/chroma_i422_yuy2 \
81                 chroma/chroma_i422_yuy2_mmx \
82                 chroma/chroma_i420_ymga \
83                 chroma/chroma_i420_ymga_mmx \
84                 directx/directx \
85                 downmix/downmix \
86                 downmix/downmixsse \
87                 downmix/downmix3dn \
88                 dsp/dsp \
89                 dummy/dummy \
90                 dummy/null \
91                 dvd/dvd \
92                 dvdread/dvdread \
93                 esd/esd \
94                 fb/fb \
95                 ffmpeg/ffmpeg \
96                 filter/filter_deinterlace \
97                 filter/filter_transform \
98                 filter/filter_invert \
99                 filter/filter_distort \
100                 filter/filter_wall \
101                 fx/fx_scope \
102                 ggi/ggi \
103                 glide/glide \
104                 gtk/gnome \
105                 gtk/gtk \
106                 idct/idct \
107                 idct/idctclassic \
108                 idct/idctmmx \
109                 idct/idctmmxext \
110                 idct/idctaltivec \
111                 imdct/imdct \
112                 imdct/imdct3dn \
113                 imdct/imdctsse \
114                 kde/kde \
115                 lirc/lirc \
116                 lpcm_adec/lpcm_adec \
117                 macosx/macosx \
118                 mad/mad \
119                 memcpy/memcpy \
120                 memcpy/memcpymmx \
121                 memcpy/memcpymmxext \
122                 memcpy/memcpy3dn \
123                 memcpy/memcpyaltivec \
124                 mga/mga \
125                 mga/xmga \
126                 motion/motion \
127                 motion/motionmmx \
128                 motion/motionmmxext \
129                 motion/motion3dnow \
130                 motion/motionaltivec \
131                 mpeg_system/mpeg_es \
132                 mpeg_system/mpeg_ps \
133                 mpeg_system/mpeg_ts \
134                 mpeg_adec/mpeg_adec \
135                 mpeg_vdec/mpeg_vdec \
136                 network/ipv4 \
137                 network/ipv6 \
138                 ogg/vorbis \
139                 qnx/qnx \
140                 qt/qt \
141                 satellite/satellite \
142                 sdl/sdl \
143                 spudec/spudec \
144                 text/logger \
145                 text/ncurses \
146                 text/rc \
147                 vcd/vcd \
148                 win32/waveout \
149                 win32/intfwin \
150                 x11/x11 \
151                 x11/xvideo
152
153 #
154 # C Objects
155
156 INTERFACE := main interface intf_msg intf_playlist intf_eject
157 INPUT := input input_ext-plugins input_ext-dec input_ext-intf input_dec input_programs input_clock mpeg_system
158 VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
159 AUDIO_OUTPUT := audio_output aout_ext-dec aout_pcm aout_spdif
160 MISC := mtime modules configuration netutils iso_lang
161
162 C_OBJ :=        $(INTERFACE:%=src/interface/%.o) \
163                 $(INPUT:%=src/input/%.o) \
164                 $(VIDEO_OUTPUT:%=src/video_output/%.o) \
165                 $(AUDIO_OUTPUT:%=src/audio_output/%.o) \
166                 $(MISC:%=src/misc/%.o)
167
168 #
169 # Misc Objects
170
171 ifeq ($(NEED_GETOPT),1)
172 C_OBJ += extras/GNUgetopt/getopt.o extras/GNUgetopt/getopt1.o 
173 endif
174
175 ifeq ($(NEED_SYMBOLS),1)
176 C_OBJ += src/misc/symbols.o
177 endif
178
179 ifeq ($(SYS),beos)
180 CPP_OBJ :=      src/misc/beos_specific.o
181 endif
182
183 ifneq (,$(findstring darwin,$(SYS)))
184 C_OBJ +=        src/misc/darwin_specific.o
185 endif
186
187 ifneq (,$(findstring mingw32,$(SYS)))
188 C_OBJ +=        src/misc/win32_specific.o
189 RESOURCE_OBJ := share/vlc_win32_rc.o
190 endif
191
192 VLC_OBJ := $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(RESOURCE_OBJ)
193
194 #
195 # Generated header
196 #
197 H_OBJ :=        src/misc/modules_builtin.h
198
199 #
200 # Other lists of files
201 #
202 C_DEP := $(C_OBJ:%.o=.dep/%.d)
203 CPP_DEP := $(CPP_OBJ:%.o=.dep/%.dpp)
204
205 #
206 # Translate plugin names
207 #
208 ifneq (,$(PLUGINS))
209 PLUGIN_OBJ := $(shell for i in $(PLUGINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@plugins/\1.so@' -e 's@^ .*@@' ; done)
210 endif
211 ifneq (,$(BUILTINS))
212 BUILTIN_OBJ := $(shell for i in $(BUILTINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@plugins/\1.a@' -e 's@^ .*@@' ; done)
213 endif
214
215 #
216 # Misc variables
217 #
218 VERSION := $(shell grep '^ *VERSION=' configure.in | head -1 | sed 's/"//g' | cut -f2 -d=)
219
220 # All symbols must be exported
221 export
222
223 ###############################################################################
224 # Targets
225 ###############################################################################
226
227 #
228 # Virtual targets
229 #
230 all: Makefile.opts vlc ${ALIASES} vlc.app plugins po
231
232 Makefile.opts:
233         @echo "**** No configuration found, please run ./configure"
234         @exit 1
235 #       ./configure
236 #       $(MAKE) $(MAKECMDGOALS)
237 #       exit    
238
239 show:
240         @echo CC: $(CC)
241         @echo CFLAGS: $(CFLAGS)
242         @echo LDFLAGS: $(LDFLAGS)
243         @echo plugins_CFLAGS: $(plugins_CFLAGS)
244         @echo plugins_LDFLAGS: $(plugins_LDFLAGS)
245         @echo builtins_CFLAGS: $(builtins_CFLAGS)
246         @echo builtins_LDFLAGS: $(builtins_LDFLAGS)
247         @echo C_OBJ: $(C_OBJ)
248         @echo CPP_OBJ: $(CPP_OBJ)
249         @echo PLUGIN_OBJ: $(PLUGIN_OBJ)
250         @echo BUILTIN_OBJ: $(BUILTIN_OBJ)
251
252 #
253 # Cleaning rules
254 #
255 clean: plugins-clean po-clean vlc-clean
256         rm -f src/*/*.o extras/*/*.o
257         rm -f lib/*.so* lib/*.a
258         rm -f plugins/*.so plugins/*.a plugins/*.lib plugins/*.tds
259         rm -rf extras/MacOSX/build
260
261 po-clean:
262         -cd po && $(MAKE) clean
263
264 plugins-clean:
265         for dir in $(PLUGINS_DIR) ; do \
266                 ( cd plugins/$${dir} \
267                         && $(MAKE) -f ../../Makefile.modules clean ) ; done
268         rm -f plugins/*/*.o plugins/*/*.lo plugins/*/*.moc plugins/*/*.bak
269
270 vlc-clean:
271         rm -f $(C_OBJ) $(CPP_OBJ)
272         rm -f vlc gnome-vlc gvlc kvlc qvlc vlc.exe
273         rm -Rf vlc.app
274
275 distclean: clean
276         -cd po && $(MAKE) maintainer-clean
277         rm -f **/*.o **/*~ *.log
278         rm -f Makefile.opts
279         rm -f include/defs.h include/modules_builtin.h
280         rm -f src/misc/modules_builtin.h
281         rm -f config*status config*cache config*log conftest*
282         rm -f gmon.out core build-stamp
283         rm -Rf .dep
284         rm -f .gdb_history
285
286 #
287 # Install/uninstall rules
288 #
289 install: vlc-install plugins-install po-install
290
291 uninstall: vlc-uninstall plugins-uninstall po-uninstall
292
293 vlc-install:
294         mkdir -p $(DESTDIR)$(bindir)
295         $(INSTALL) vlc $(DESTDIR)$(bindir)
296 ifneq (,$(ALIASES))
297         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias && ln -s vlc $(DESTDIR)$(bindir)/$$alias ; fi ; done
298 endif
299         mkdir -p $(DESTDIR)$(datadir)/videolan
300         $(INSTALL) -m 644 share/*.psf $(DESTDIR)$(datadir)/videolan
301         $(INSTALL) -m 644 share/*.png $(DESTDIR)$(datadir)/videolan
302         $(INSTALL) -m 644 share/*.xpm $(DESTDIR)$(datadir)/videolan
303
304 vlc-uninstall:
305         rm -f $(DESTDIR)$(bindir)/vlc
306 ifneq (,$(ALIASES))
307         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias ; fi ; done
308 endif
309         rm -f $(DESTDIR)$(datadir)/videolan/*.psf
310         rm -f $(DESTDIR)$(datadir)/videolan/*.png
311         rm -f $(DESTDIR)$(datadir)/videolan/*.xpm
312
313 plugins-install:
314         mkdir -p $(DESTDIR)$(libdir)/videolan/vlc
315 ifneq (,$(PLUGINS))
316         $(INSTALL) -m 644 $(PLUGINS:%=plugins/%.so) $(DESTDIR)$(libdir)/videolan/vlc
317 endif
318
319 plugins-uninstall:
320         rm -f $(DESTDIR)$(libdir)/videolan/vlc/*.so
321
322 po-install:
323         -cd po && $(MAKE) install
324
325 po-uninstall:
326         -cd po && $(MAKE) uninstall
327
328 #
329 # Package generation rules
330 #
331 dist:
332         # Check that tmp isn't in the way
333         @if test -e tmp; then \
334                 echo "Error: please remove ./tmp, it is in the way"; false; \
335         else \
336                 echo "OK."; mkdir tmp; \
337         fi
338         # Copy directory structure in tmp
339         find -type d | grep -v '\(\.dep\|snapshot\|CVS\)' | while read i ; \
340                 do mkdir -p tmp/vlc/$$i ; \
341         done
342         rm -Rf tmp/vlc/tmp
343         find debian -mindepth 1 -maxdepth 1 -type d | \
344                 while read i ; do rm -Rf tmp/vlc/$$i ; done
345         # Copy .c .h .in .cpp and .glade files
346         find include src plugins -type f -name '*.[bcdhigrst]*' | while read i ; \
347                 do cp $$i tmp/vlc/$$i ; done
348         # Grmbl... special case...
349         for i in API BUGS DESIGN TODO ; \
350                 do cp plugins/mad/$$i tmp/vlc/plugins/mad ; done
351         # Copy plugin Makefiles
352         find plugins -type f -name Makefile | while read i ; \
353                 do cp $$i tmp/vlc/$$i ; done
354         # Copy extra programs and documentation
355         cp -a extras/* tmp/vlc/extras
356         cp -a doc/* tmp/vlc/doc
357         find tmp/vlc/extras tmp/vlc/doc \
358                 -type d -name CVS -o -name '.*' -o -name '*.[o]' | \
359                         while read i ; do rm -Rf $$i ; done
360         # Copy gettext stuff
361         cp po/ChangeLog po/vlc.pot po/*.po tmp/vlc/po
362         for i in Makefile.in.in POTFILES.in ; do cp po/$$i tmp/vlc/po ; done
363         # Copy misc files
364         cp FAQ AUTHORS COPYING TODO todo.pl ChangeLog* README* INSTALL* \
365                 ABOUT-NLS BUGS MODULES vlc.spec \
366                 Makefile Makefile.opts.in Makefile.dep Makefile.modules \
367                 configure configure.in install-sh install-win32 macosx-dmg \
368                 config.sub config.guess aclocal.m4 mkinstalldirs \
369                         tmp/vlc/
370         # Copy Debian control files
371         for file in debian/*dirs debian/*docs debian/*menu debian/*desktop \
372                 debian/*copyright ; do cp $$file tmp/vlc/debian ; done
373         for file in control changelog rules ; do \
374                 cp debian/$$file tmp/vlc/debian/ ; done
375         # Copy ipkg control files
376         for file in control rules patch ; do \
377                 cp ipkg/$$file tmp/vlc/ipkg/ ; done
378         # Copy fonts and icons
379         for file in share/*vlc* share/*psf; do \
380                 cp $$file tmp/vlc/share ; done
381         # Build archives
382         F=vlc-${VERSION}; \
383         mv tmp/vlc tmp/$$F; (cd tmp ; tar czf ../$$F.tar.gz $$F); \
384         # Clean up
385         rm -Rf tmp
386
387 package-win32:
388         # XXX: this rule is probably only useful to you if you have exactly
389         # the same setup as me. Contact sam@zoy.org if you need to use it.
390         #
391         # Check that tmp isn't in the way
392         @if test -e tmp; then \
393                 echo "Error: please remove ./tmp, it is in the way"; false; \
394         else \
395                 echo "OK."; mkdir tmp; \
396         fi
397         # Create installation script
398         cp install-win32 tmp/nsi
399         # Copy relevant files
400         cp vlc.exe tmp/ 
401         $(STRIP) tmp/vlc.exe
402         cp INSTALL.win32 tmp/INSTALL.txt ; unix2dos tmp/INSTALL.txt
403         for file in AUTHORS COPYING ChangeLog README FAQ TODO ; \
404                         do cp $$file tmp/$${file}.txt ; \
405                         unix2dos tmp/$${file}.txt ; done
406         mkdir tmp/plugins
407         cp $(PLUGINS:%=plugins/%.so) tmp/plugins/ 
408         # don't include these two
409         #rm -f tmp/plugins/gtk.so tmp/plugins/sdl.so
410 ifneq (,$(PLUGINS))
411         for i in $(PLUGINS) ; do if test $$i != intfwin ; then $(STRIP) tmp/plugins/$$i.so ; fi ; done
412 endif
413         mkdir tmp/share
414         for file in default8x16.psf default8x9.psf ; \
415                 do cp share/$$file tmp/share/ ; done
416         # Create package 
417         wine ~/.wine/fake_windows/Program\ Files/NSIS/makensis.exe -- /DVERSION=${VERSION} /CD tmp/nsi
418         # Clean up
419         rm -Rf tmp
420
421 package-beos:
422         # Check that tmp isn't in the way
423         @if test -e tmp; then \
424                 echo "Error: please remove ./tmp, it is in the way"; false; \
425         else \
426                 echo "OK."; mkdir tmp; \
427         fi
428         
429         # Create dir
430         mkdir -p tmp/vlc/share
431         # Copy relevant files
432         cp vlc tmp/vlc/
433         strip tmp/vlc/vlc
434         cp AUTHORS COPYING ChangeLog README FAQ TODO tmp/vlc/
435         for file in default8x16.psf default8x9.psf ; \
436                 do cp share/$$file tmp/vlc/share/ ; done
437         mkdir tmp/vlc/plugins
438         cp $(PLUGINS:%=plugins/%.so) tmp/vlc/plugins/ 
439         strip $(PLUGINS:%=tmp/vlc/plugins/%.so)
440         # Create package 
441         mv tmp/vlc tmp/vlc-${VERSION}
442         (cd tmp ; find vlc-${VERSION} | \
443         zip -9 -@ vlc-${VERSION}-BeOS-x86.zip )
444         mv tmp/vlc-${VERSION}-BeOS-x86.zip .
445         # Clean up
446         rm -Rf tmp
447
448 package-macosx:
449         # Check that tmp isn't in the way
450         @if test -e tmp; then \
451                 echo "Error: please remove ./tmp, it is in the way"; false; \
452         else \
453                 echo "OK."; mkdir tmp; \
454         fi
455
456         # Copy relevant files 
457         cp -R vlc.app tmp/
458         cp AUTHORS COPYING ChangeLog README FAQ TODO tmp/
459
460         # Create disk image 
461         ./macosx-dmg 0 "vlc-${VERSION}" tmp/* 
462
463         # Clean up
464         rm -Rf tmp
465
466 #
467 # Gtk/Gnome/* aliases and OS X application
468 #
469 gnome-vlc gvlc kvlc qvlc: vlc
470         rm -f $@ && ln -s vlc $@
471
472 .PHONY: vlc.app
473 vlc.app: vlc plugins
474 ifneq (,$(findstring darwin,$(SYS)))
475         rm -Rf vlc.app
476         cd extras/MacOSX ; pbxbuild | grep -v '^ ' | grep -v '^\t'
477         cp -r extras/MacOSX/build/vlc.bundle ./vlc.app
478         $(INSTALL) -d vlc.app/Contents/MacOS/share
479         $(INSTALL) -d vlc.app/Contents/MacOS/plugins
480         $(INSTALL) vlc vlc.app/Contents/MacOS/
481 ifneq (,$(PLUGINS))
482         $(INSTALL) $(PLUGINS:%=plugins/%.so) vlc.app/Contents/MacOS/plugins
483 endif
484         $(INSTALL) -m 644 share/*.psf vlc.app/Contents/MacOS/share
485 endif
486
487 FORCE:
488
489 #
490 # Generic rules (see below)
491 #
492 $(H_OBJ): Makefile.opts Makefile.dep Makefile
493 #       @echo "regenerating $@"
494         @rm -f $@ && cp $@.in $@
495 ifneq (,$(BUILTINS))
496         @for i in $(BUILTINS) ; do \
497                 echo "int InitModule__MODULE_"$$i"( module_t* );" >>$@; \
498                 echo "int ActivateModule__MODULE_"$$i"( module_t* );" >>$@; \
499                 echo "int DeactivateModule__MODULE_"$$i"( module_t* );" >>$@; \
500         done
501         @echo "" >> $@ ;
502 endif
503         @echo "#define ALLOCATE_ALL_BUILTINS() \\" >> $@ ;
504         @echo "    do \\" >> $@ ;
505         @echo "    { \\" >> $@ ;
506 ifneq (,$(BUILTINS))
507         @for i in $(BUILTINS) ; do \
508                 echo "        ALLOCATE_BUILTIN("$$i"); \\" >> $@ ; \
509         done
510 endif
511         @echo "    } while( 0 );" >> $@ ;
512         @echo "" >> $@ ;
513
514 $(C_DEP): %.d: FORCE
515         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
516
517 $(CPP_DEP): %.dpp: FORCE
518         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
519
520 $(C_OBJ): %.o: Makefile.opts Makefile.dep Makefile
521 $(C_OBJ): %.o: $(H_OBJ)
522 $(C_OBJ): %.o: .dep/%.d
523 $(C_OBJ): %.o: %.c
524         $(CC) $(CFLAGS) $(vlc_CFLAGS) -c -o $@ $<
525
526 $(CPP_OBJ): %.o: Makefile.opts Makefile.dep Makefile
527 $(CPP_OBJ): %.o: $(H_OBJ)
528 $(CPP_OBJ): %.o: .dep/%.dpp
529 $(CPP_OBJ): %.o: %.cpp
530         $(CC) $(CFLAGS) $(vlc_CFLAGS) -c -o $@ $<
531
532 $(RESOURCE_OBJ): %.o: Makefile.dep Makefile
533 ifneq (,(findstring mingw32,$(SYS)))
534 $(RESOURCE_OBJ): %.o: %.rc
535         $(WINDRES) -i $< -o $@
536 endif
537
538 #
539 # Main application target
540 #
541 vlc: Makefile.opts Makefile.dep Makefile $(VLC_OBJ) $(BUILTIN_OBJ)
542         $(CC) $(CFLAGS) -o $@ $(VLC_OBJ) $(BUILTIN_OBJ) $(LDFLAGS) $(vlc_LDFLAGS) $(builtins_LDFLAGS)
543 ifeq ($(SYS),beos)
544         xres -o $@ ./share/vlc_beos.rsrc
545         mimeset -f $@
546 endif
547
548 #
549 # Plugins target
550 #
551 plugins: Makefile.modules Makefile.opts Makefile.dep Makefile $(PLUGIN_OBJ)
552 $(PLUGIN_OBJ): FORCE
553         @cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.so=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) -f ../../Makefile.modules $(@:plugins/%=../%)
554
555 #
556 # Built-in modules target
557 #
558 builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
559 $(BUILTIN_OBJ): FORCE
560         @cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:plugins/%.a=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) -f ../../Makefile.modules $(@:plugins/%=../%)
561
562 #
563 # gettext target
564 #
565 po: FORCE
566         @cd po && $(MAKE)
567