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