]> git.sesse.net Git - vlc/blob - Makefile
2d6205b131fcd326cf10019a465ea6078616e15b
[vlc] / Makefile
1 ################################################################################
2 # vlc (VideoLAN Client) main makefile
3 # (c)1998 VideoLAN
4 ################################################################################
5 # This makefile is the main makefile for the VideoLAN client.
6 ################################################################################
7
8 ################################################################################
9 # Configuration
10 ################################################################################
11
12 # Environment
13 CC=egcc
14 SHELL=/bin/sh
15
16 # Audio output settings
17 AUDIO = dsp
18 # Not yet supported
19 #AUDIO += esd
20 # Fallback method that should always work
21 AUDIO += dummy
22
23 # Video output settings
24 VIDEO = x11
25 #VIDEO += fb
26 #VIDEO += ggi
27 #VIDEO += glide
28 # Not yet supported
29 #VIDEO += beos
30 #VIDEO += dga
31 # Fallback method that should always work
32 VIDEO += dummy
33
34 # Target architecture
35 ARCH=X86
36 #ARCH=PPC
37 #ARCH=SPARC
38
39 # Target operating system
40 SYS=LINUX
41 #SYS=BSD
42 #SYS=BEOS
43
44 # For x86 architecture, choose MMX support
45 MMX=YES
46 #MMX=NO
47
48 # Decoder choice - ?? old decoder will be removed soon
49 #DECODER=old
50 DECODER=new
51
52 # Debugging mode on or off (set to 1 to activate)
53 DEBUG=0
54
55 #----------------- do not change anything below this line ----------------------
56
57 ################################################################################
58 # Configuration pre-processing
59 ################################################################################
60
61 # Program version - may only be changed by the project leader
62 PROGRAM_VERSION = 0.1.99
63
64 # audio options
65 audio := $(shell echo $(AUDIO) | tr 'A-Z' 'a-z')
66 AUDIO := $(shell echo $(AUDIO) | tr 'a-z' 'A-Z')
67
68 # video options
69 video := $(shell echo $(VIDEO) | tr 'A-Z' 'a-z')
70 VIDEO := $(shell echo $(VIDEO) | tr 'a-z' 'A-Z')
71
72 # PROGRAM_OPTIONS is an identification string of the compilation options
73 PROGRAM_OPTIONS = $(ARCH) $(SYS)
74 ifeq ($(DEBUG),1)
75 PROGRAM_OPTIONS += DEBUG
76 endif
77
78 # PROGRAM_BUILD is a complete identification of the build
79 PROGRAM_BUILD = `date -R` $(USER)@`hostname`
80
81 # DEFINE will contain some of the constants definitions decided in Makefile, 
82 # including ARCH_xx and SYS_xx. It will be passed to C compiler.
83 DEFINE += -DARCH_$(ARCH)
84 DEFINE += -DSYS_$(SYS)
85 DEFINE += -DAUDIO_OPTIONS="\"$(audio)\""
86 DEFINE += -DVIDEO_OPTIONS="\"$(video)\""
87 DEFINE += -DPROGRAM_VERSION="\"$(PROGRAM_VERSION)\""
88 DEFINE += -DPROGRAM_OPTIONS="\"$(PROGRAM_OPTIONS)\""
89 DEFINE += -DPROGRAM_BUILD="\"$(PROGRAM_BUILD)\""
90 ifeq ($(DEBUG),1)
91 DEFINE += -DDEBUG
92 endif
93
94 ################################################################################
95 # Tuning and other variables - do not change anything except if you know
96 # exactly what you are doing
97 ################################################################################
98
99 #
100 # C headers directories
101 #
102 INCLUDE += -Iinclude
103
104 #
105 # Libraries
106 #
107 LIB += -lpthread
108 LIB += -lm
109 LIB += -ldl
110
111 #
112 # C compiler flags: compilation
113 #
114 CCFLAGS += $(DEFINE) $(INCLUDE)
115 CCFLAGS += -Wall
116 CCFLAGS += -D_REENTRANT
117 CCFLAGS += -D_GNU_SOURCE
118
119 # Optimizations : don't compile debug versions with them
120 CCFLAGS += -O6
121 CCFLAGS += -ffast-math -funroll-loops -fargument-noalias-global
122 CCFLAGS += -fomit-frame-pointer
123
124 # Optimizations for x86 familiy
125 ifeq ($(ARCH),X86)
126 CCFLAGS += -malign-double
127 CCFLAGS += -march=pentiumpro
128 #CCFLAGS += -march=pentium
129 endif
130
131 # Optimizations for PowerPC
132 ifeq ($(ARCH),PPC)
133 CCFLAGS += -mcpu=604e -mmultiple -mhard-float -mstring
134 endif
135
136 # Optimizations for Sparc
137 ifeq ($(ARCH),SPARC)
138 CCFLAGS += -mhard-float
139 endif
140
141 #
142 # C compiler flags: dependancies
143 #
144 DCFLAGS += $(INCLUDE)
145 DCFLAGS += -MM
146
147 #
148 # C compiler flags: linking
149 #
150 LCFLAGS += $(LIB)
151 LCFLAGS += -Wall
152 #LCFLAGS += -s
153
154 #
155 # C compiler flags: common flags
156 #
157
158 # Eventual MMX optimizations for x86
159 ifeq ($(ARCH),X86)
160 ifeq ($(MMX), YES)
161 CFLAGS += -DHAVE_MMX
162 endif
163 endif
164
165 #
166 # Additionnal debugging flags
167 #
168
169 # Debugging support
170 ifeq ($(DEBUG),1)
171 CFLAGS += -g
172 #CFLAGS += -pg
173 endif
174
175 #################################################################################
176 # Objects and files
177 #################################################################################
178
179 #
180 # C Objects
181
182 interface_obj =                 interface/main.o \
183                                                 interface/interface.o \
184                                                 interface/intf_msg.o \
185                                                 interface/intf_cmd.o \
186                                                 interface/intf_ctrl.o \
187                                                 interface/intf_console.o
188
189 input_obj =                     input/input_vlan.o \
190                                                 input/input_file.o \
191                                                 input/input_netlist.o \
192                                                 input/input_network.o \
193                                                 input/input_ctrl.o \
194                                                 input/input_pcr.o \
195                                                 input/input_psi.o \
196                                                 input/input.o
197
198 audio_output_obj =              audio_output/audio_output.o
199
200 video_output_obj =              video_output/video_output.o \
201                                                 video_output/video_text.o \
202                                                 video_output/video_yuv.o
203
204 ac3_decoder_obj =               ac3_decoder/ac3_decoder_thread.o \
205                                                 ac3_decoder/ac3_decoder.o \
206                                                 ac3_decoder/ac3_parse.o \
207                                                 ac3_decoder/ac3_exponent.o \
208                                                 ac3_decoder/ac3_bit_allocate.o \
209                                                 ac3_decoder/ac3_mantissa.o \
210                                                 ac3_decoder/ac3_rematrix.o \
211                                                 ac3_decoder/ac3_imdct.o \
212                                                 ac3_decoder/ac3_downmix.o
213
214 audio_decoder_obj =             audio_decoder/audio_decoder.o \
215                                                 audio_decoder/audio_math.o
216
217 spu_decoder_obj =               spu_decoder/spu_decoder.o
218
219 #??generic_decoder_obj =                generic_decoder/generic_decoder.o
220 # remeber to add it to OBJ 
221
222 ifeq ($(DECODER),old)
223 CFLAGS += -DOLD_DECODER
224 video_decoder_obj =             video_decoder_ref/video_decoder.o \
225                                                 video_decoder_ref/display.o \
226                                                 video_decoder_ref/getblk.o \
227                                                 video_decoder_ref/gethdr.o \
228                                                 video_decoder_ref/getpic.o \
229                                                 video_decoder_ref/getvlc.o \
230                                                 video_decoder_ref/idct.o \
231                                                 video_decoder_ref/motion.o \
232                                                 video_decoder_ref/mpeg2dec.o \
233                                                 video_decoder_ref/recon.o \
234                                                 video_decoder_ref/spatscal.o
235 else
236 video_parser_obj =              video_parser/video_parser.o \
237                                                 video_parser/vpar_headers.o \
238                                                 video_parser/vpar_blocks.o \
239                                                 video_parser/vpar_synchro.o \
240                                                 video_parser/video_fifo.o
241
242 video_decoder_obj =             video_decoder/video_decoder.o \
243                                                 video_decoder/vdec_motion.o \
244                                                 video_decoder/vdec_motion_inner.o \
245                                                 video_decoder/vdec_idct.o
246 endif
247
248 misc_obj =                      misc/mtime.o \
249                                                 misc/rsc_files.o \
250                                                 misc/netutils.o \
251                                                 misc/decoder_fifo.o
252
253 C_OBJ = $(interface_obj) \
254                 $(input_obj) \
255                 $(audio_output_obj) \
256                 $(video_output_obj) \
257                 $(ac3_decoder_obj) \
258                 $(audio_decoder_obj) \
259                 $(spu_decoder_obj) \
260                 $(generic_decoder_obj) \
261                 $(video_parser_obj) \
262                 $(video_decoder_obj) \
263                 $(vlan_obj) \
264                 $(misc_obj)
265
266 #
267 # Assembler Objects
268
269 ifeq ($(ARCH),X86)
270 ifeq ($(MMX), YES)
271 ifeq ($(DECODER),new)
272 ASM_OBJ =                       video_decoder/vdec_idctmmx.o \
273                                                 video_output/video_yuv_mmx.o
274 else
275 ASM_OBJ =                       video_decoder_ref/vdec_idctmmx.o \
276                                                 video_output/video_yuv_mmx.o
277 endif
278 endif
279 endif
280
281 #
282 # Plugins
283 #
284 interface_plugin =      $(video:%=interface/intf_%.so)
285 audio_plugin =          $(audio:%=audio_output/aout_%.so)
286 video_plugin =          $(video:%=video_output/vout_%.so)
287
288 PLUGIN_OBJ = $(interface_plugin) \
289                 $(audio_plugin) \
290                 $(video_plugin) \
291
292 #
293 # Other lists of files
294 #
295 sources := $(C_OBJ:%.o=%.c) $(PLUGIN_OBJ:%.so=%.c)
296 dependancies := $(sources:%.c=dep/%.d)
297
298 # All symbols must be exported
299 export
300
301 ################################################################################
302 # Targets
303 ################################################################################
304
305 #
306 # Virtual targets
307 #
308 all: vlc
309
310 clean:
311         rm -f $(C_OBJ) $(ASM_OBJ) $(PLUGIN_OBJ)
312
313 distclean: clean
314         rm -f **/*.o **/*.so **/*~ *.log
315         rm -f vlc gmon.out core
316         rm -rf dep
317
318 show:
319         @echo "Command line for C objects:"
320         @echo $(CC) $(CCFLAGS) $(CFLAGS) -c -o "<dest.o>" "<src.c>"
321         @echo
322         @echo "Command line for assembler objects:"
323         @echo $(CC) $(CFLAGS) -c -o "<dest.o>" "<src.S>"
324
325 FORCE:
326
327 #
328 # Real targets
329 #
330 vlc: $(C_OBJ) $(ASM_OBJ) $(PLUGIN_OBJ)
331         $(CC) $(LCFLAGS) $(CFLAGS) --export-dynamic -rdynamic -o $@ $(C_OBJ) $(ASM_OBJ) 
332
333 #
334 # Generic rules (see below)
335 #
336 $(dependancies): %.d: FORCE
337         @$(MAKE) -s --no-print-directory -f Makefile.dep $@
338
339 $(C_OBJ): %.o: Makefile.dep
340 $(C_OBJ): %.o: dep/%.d
341 $(C_OBJ): %.o: %.c
342         @echo "compiling $*.o from $*.c"
343         @$(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
344
345 $(ASM_OBJ): %.o: Makefile.dep
346 $(ASM_OBJ): %.o: %.S
347         @echo "assembling $*.o from $*.S"
348         @$(CC) $(CFLAGS) -c -o $@ $<
349
350 $(PLUGIN_OBJ): %.so: Makefile.dep
351 $(PLUGIN_OBJ): %.so: dep/%.d
352
353 # audio plugins
354 audio_output/aout_dummy.so \
355         audio_output/aout_dsp.so: %.so: %.c
356                 @echo "compiling $*.so from $*.c"
357                 @$(CC) $(CCFLAGS) $(CFLAGS) -shared -o $@ $<
358
359 audio_output/aout_esd.so: %.so: %.c
360                 @echo "compiling $*.so from $*.c"
361                 @$(CC) $(CCFLAGS) $(CFLAGS) -laudiofile -lesd -shared -o $@ $<
362
363 # video plugins
364 interface/intf_dummy.so \
365         video_output/vout_dummy.so \
366         interface/intf_fb.so \
367         video_output/vout_fb.so: %.so: %.c
368                 @echo "compiling $*.so from $*.c"
369                 @$(CC) $(CCFLAGS) $(CFLAGS) -shared -o $@ $<
370
371 interface/intf_x11.so \
372         video_output/vout_x11.so: %.so: %.c
373                 @echo "compiling $*.so from $*.c"
374                 @$(CC) $(CCFLAGS) $(CFLAGS) -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXext -shared -o $@ $<
375
376 interface/intf_glide.so \
377         video_output/vout_glide.so: %.so: %.c
378                 @echo "compiling $*.so from $*.c"
379                 @$(CC) $(CCFLAGS) $(CFLAGS) -I/usr/include/glide -lglide2x -shared -o $@ $<
380
381 interface/intf_ggi.so \
382         video_output/vout_ggi.so: %.so: %.c
383                 @echo "compiling $*.so from $*.c"
384                 @$(CC) $(CCFLAGS) $(CFLAGS) -lggi -shared -o $@ $<
385
386
387 ################################################################################
388 # Note on generic rules and dependancies
389 ################################################################################
390
391 # Note on dependancies: each .c file is associated with a .d file, which
392 # depends of it. The .o file associated with a .c file depends of the .d, of the 
393 # .c itself, and of Makefile. The .d files are stored in a separate dep/ 
394 # directory.
395 # The dep directory should be ignored by CVS.
396
397 # Note on inclusions: depending of the target, the dependancies files must 
398 # or must not be included. The problem is that if we ask make to include a file,
399 # and this file does not exist, it is made before it can be included. In a 
400 # general way, a .d file should be included if and only if the corresponding .o 
401 # needs to be re-made.
402
403 # Two makefiles are used: the main one (this one) has regular generic rules,
404 # except for .o files, for which it calls the object Makefile. Dependancies
405 # are not included in this file.
406 # The object Makefile known how to make a .o from a .c, and includes
407 # dependancies for the target, but only those required.