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