support BUILDSUF patch by <charles dot yates at pandora dot be>
[ffmpeg.git] / libavcodec / Makefile
1 #
2 # libavcodec Makefile
3 # (c) 2000-2005 Fabrice Bellard
4 #
5 include ../config.mak
6
7 VPATH=$(SRC_PATH)/libavcodec
8
9 # NOTE: -I.. is needed to include config.h
10 CFLAGS=$(OPTFLAGS) -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE $(AMR_CFLAGS)
11
12 OBJS= bitstream.o utils.o mem.o allcodecs.o \
13       mpegvideo.o jrevdct.o jfdctfst.o jfdctint.o\
14       mpegaudio.o ac3enc.o mjpeg.o resample.o resample2.o dsputil.o \
15       motion_est.o imgconvert.o imgresample.o \
16       mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \
17       ratecontrol.o adpcm.o eval.o error_resilience.o \
18       fft.o mdct.o raw.o golomb.o cabac.o\
19       dpcm.o adx.o rational.o faandct.o parser.o g726.o \
20       vp3dsp.o integer.o h264idct.o rangecoder.o pnm.o h263.o msmpeg4.o h263dec.o
21       
22 ifeq ($(CONFIG_AASC_DECODER),yes)
23     OBJS+= aasc.o
24 endif
25 ifeq ($(CONFIG_ALAC_DECODER),yes)
26     OBJS+= alac.o
27 endif
28 ifneq ($(CONFIG_ASV1_DECODER)$(CONFIG_ASV1_ENCODER)$(CONFIG_ASV2_DECODER)$(CONFIG_ASV2_ENCODER),)
29     OBJS+= asv1.o
30 endif
31 ifeq ($(CONFIG_CINEPAK_DECODER),yes)
32     OBJS+= cinepak.o
33 endif
34 ifneq ($(CONFIG_CLJR_DECODER)$(CONFIG_CLJR_ENCODER),)
35     OBJS+= cljr.o
36 endif
37 ifeq ($(CONFIG_CYUV_DECODER),yes)
38     OBJS+= cyuv.o
39 endif
40 ifneq ($(CONFIG_DVVIDEO_DECODER)$(CONFIG_DVVIDEO_ENCODER),)
41     OBJS+= dv.o
42 endif
43 ifeq ($(CONFIG_EIGHTBPS_DECODER),yes)
44     OBJS+= 8bps.o
45 endif
46 ifneq ($(CONFIG_FFV1_DECODER)$(CONFIG_FFV1_ENCODER),)
47     OBJS+= ffv1.o
48 endif
49 ifeq ($(CONFIG_FLAC_DECODER),yes)
50     OBJS+= flac.o
51 endif
52 ifeq ($(CONFIG_FLIC_DECODER),yes)
53     OBJS+= flicvideo.o
54 endif
55 ifeq ($(CONFIG_FOURXM_DECODER),yes)
56     OBJS+= 4xm.o
57 endif
58 ifneq ($(CONFIG_H261_DECODER)$(CONFIG_H261_ENCODER),)
59     OBJS+= h261.o
60 endif
61 ifneq ($(CONFIG_H264_DECODER)$(CONFIG_SVQ3_DECODER),)
62     OBJS+= h264.o
63 endif
64 ifneq ($(CONFIG_HUFFYUV_DECODER)$(CONFIG_HUFFYUV_ENCODER)$(CONFIG_FFVHUFF_DECODER)$(CONFIG_FFVHUFF_ENCODER),)
65     OBJS+= huffyuv.o
66 endif
67 ifeq ($(CONFIG_IDCIN_DECODER),yes)
68     OBJS+= idcinvideo.o
69 endif
70 ifeq ($(CONFIG_INDEO2_DECODER),yes)
71     OBJS+= indeo2.o
72 endif
73 ifeq ($(CONFIG_INDEO3_DECODER),yes)
74     OBJS+= indeo3.o
75 endif
76 ifeq ($(CONFIG_INTERPLAY_VIDEO_DECODER),yes)
77     OBJS+= interplayvideo.o
78 endif
79 ifneq ($(CONFIG_MSZH_DECODER)$(CONFIG_ZLIB_DECODER)$(CONFIG_ZLIB_ENCODER),)
80     OBJS+= lcl.o
81 endif
82 ifeq ($(CONFIG_LOCO_DECODER),yes)
83     OBJS+= loco.o
84 endif
85 ifneq ($(CONFIG_MACE3_DECODER)$(CONFIG_MACE6_DECODER),)
86     OBJS+= mace.o
87 endif
88 ifeq ($(CONFIG_MSRLE_DECODER),yes)
89     OBJS+= msrle.o
90 endif
91 ifeq ($(CONFIG_MSVIDEO1_DECODER),yes)
92     OBJS+= msvideo1.o
93 endif
94 ifneq ($(CONFIG_PNG_DECODER)$(CONFIG_PNG_ENCODER),)
95     OBJS+= png.o
96 endif
97 ifeq ($(CONFIG_QDRAW_DECODER),yes)
98     OBJS+= qdrw.o
99 endif
100 ifeq ($(CONFIG_QPEG_DECODER),yes)
101     OBJS+= qpeg.o
102 endif
103 ifeq ($(CONFIG_QTRLE_DECODER),yes)
104     OBJS+= qtrle.o
105 endif
106 ifeq ($(CONFIG_RA_144_DECODER),yes)
107     OBJS+= ra144.o
108 endif
109 ifeq ($(CONFIG_RA_288_DECODER),yes)
110     OBJS+= ra288.o
111 endif
112 ifeq ($(CONFIG_ROQ_DECODER),yes)
113     OBJS+= roqvideo.o
114 endif
115 ifeq ($(CONFIG_RPZA_DECODER),yes)
116     OBJS+= rpza.o
117 endif
118 ifneq ($(CONFIG_RV10_DECODER)$(CONFIG_RV20_DECODER)$(CONFIG_RV10_ENCODER)$(CONFIG_RV20_ENCODER),)
119     OBJS+= rv10.o
120 endif
121 ifeq ($(CONFIG_SHORTEN_DECODER),yes)
122     OBJS+= shorten.o
123 endif
124 ifeq ($(CONFIG_SMC_DECODER),yes)
125     OBJS+= smc.o
126 endif
127 ifneq ($(CONFIG_SNOW_DECODER)$(CONFIG_Snow_ENCODER),)
128     OBJS+= snow.o
129 endif
130 ifneq ($(CONFIG_SONIC_DECODER)$(CONFIG_SONIC_ENCODER)$(CONFIG_SONIC_LS_ENCODER),)
131     OBJS+= sonic.o
132 endif
133 ifneq ($(CONFIG_SVQ1_DECODER)$(CONFIG_SVQ1_ENCODER),)
134     OBJS+= svq1.o
135 endif
136 ifeq ($(CONFIG_TRUEMOTION1_DECODER),yes)
137     OBJS+= truemotion1.o
138 endif
139 ifeq ($(CONFIG_TSCC_DECODER),yes)
140     OBJS+= tscc.o
141 endif
142 ifeq ($(CONFIG_ULTI_DECODER),yes)
143     OBJS+= ulti.o
144 endif
145 ifneq ($(CONFIG_VC9_DECODER)$(CONFIG_WMV3_DECODER),)
146     OBJS+= vc9.o
147 endif
148 ifneq ($(CONFIG_VCR1_DECODER)$(CONFIG_VCR1_ENCODER),)
149     OBJS+= vcr1.o
150 endif
151 ifneq ($(CONFIG_VMDVIDEO_DECODER)$(CONFIG_VMDAUDIO_DECODER),)
152     OBJS+= vmdav.o
153 endif
154 ifneq ($(CONFIG_VP3_DECODER)$(CONFIG_THEORA_DECODER),)
155     OBJS+= vp3.o
156 endif
157 ifeq ($(CONFIG_VQA_DECODER),yes)
158     OBJS+= vqavideo.o
159 endif
160 ifneq ($(CONFIG_WMAV1_DECODER)$(CONFIG_WMAV2_DECODER),)
161     OBJS+= wmadec.o
162 endif
163 ifeq ($(CONFIG_WNV1_DECODER),yes)
164     OBJS+= wnv1.o
165 endif
166 ifeq ($(CONFIG_WS_SND1_DECODER),yes)
167     OBJS+= ws-snd1.o
168 endif
169 ifneq ($(CONFIG_XAN_WC3_DECODER)$(CONFIG_XAN_WC4_DECODER),)
170     OBJS+= xan.o
171 endif
172 ifeq ($(CONFIG_XL_DECODER),yes)
173     OBJS+= xl.o
174 endif
175       
176       
177 AMROBJS=
178 ifeq ($(AMR_NB),yes)
179 ifeq ($(AMR_NB_FIXED),yes)
180 AMROBJS= amr.o
181 AMREXTRALIBS+= amr/*.o
182 AMRLIBS=amrlibs
183 CLEANAMR=cleanamr
184 else
185 AMROBJS= amr.o
186 OBJS+= amr_float/sp_dec.o amr_float/sp_enc.o amr_float/interf_dec.o amr_float/interf_enc.o
187 CLEANAMR=cleanamrfloat
188 endif
189 endif
190
191 ifeq ($(HAVE_PTHREADS),yes)
192 OBJS+= pthread.o
193 endif
194
195 ifeq ($(HAVE_W32THREADS),yes)
196 OBJS+= w32thread.o
197 endif
198
199 ifeq ($(HAVE_BEOSTHREADS),yes)
200 OBJS+= beosthread.o
201 endif
202
203 ifeq ($(AMR_WB),yes)
204 AMROBJS= amr.o
205 OBJS+= amrwb_float/dec_acelp.o amrwb_float/dec_dtx.o amrwb_float/dec_gain.o \
206                 amrwb_float/dec_if.o amrwb_float/dec_lpc.o amrwb_float/dec_main.o \
207                 amrwb_float/dec_rom.o amrwb_float/dec_util.o amrwb_float/enc_acelp.o \
208                 amrwb_float/enc_dtx.o amrwb_float/enc_gain.o amrwb_float/enc_if.o \
209                 amrwb_float/enc_lpc.o amrwb_float/enc_main.o amrwb_float/enc_rom.o \
210                 amrwb_float/enc_util.o amrwb_float/if_rom.o
211 endif
212 OBJS+= $(AMROBJS)
213 CLEANAMRWB=cleanamrwbfloat
214 ASM_OBJS=
215
216 ifeq ($(HAVE_XVMC_ACCEL),yes)
217 OBJS+= xvmcvideo.o
218 endif
219
220 # currently using liba52 for ac3 decoding
221 ifeq ($(CONFIG_AC3),yes)
222 OBJS+= a52dec.o
223
224 # using builtin liba52 or runtime linked liba52.so.0
225 ifneq ($(CONFIG_A52BIN),yes)
226 OBJS+= liba52/bit_allocate.o liba52/bitstream.o liba52/downmix.o \
227         liba52/imdct.o  liba52/parse.o liba52/crc.o liba52/resample.o
228 endif
229 endif
230
231 # currently using libdts for dts decoding
232 ifeq ($(CONFIG_DTS),yes)
233 OBJS+= dtsdec.o
234 CFLAGS += $(DTS_INC)
235 EXTRALIBS += -ldts
236 endif
237
238 ifeq ($(CONFIG_FAAD),yes)
239 OBJS+= faad.o
240 ifeq ($(CONFIG_FAADBIN),yes)
241 # no libs needed
242 else
243 EXTRALIBS += -lfaad
244 endif
245 endif
246
247 ifeq ($(CONFIG_FAAC),yes)
248 OBJS+= faac.o
249 EXTRALIBS += -lfaac
250 endif
251
252 ifeq ($(CONFIG_XVID),yes)
253 OBJS+= xvidff.o
254 EXTRALIBS += -lxvidcore
255 endif
256
257 ifeq ($(CONFIG_X264),yes)
258 OBJS+= x264.o
259 EXTRALIBS += -lx264
260 endif
261
262 ifeq ($(CONFIG_PP),yes)
263 ifeq ($(SHARED_PP),yes)
264 EXTRALIBS += -L$(VPATH)/libpostproc -lpostproc$(BUILDSUF)
265 else
266 # LIBS += libpostproc/libpostproc.a ... should be fixed
267 OBJS += libpostproc/postprocess.o
268 endif
269 endif
270
271 ifeq ($(CONFIG_MP3LAME),yes)
272 OBJS += mp3lameaudio.o
273 EXTRALIBS += -lmp3lame
274 endif
275
276 ifeq ($(CONFIG_LIBOGG),yes)
277 ifeq ($(CONFIG_LIBVORBIS),yes)
278 OBJS += oggvorbis.o
279 EXTRALIBS += -lvorbisenc -lvorbis
280 endif
281 ifeq ($(CONFIG_LIBTHEORA), yes)
282 OBJS += oggtheora.o
283 EXTRALIBS += -ltheora
284 endif
285 EXTRALIBS += -logg
286 endif
287
288 ifeq ($(TARGET_GPROF),yes)
289 CFLAGS+=-p
290 LDFLAGS+=-p
291 endif
292
293 # i386 mmx specific stuff
294 ifeq ($(TARGET_MMX),yes)
295 OBJS += i386/fdct_mmx.o i386/cputest.o \
296         i386/dsputil_mmx.o i386/mpegvideo_mmx.o \
297         i386/idct_mmx.o i386/motion_est_mmx.o \
298         i386/simple_idct_mmx.o i386/fft_sse.o i386/vp3dsp_mmx.o \
299         i386/vp3dsp_sse2.o
300 ifdef TARGET_BUILTIN_VECTOR
301 i386/fft_sse.o: CFLAGS+= -msse
302 depend: CFLAGS+= -msse
303 endif
304 endif
305
306 # armv4l specific stuff
307 ifeq ($(TARGET_ARCH_ARMV4L),yes)
308 ASM_OBJS += armv4l/jrevdct_arm.o armv4l/simple_idct_arm.o
309 OBJS += armv4l/dsputil_arm.o armv4l/mpegvideo_arm.o
310 endif
311
312 # sun mediaLib specific stuff
313 # currently only works when libavcodec is used in mplayer
314 ifeq ($(HAVE_MLIB),yes)
315 OBJS += mlib/dsputil_mlib.o
316 CFLAGS += $(MLIB_INC)
317 endif
318
319 # alpha specific stuff
320 ifeq ($(TARGET_ARCH_ALPHA),yes)
321 OBJS += alpha/dsputil_alpha.o alpha/mpegvideo_alpha.o \
322         alpha/simple_idct_alpha.o alpha/motion_est_alpha.o
323 ASM_OBJS += alpha/dsputil_alpha_asm.o alpha/motion_est_mvi_asm.o
324 CFLAGS += -fforce-addr
325 endif
326
327 ifeq ($(TARGET_ARCH_POWERPC),yes)
328 OBJS += ppc/dsputil_ppc.o ppc/mpegvideo_ppc.o
329 endif
330
331 ifeq ($(TARGET_MMI),yes)
332 OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
333 endif
334
335 ifeq ($(TARGET_ALTIVEC),yes)
336 OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \
337         ppc/fft_altivec.o ppc/gmc_altivec.o ppc/fdct_altivec.o \
338         ppc/dsputil_h264_altivec.o
339 endif
340
341 ifeq ($(TARGET_ARCH_SH4),yes)
342 OBJS+= sh4/idct_sh4.o sh4/dsputil_sh4.o sh4/dsputil_align.o
343 endif
344
345 ifeq ($(TARGET_ARCH_SPARC),yes)
346 OBJS+=sparc/dsputil_vis.o
347 sparc/%.o: sparc/%.c
348         $(CC) -mcpu=ultrasparc -mtune=ultrasparc $(CFLAGS) -c -o $@ $< 
349 endif
350 ifeq ($(TARGET_ARCH_SPARC64),yes)
351 CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
352 endif
353
354 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S)
355 OBJS := $(OBJS) $(ASM_OBJS)
356
357 LIB= $(LIBPREF)avcodec$(LIBSUF)
358 ifeq ($(BUILD_SHARED),yes)
359 SLIB= $(SLIBPREF)avcodec$(SLIBSUF)
360 endif
361 TESTS= imgresample-test dct-test motion-test fft-test
362
363 all: $(LIB) $(SLIB)
364
365 amrlibs:
366         $(MAKE) -C amr spclib fipoplib
367
368 tests: apiexample cpuid_test $(TESTS)
369
370 $(LIB): $(OBJS) $(AMRLIBS)
371         rm -f $@
372         $(AR) rc $@ $(OBJS) $(AMREXTRALIBS)
373         $(RANLIB) $@
374
375 $(SLIB): $(OBJS)
376 ifeq ($(CONFIG_PP),yes)
377         $(MAKE) -C libpostproc
378 endif
379 ifeq ($(CONFIG_WIN32),yes)
380         $(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
381         -lib /machine:i386 /def:$(@:.dll=.def)
382 else
383         $(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS) $(LDFLAGS)
384 endif
385
386 dsputil.o: dsputil.c dsputil.h
387
388 libpostproc/libpostproc.a:
389         $(MAKE) -C libpostproc
390
391 %.o: %.c
392         $(CC) $(CFLAGS) -c -o $@ $< 
393
394 %.o: %.S
395         $(CC) $(CFLAGS) -c -o $@ $<
396
397 depend: $(SRCS)
398         $(CC) -MM $(CFLAGS) $^ 1>.depend
399
400 dep:    depend
401
402 clean: $(CLEANAMR)
403         rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so i386/*.o i386/*~ \
404            armv4l/*.o armv4l/*~ \
405            mlib/*.o mlib/*~ \
406            alpha/*.o alpha/*~ \
407            ppc/*.o ppc/*~ \
408            ps2/*.o ps2/*~ \
409            sh4/*.o sh4/*~ \
410            sparc/*.o sparc/*~ \
411            liba52/*.o liba52/*~ \
412            apiexample $(TESTS)
413         $(MAKE) -C libpostproc clean
414
415 distclean: clean
416         rm -f Makefile.bak .depend
417
418 cleanamr:
419         $(MAKE) -C amr clean
420
421 cleanamrfloat:
422         rm -f amr_float/*.o
423
424 cleanamrwbfloat:
425         $(MAKE) -C amrwb_float -f makefile.gcc clean
426
427 # api example program
428 apiexample: apiexample.c $(LIB)
429         $(CC) $(CFLAGS) -o $@ $< $(LIB) $(EXTRALIBS) -lm
430
431 # cpuid test
432 cpuid_test: i386/cputest.c
433         $(CC) $(CFLAGS) -D__TEST__ -o $@ $<
434
435 # testing progs
436
437 imgresample-test: imgresample.c
438         $(CC) $(CFLAGS) -DTEST -o $@ $^ -lm
439
440 dct-test: dct-test.o fdctref.o $(LIB)
441         $(CC) -o $@ $^ -lm
442
443 motion-test: motion_test.o $(LIB)
444         $(CC) -o $@ $^ -lm
445
446 fft-test: fft-test.o $(LIB)
447         $(CC) -o $@ $^ -lm
448
449 ifeq ($(BUILD_SHARED),yes)
450 install: all install-headers
451 ifeq ($(CONFIG_WIN32),yes)
452         install $(INSTALLSTRIP) -m 755 $(SLIB) "$(prefix)"
453 else
454         install -d $(libdir)
455         install $(INSTALLSTRIP) -m 755 $(SLIB) $(libdir)/libavcodec-$(VERSION).so
456         ln -sf libavcodec-$(VERSION).so $(libdir)/libavcodec.so
457         ldconfig || true
458 endif
459 ifeq ($(CONFIG_PP),yes)
460         $(MAKE) -C libpostproc $@
461 endif
462 else
463 install:
464 endif
465
466 installlib: all install-headers
467         install -m 644 $(LIB) "$(libdir)"
468
469 install-headers:
470         mkdir -p "$(prefix)/include/ffmpeg"
471         install -m 644 $(SRC_PATH)/libavcodec/avcodec.h \
472                        $(SRC_PATH)/libavcodec/common.h \
473                        $(SRC_PATH)/libavcodec/rational.h \
474                 "$(prefix)/include/ffmpeg"
475
476 #
477 # include dependency files if they exist
478 #
479 ifneq ($(wildcard .depend),)
480 include .depend
481 endif