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