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