]> git.sesse.net Git - vlc/blob - Makefile
4f494d813f0723085c3fe8b7bf526e6d094c4665
[vlc] / Makefile
1 ###############################################################################
2 # vlc (VideoLAN Client) main Makefile - (c)1998 VideoLAN
3 ###############################################################################
4
5 -include Makefile.opts
6
7 ###############################################################################
8 # Objects and files
9 ###############################################################################
10
11
12 # All possible plugin directories, needed for make clean
13 #
14 PLUGINS_DIR :=  alsa beos darwin dsp dummy \
15                 dvd esd fb ggi glide gnome gtk \
16                 idct \
17                 macosx mga \
18                 motion \
19                 mpeg null qt sdl \
20                 text x11 yuv
21
22 #
23 # All possible plugin objects
24 #
25 PLUGINS_TARGETS := alsa/alsa beos/beos darwin/darwin dsp/dsp dummy/dummy \
26                 dvd/dvd esd/esd fb/fb ggi/ggi glide/glide gnome/gnome gtk/gtk \
27                 idct/idct idct/idctclassic idct/idctmmx idct/idctmmxext \
28                 macosx/macosx mga/mga \
29                 motion/motion motion/motionmmx motion/motionmmxext \
30                 mpeg/es mpeg/ps mpeg/ts null/null qt/qt sdl/sdl \
31                 text/ncurses text/rc x11/x11 x11/xvideo yuv/yuv yuv/yuvmmx
32
33 #
34 # C Objects
35
36 INTERFACE =     src/interface/main.o \
37                 src/interface/interface.o \
38                 src/interface/intf_msg.o \
39                 src/interface/intf_playlist.o \
40                 src/interface/intf_channels.o \
41                 src/interface/intf_urldecode.o \
42
43 INPUT =         src/input/input_ext-dec.o \
44                 src/input/input_ext-intf.o \
45                 src/input/input_dec.o \
46                 src/input/input_programs.o \
47                 src/input/input_netlist.o \
48                 src/input/input_clock.o \
49                 src/input/input.o \
50                 src/input/mpeg_system.o
51
52 AUDIO_OUTPUT =  src/audio_output/audio_output.o \
53                 src/audio_output/aout_fifo.o \
54                 src/audio_output/aout_u8.o \
55                 src/audio_output/aout_s8.o \
56                 src/audio_output/aout_u16.o \
57                 src/audio_output/aout_s16.o \
58         src/audio_output/aout_spdif.o
59
60 VIDEO_OUTPUT =  src/video_output/video_output.o \
61                 src/video_output/video_text.o \
62                 src/video_output/video_spu.o \
63                 src/video_output/video_yuv.o
64
65 AC3_DECODER =   src/ac3_decoder/ac3_decoder_thread.o \
66                 src/ac3_decoder/ac3_decoder.o \
67                 src/ac3_decoder/ac3_parse.o \
68                 src/ac3_decoder/ac3_exponent.o \
69                 src/ac3_decoder/ac3_bit_allocate.o \
70                 src/ac3_decoder/ac3_mantissa.o \
71                 src/ac3_decoder/ac3_rematrix.o \
72                 src/ac3_decoder/ac3_imdct.o \
73                 src/ac3_decoder/ac3_imdct_c.o \
74                 src/ac3_decoder/ac3_srfft.o \
75                 src/ac3_decoder/ac3_downmix.o \
76                 src/ac3_decoder/ac3_downmix_c.o
77
78 AC3_SPDIF = src/ac3_spdif/ac3_spdif.o \
79         src/ac3_spdif/ac3_iec958.o
80
81 LPCM_DECODER =  src/lpcm_decoder/lpcm_decoder_thread.o \
82                 src/lpcm_decoder/lpcm_decoder.o
83
84 AUDIO_DECODER = src/audio_decoder/audio_decoder.o \
85                 src/audio_decoder/adec_generic.o \
86                 src/audio_decoder/adec_layer1.o \
87                 src/audio_decoder/adec_layer2.o \
88                 src/audio_decoder/adec_math.o
89
90 SPU_DECODER =   src/spu_decoder/spu_decoder.o
91
92 #GEN_DECODER =  src/generic_decoder/generic_decoder.o
93
94 VIDEO_PARSER =  src/video_parser/video_parser.o \
95                 src/video_parser/vpar_headers.o \
96                 src/video_parser/vpar_blocks.o \
97                 src/video_parser/vpar_synchro.o \
98                 src/video_parser/video_fifo.o
99
100 VIDEO_DECODER = src/video_decoder/video_decoder.o
101
102 MISC =          src/misc/mtime.o \
103                 src/misc/tests.o \
104                 src/misc/modules.o \
105                 src/misc/netutils.o
106
107 C_OBJ =         $(INTERFACE) \
108                 $(INPUT) \
109                 $(VIDEO_OUTPUT) \
110                 $(AUDIO_OUTPUT) \
111                 $(AC3_DECODER) \
112         $(AC3_SPDIF) \
113                 $(LPCM_DECODER) \
114                 $(AUDIO_DECODER) \
115                 $(SPU_DECODER) \
116                 $(GEN_DECODER) \
117                 $(VIDEO_PARSER) \
118                 $(VIDEO_DECODER) \
119                 $(MISC)
120
121 #
122 # Misc Objects
123
124 ifeq ($(GETOPT),1)
125 C_OBJ += extras/GNUgetopt/getopt.o extras/GNUgetopt/getopt1.o 
126 endif
127
128 ifeq ($(SYS),beos)
129 CPP_OBJ =       src/misc/beos_specific.o
130 endif
131
132 ifneq (,$(findstring darwin,$(SYS)))
133 C_OBJ +=        src/misc/darwin_specific.o
134 endif
135
136 #
137 # Generated header
138 #
139 H_OBJ =         include/modules_builtin.h
140
141 #
142 # Other lists of files
143 #
144 C_DEP := $(C_OBJ:%.o=.dep/%.d)
145 CPP_DEP := $(CPP_OBJ:%.o=.dep/%.dpp)
146
147 #
148 # Translate plugin names
149 #
150 ifneq (,$(PLUGINS))
151 PLUGIN_OBJ := $(shell for i in $(PLUGINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@lib/\1.so@' -e 's@^ .*@@' ; done)
152 endif
153 ifneq (,$(BUILTINS))
154 BUILTIN_OBJ := $(shell for i in $(BUILTINS) ; do echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.*/\('$$i'\) .*@lib/\1.a@' -e 's@^ .*@@' ; done)
155 endif
156
157 # All symbols must be exported
158 export
159
160 ###############################################################################
161 # Targets
162 ###############################################################################
163
164 #
165 # Virtual targets
166 #
167 all: vlc ${ALIASES} plugins vlc.app
168
169 clean:
170         for dir in $(PLUGINS_DIR) ; do \
171                 ( cd plugins/$${dir} && $(MAKE) clean ) ; done
172         rm -f plugins/*/*.o plugins/*/*.moc plugins/*/*.bak
173         rm -f $(C_OBJ) $(CPP_OBJ)
174         rm -f src/*/*.o extras/*/*.o
175         rm -f lib/*.so lib/*.a vlc gnome-vlc gvlc kvlc qvlc
176         rm -Rf vlc.app
177
178 distclean: clean
179         rm -f **/*.o **/*~ *.log
180         rm -f Makefile.opts
181         rm -f include/defs.h include/config.h include/modules_builtin.h
182         rm -f config*status config*cache config*log
183         rm -f gmon.out core build-stamp
184         rm -Rf .dep
185         rm -f .gdb_history
186
187 install:
188         mkdir -p $(DESTDIR)$(bindir)
189         $(INSTALL) vlc $(DESTDIR)$(bindir)
190 ifneq (,$(ALIASES))
191         for alias in $(ALIASES) ; do if test $$alias ; then rm -f $(DESTDIR)$(bindir)/$$alias && ln -s vlc $(DESTDIR)$(bindir)/$$alias ; fi ; done
192 endif
193         mkdir -p $(DESTDIR)$(libdir)/videolan/vlc
194 ifneq (,$(PLUGINS))
195         $(INSTALL) -m 644 $(PLUGINS:%=lib/%.so) $(DESTDIR)$(libdir)/videolan/vlc
196 endif
197         mkdir -p $(DESTDIR)$(datadir)/videolan
198         $(INSTALL) -m 644 share/*.psf $(DESTDIR)$(datadir)/videolan
199         $(INSTALL) -m 644 share/*.png $(DESTDIR)$(datadir)/videolan
200         $(INSTALL) -m 644 share/*.xpm $(DESTDIR)$(datadir)/videolan
201
202 show:
203         @echo CC: $(CC)
204         @echo CFLAGS: $(CFLAGS)
205         @echo DCFLAGS: $(DCFLAGS)
206         @echo LCFLAGS: $(LCFLAGS)
207         @echo C_OBJ: $(C_OBJ)
208         @echo CPP_OBJ: $(CPP_OBJ)
209         @echo objects: $(objects)
210         @echo cppobjects: $(cppobjects)
211         @echo PLUGIN_OBJ: $(PLUGIN_OBJ)
212         @echo BUILTIN_OBJ: $(BUILTIN_OBJ)
213
214
215 # ugliest of all, but I have no time to do it -- sam
216 snapshot: Makefile.opts
217         rm -Rf /tmp/vlc-${PROGRAM_VERSION}* /tmp/vlc-${PROGRAM_VERSION}nocss*
218         # copy archive in /tmp
219         find -type d | grep -v CVS | grep -v '\.dep' | while read i ; \
220                 do mkdir -p /tmp/vlc-${PROGRAM_VERSION}/$$i ; \
221         done
222         find debian -mindepth 1 -maxdepth 1 -type d | \
223                 while read i ; do rm -Rf /tmp/vlc-${PROGRAM_VERSION}/$$i ; done
224         # .c .h .in .cpp .glade
225         find include src plugins -type f -name '*.[chig]*' | while read i ; \
226                 do cp $$i /tmp/vlc-${PROGRAM_VERSION}/$$i ; done
227         # Makefiles
228         find . plugins -type f -name Makefile | while read i ; \
229                 do cp $$i /tmp/vlc-${PROGRAM_VERSION}/$$i ; done
230         # extra files
231         cp -a extras/* /tmp/vlc-${PROGRAM_VERSION}/extras
232         cp -a doc/* /tmp/vlc-${PROGRAM_VERSION}/doc
233         find /tmp/vlc-${PROGRAM_VERSION}/extras \
234                 /tmp/vlc-${PROGRAM_VERSION}/doc \
235                 -type d -name CVS | while read i ; \
236                         do rm -Rf $$i ; \
237                 done
238         # copy misc files
239         cp vlc.spec AUTHORS COPYING ChangeLog INSTALL README TODO todo.pl \
240                 Makefile.opts.in Makefile.dep Makefile.modules \
241                 configure configure.in install-sh config.sub config.guess \
242                         /tmp/vlc-${PROGRAM_VERSION}/
243         for file in control control-css vlc-gtk.menu vlc.copyright vlc.docs \
244                 changelog changelog-css rules rules-css vlc.dirs vlc.desktop \
245                 gvlc.desktop gnome-vlc.desktop vlc.menu ; do \
246                         cp debian/$$file /tmp/vlc-${PROGRAM_VERSION}/debian/ ; \
247                 done
248         for file in default8x16.psf default8x9.psf vlc_beos.rsrc vlc.icns ; do \
249                 cp share/$$file /tmp/vlc-${PROGRAM_VERSION}/share/ ; done
250         for icon in vlc gvlc qvlc gnome-vlc kvlc ; do \
251                 cp share/$$icon.xpm share/$$icon.png \
252                         /tmp/vlc-${PROGRAM_VERSION}/share/ ; done
253
254         # build css-enabled archives
255         (cd /tmp ; tar cf vlc-${PROGRAM_VERSION}.tar vlc-${PROGRAM_VERSION} ; \
256                 bzip2 -f -9 < vlc-${PROGRAM_VERSION}.tar \
257                         > vlc-${PROGRAM_VERSION}.tar.bz2 ; \
258                 gzip -f -9 vlc-${PROGRAM_VERSION}.tar )
259         mv /tmp/vlc-${PROGRAM_VERSION}.tar.gz \
260                 /tmp/vlc-${PROGRAM_VERSION}.tar.bz2 ..
261
262         # clean up
263         rm -Rf /tmp/vlc-${PROGRAM_VERSION}*
264
265 .PHONY: vlc.app
266 vlc.app:
267 ifneq (,$(findstring darwin,$(SYS)))
268         rm -Rf vlc.app
269         mkdir -p vlc.app/Contents/Resources
270         mkdir -p vlc.app/Contents/MacOS/lib
271         mkdir -p vlc.app/Contents/MacOS/share
272         $(INSTALL) -m 644 extras/MacOSX_app/Contents/Info.plist vlc.app/Contents/
273         $(INSTALL) -m 644 extras/MacOSX_app/Contents/PkgInfo vlc.app/Contents/
274         $(INSTALL) vlc vlc.app/Contents/MacOS/
275         $(INSTALL) share/vlc.icns vlc.app/Contents/Resources/
276 ifneq (,$(PLUGINS))
277         $(INSTALL) $(PLUGINS:%=lib/%.so) vlc.app/Contents/MacOS/lib
278 endif
279         $(INSTALL) -m 644 share/*.psf vlc.app/Contents/MacOS/share
280 endif
281
282 FORCE:
283
284 #
285 # GTK/Gnome aliases - don't add too many aliases which could bloat
286 # the namespace
287 #
288 gnome-vlc gvlc kvlc qvlc: vlc
289         rm -f $@ && ln -s vlc $@
290
291 #
292 # Generic rules (see below)
293 #
294 $(C_DEP): %.d: FORCE
295         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
296
297 $(CPP_DEP): %.dpp: FORCE
298         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
299
300 $(H_OBJ): Makefile.opts Makefile.dep Makefile
301         rm -f $@ && cp $@.in $@
302 ifneq (,$(BUILTINS))
303         for i in $(BUILTINS) ; do \
304                 echo "int module_"$$i"_InitModule( module_t* );" >> $@ ; \
305                 echo "int module_"$$i"_ActivateModule( module_t* );" >> $@ ; \
306                 echo "int module_"$$i"_DeactivateModule( module_t* );" >> $@ ; \
307         done
308 endif
309         echo "" >> $@ ;
310         printf "#define ALLOCATE_ALL_BUILTINS() do { " >> $@ ;
311 ifneq (,$(BUILTINS))
312         for i in $(BUILTINS) ; do \
313                 printf "ALLOCATE_BUILTIN("$$i"); " >> $@ ; \
314         done
315 endif
316         echo "} while( 0 );" >> $@ ;
317         echo "" >> $@ ;
318
319 $(C_OBJ): %.o: Makefile.opts Makefile.dep Makefile
320 $(C_OBJ): %.o: .dep/%.d
321 $(C_OBJ): %.o: %.c
322 ifneq (,$(findstring darwin,$(SYS)))
323 #this is uglier of all
324         @if test "src/ac3_decoder/ac3_imdct.c" = "$<"; then $(CC) `echo $(CFLAGS) | sed -e 's/-O3/-O/'` -c -o $@ $<; echo "(CC) `echo $(CFLAGS) | sed -e 's/-O3/-O/'` -c -o $@ $<"; else $(CC) $(CFLAGS) -c -o $@ $<; echo "$(CC) $(CFLAGS) -c -o $@ $<"; fi
325 else
326         $(CC) $(CFLAGS) -c -o $@ $<
327 endif
328
329 $(CPP_OBJ): %.o: Makefile.opts Makefile.dep Makefile
330 $(CPP_OBJ): %.o: .dep/%.dpp
331 $(CPP_OBJ): %.o: %.cpp
332         $(CC) $(CFLAGS) -c -o $@ $<
333
334 #
335 # Main application target
336 #
337 vlc: Makefile.opts Makefile.dep Makefile $(H_OBJ) $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ)
338         $(CC) $(CFLAGS) -o $@ $(C_OBJ) $(CPP_OBJ) $(BUILTIN_OBJ) $(LCFLAGS)
339 ifeq ($(SYS),beos)
340         rm -f ./lib/_APP_
341         ln -s ../vlc ./lib/_APP_
342         xres -o $@ ./share/vlc_beos.rsrc
343         mimeset -f $@
344 endif
345
346 #
347 # Plugins target
348 #
349 plugins: Makefile.modules Makefile.opts Makefile.dep Makefile $(PLUGIN_OBJ)
350 $(PLUGIN_OBJ): FORCE
351         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:lib/%.so=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:%=../../%)
352
353 #
354 # Built-in modules target
355 #
356 builtins: Makefile.modules Makefile.opts Makefile.dep Makefile $(BUILTIN_OBJ)
357 $(BUILTIN_OBJ): FORCE
358         cd $(shell echo " "$(PLUGINS_TARGETS)" " | sed -e 's@.* \([^/]*/\)'$(@:lib/%.a=%)' .*@plugins/\1@' -e 's@^ .*@@') && $(MAKE) $(@:%=../../%)
359         $(RANLIB) $@
360