8fdb1ccba08fd0f84bdab4bae8e60ec06f693630
[libav.git] / libavcodec / Makefile
1 #
2 # libavcodec Makefile
3 # (c) 2000-2003 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
11
12 OBJS= common.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 dv.o error_resilience.o \
18 fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \
19 vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o vcr1.o cljr.o \
20 roqvideo.o dpcm.o interplayvideo.o xan.o rpza.o cinepak.o msrle.o \
21 msvideo1.o vqavideo.o idcinvideo.o adx.o rational.o faandct.o 8bps.o \
22 smc.o parser.o flicvideo.o truemotion1.o vmdav.o lcl.o qtrle.o g726.o \
23 flac.o vp3dsp.o integer.o snow.o tscc.o sonic.o
24
25 ifeq ($(AMR_NB),yes)
26 ifeq ($(AMR_NB_FIXED),yes)
27 OBJS+= amr.o
28 AMREXTRALIBS+= amr/*.o
29 AMRLIBS=amrlibs
30 CLEANAMR=cleanamr
31 else
32 OBJS+= amr.o amr_float/sp_dec.o amr_float/sp_enc.o amr_float/interf_dec.o amr_float/interf_enc.o
33 CLEANAMR=cleanamrfloat
34 endif
35 endif
36
37 ifeq ($(HAVE_PTHREADS),yes)
38 OBJS+= pthread.o
39 endif
40
41 ifeq ($(HAVE_W32THREADS),yes)
42 OBJS+= w32thread.o
43 endif
44
45 ifeq ($(AMR_WB),yes)
46 OBJS+= amr.o amrwb_float/dec_acelp.o amrwb_float/dec_dtx.o amrwb_float/dec_gain.o \
47 amrwb_float/dec_if.o amrwb_float/dec_lpc.o amrwb_float/dec_main.o \
48 amrwb_float/dec_rom.o amrwb_float/dec_util.o amrwb_float/enc_acelp.o \
49 amrwb_float/enc_dtx.o amrwb_float/enc_gain.o amrwb_float/enc_if.o \
50 amrwb_float/enc_lpc.o amrwb_float/enc_main.o amrwb_float/enc_rom.o \
51 amrwb_float/enc_util.o amrwb_float/if_rom.o
52 endif
53 CLEANAMRWB=cleanamrwbfloat
54 ASM_OBJS=
55
56 # codecs which are patented in some non free countries like the us
57 ifeq ($(CONFIG_RISKY),yes)
58 OBJS+= h263.o h261.o msmpeg4.o h263dec.o svq1.o rv10.o wmadec.o indeo3.o
59 endif
60
61 ifeq ($(HAVE_XVMC_ACCEL),yes)
62 OBJS+= xvmcvideo.o
63 endif
64
65 # currently using liba52 for ac3 decoding
66 ifeq ($(CONFIG_AC3),yes)
67 OBJS+= a52dec.o
68
69 # using builtin liba52 or runtime linked liba52.so.0
70 ifneq ($(CONFIG_A52BIN),yes)
71 OBJS+= liba52/bit_allocate.o liba52/bitstream.o liba52/downmix.o \
72 liba52/imdct.o liba52/parse.o liba52/crc.o liba52/resample.o
73 endif
74 endif
75
76 # currently using libdts for dts decoding
77 ifeq ($(CONFIG_DTS),yes)
78 OBJS+= dtsdec.o
79 CFLAGS += $(DTS_INC)
80 EXTRALIBS += -ldts
81 endif
82
83 ifeq ($(CONFIG_FAAD),yes)
84 OBJS+= faad.o
85 ifeq ($(CONFIG_FAADBIN),yes)
86 # no libs needed
87 else
88 EXTRALIBS += -lfaad
89 endif
90 endif
91
92 ifeq ($(CONFIG_FAAC),yes)
93 OBJS+= faac.o
94 EXTRALIBS += -lfaac
95 endif
96
97 ifeq ($(CONFIG_XVID),yes)
98 OBJS+= xvidff.o
99 EXTRALIBS += -lxvidcore
100 endif
101
102 ifeq ($(CONFIG_PP),yes)
103 ifeq ($(SHARED_PP),yes)
104 EXTRALIBS += -lpostproc
105 else
106 # LIBS += libpostproc/libpostproc.a ... should be fixed
107 OBJS += libpostproc/postprocess.o
108 endif
109 endif
110
111 ifeq ($(CONFIG_MP3LAME),yes)
112 OBJS += mp3lameaudio.o
113 EXTRALIBS += -lmp3lame
114 endif
115
116 ifeq ($(CONFIG_VORBIS),yes)
117 OBJS += oggvorbis.o
118 EXTRALIBS += -lvorbis -lvorbisenc
119 endif
120
121 ifeq ($(TARGET_GPROF),yes)
122 CFLAGS+=-p
123 LDFLAGS+=-p
124 endif
125
126 # i386 mmx specific stuff
127 ifeq ($(TARGET_MMX),yes)
128 OBJS += i386/fdct_mmx.o i386/cputest.o \
129 i386/dsputil_mmx.o i386/mpegvideo_mmx.o \
130 i386/idct_mmx.o i386/motion_est_mmx.o \
131 i386/simple_idct_mmx.o i386/fft_sse.o i386/vp3dsp_mmx.o \
132 i386/vp3dsp_sse2.o
133 ifdef TARGET_BUILTIN_VECTOR
134 i386/fft_sse.o: CFLAGS+= -msse
135 depend: CFLAGS+= -msse
136 endif
137 endif
138
139 # armv4l specific stuff
140 ifeq ($(TARGET_ARCH_ARMV4L),yes)
141 ASM_OBJS += armv4l/jrevdct_arm.o armv4l/simple_idct_arm.o
142 OBJS += armv4l/dsputil_arm.o armv4l/mpegvideo_arm.o
143 endif
144
145 # sun mediaLib specific stuff
146 # currently only works when libavcodec is used in mplayer
147 ifeq ($(HAVE_MLIB),yes)
148 OBJS += mlib/dsputil_mlib.o
149 CFLAGS += $(MLIB_INC)
150 endif
151
152 # alpha specific stuff
153 ifeq ($(TARGET_ARCH_ALPHA),yes)
154 OBJS += alpha/dsputil_alpha.o alpha/mpegvideo_alpha.o \
155 alpha/simple_idct_alpha.o alpha/motion_est_alpha.o
156 ASM_OBJS += alpha/dsputil_alpha_asm.o alpha/motion_est_mvi_asm.o
157 CFLAGS += -fforce-addr -freduce-all-givs
158 endif
159
160 ifeq ($(TARGET_ARCH_POWERPC),yes)
161 OBJS += ppc/dsputil_ppc.o ppc/mpegvideo_ppc.o
162 endif
163
164 ifeq ($(TARGET_MMI),yes)
165 OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
166 endif
167
168 ifeq ($(TARGET_ALTIVEC),yes)
169 OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \
170 ppc/fft_altivec.o ppc/gmc_altivec.o ppc/fdct_altivec.o
171 endif
172
173 ifeq ($(TARGET_ARCH_SH4),yes)
174 OBJS+= sh4/idct_sh4.o sh4/dsputil_sh4.o sh4/dsputil_align.o
175 endif
176
177 ifeq ($(TARGET_ARCH_SPARC),yes)
178 OBJS+=sparc/dsputil_vis.o
179 sparc/%.o: sparc/%.c
180 $(CC) -mcpu=ultrasparc -mtune=ultrasparc $(CFLAGS) -c -o $@ $<
181 endif
182 ifeq ($(TARGET_ARCH_SPARC64),yes)
183 CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc
184 endif
185
186 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S)
187 OBJS := $(OBJS) $(ASM_OBJS)
188
189 LIB= $(LIBPREF)avcodec$(LIBSUF)
190 ifeq ($(BUILD_SHARED),yes)
191 SLIB= $(SLIBPREF)avcodec$(SLIBSUF)
192 endif
193 TESTS= imgresample-test dct-test motion-test fft-test
194
195 all: $(LIB) $(SLIB)
196
197 amrlibs:
198 $(MAKE) -C amr spclib fipoplib
199
200 tests: apiexample cpuid_test $(TESTS)
201
202 $(LIB): $(OBJS) $(AMRLIBS)
203 rm -f $@
204 $(AR) rc $@ $(OBJS) $(AMREXTRALIBS)
205 $(RANLIB) $@
206
207 $(SLIB): $(OBJS)
208 ifeq ($(CONFIG_WIN32),yes)
209 $(CC) $(SHFLAGS) -Wl,--output-def,$(@:.dll=.def) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS)
210 -lib /machine:i386 /def:$(@:.dll=.def)
211 else
212 $(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS) $(AMREXTRALIBS) $(LDFLAGS)
213 endif
214
215 dsputil.o: dsputil.c dsputil.h
216
217 libpostproc/libpostproc.a:
218 $(MAKE) -C libpostproc
219
220 %.o: %.c
221 $(CC) $(CFLAGS) -c -o $@ $<
222
223 %.o: %.S
224 $(CC) $(CFLAGS) -c -o $@ $<
225
226 depend: $(SRCS)
227 $(CC) -MM $(CFLAGS) $^ 1>.depend
228
229 dep: depend
230
231 clean: $(CLEANAMR)
232 rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so i386/*.o i386/*~ \
233 armv4l/*.o armv4l/*~ \
234 mlib/*.o mlib/*~ \
235 alpha/*.o alpha/*~ \
236 ppc/*.o ppc/*~ \
237 ps2/*.o ps2/*~ \
238 sh4/*.o sh4/*~ \
239 sparc/*.o sparc/*~ \
240 liba52/*.o liba52/*~ \
241 apiexample $(TESTS)
242 $(MAKE) -C libpostproc clean
243
244 distclean: clean
245 rm -f Makefile.bak .depend
246
247 cleanamr:
248 $(MAKE) -C amr clean
249
250 cleanamrfloat:
251 rm -f amr_float/*.o
252
253 cleanamrwbfloat:
254 $(MAKE) -C amrwb_float -f makefile.gcc clean
255
256 # api example program
257 apiexample: apiexample.c $(LIB)
258 $(CC) $(CFLAGS) -o $@ $< $(LIB) $(EXTRALIBS) -lm
259
260 # cpuid test
261 cpuid_test: i386/cputest.c
262 $(CC) $(CFLAGS) -D__TEST__ -o $@ $<
263
264 # testing progs
265
266 imgresample-test: imgresample.c
267 $(CC) $(CFLAGS) -DTEST -o $@ $^ -lm
268
269 dct-test: dct-test.o fdctref.o $(LIB)
270 $(CC) -o $@ $^ -lm
271
272 motion-test: motion_test.o $(LIB)
273 $(CC) -o $@ $^ -lm
274
275 fft-test: fft-test.o $(LIB)
276 $(CC) -o $@ $^ -lm
277
278 ifeq ($(BUILD_SHARED),yes)
279 install: all install-headers
280 ifeq ($(CONFIG_WIN32),yes)
281 install -s -m 755 $(SLIB) "$(prefix)"
282 else
283 install -d $(prefix)/lib
284 install -s -m 755 $(SLIB) $(prefix)/lib/libavcodec-$(VERSION).so
285 ln -sf libavcodec-$(VERSION).so $(prefix)/lib/libavcodec.so
286 ldconfig || true
287 endif
288 else
289 install:
290 endif
291
292 installlib: all install-headers
293 install -m 644 $(LIB) $(prefix)/lib
294
295 install-headers:
296 mkdir -p "$(prefix)/include/ffmpeg"
297 install -m 644 $(SRC_PATH)/libavcodec/avcodec.h \
298 $(SRC_PATH)/libavcodec/common.h \
299 $(SRC_PATH)/libavcodec/rational.h \
300 "$(prefix)/include/ffmpeg"
301
302 #
303 # include dependency files if they exist
304 #
305 ifneq ($(wildcard .depend),)
306 include .depend
307 endif