* link libfaad when needed
[libav.git] / libavcodec / Makefile
1 #
2 # libavcodec Makefile
3 # (c) 2000, 2001, 2002 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) -Wall -g -DHAVE_AV_CONFIG_H -I.. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE
11 LDFLAGS= -g
12
13 OBJS= common.o utils.o mem.o allcodecs.o \
14 mpegvideo.o jrevdct.o jfdctfst.o jfdctint.o\
15 mpegaudio.o ac3enc.o mjpeg.o resample.o dsputil.o \
16 motion_est.o imgconvert.o imgresample.o \
17 mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \
18 ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \
19 fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \
20 vp3.o
21 ASM_OBJS=
22
23 # codecs which are patented in some non free countries like the us
24 ifeq ($(CONFIG_RISKY),yes)
25 OBJS+= h263.o msmpeg4.o h263dec.o svq1.o rv10.o wmadec.o indeo3.o
26 endif
27
28 # currently using liba52 for ac3 decoding
29 ifeq ($(CONFIG_AC3),yes)
30 OBJS+= a52dec.o
31
32 # using builtin liba52 or runtime linked liba52.so.0
33 ifneq ($(CONFIG_A52BIN),yes)
34 OBJS+= liba52/bit_allocate.o liba52/bitstream.o liba52/downmix.o \
35 liba52/imdct.o liba52/parse.o liba52/crc.o liba52/resample.o
36 endif
37 endif
38
39 ifeq ($(CONFIG_FAAD),yes)
40 OBJS+= faad.o
41 ifeq ($(CONFIG_FAADBIN),yes)
42 # no libs needed
43 else
44 EXTRALIBS += -lfaad
45 endif
46 endif
47
48 ifeq ($(CONFIG_PP),yes)
49 ifeq ($(SHARED_PP),yes)
50 EXTRALIBS += -lpostproc
51 else
52 # LIBS += libpostproc/libpostproc.a ... should be fixed
53 OBJS += libpostproc/postprocess.o
54 endif
55 endif
56
57 ifeq ($(CONFIG_MP3LAME),yes)
58 OBJS += mp3lameaudio.o
59 EXTRALIBS += -lmp3lame
60 endif
61
62 ifeq ($(CONFIG_VORBIS),yes)
63 OBJS += oggvorbis.o
64 EXTRALIBS += -lvorbis -lvorbisenc
65 endif
66
67 ifeq ($(TARGET_GPROF),yes)
68 CFLAGS+=-p
69 LDFLAGS+=-p
70 endif
71
72 # i386 mmx specific stuff
73 ifeq ($(TARGET_MMX),yes)
74 OBJS += i386/fdct_mmx.o i386/cputest.o \
75 i386/dsputil_mmx.o i386/mpegvideo_mmx.o \
76 i386/idct_mmx.o i386/motion_est_mmx.o \
77 i386/simple_idct_mmx.o i386/fft_sse.o
78 ifdef TARGET_BUILTIN_VECTOR
79 i386/fft_sse.o: CFLAGS+= -msse
80 endif
81 endif
82
83 # armv4l specific stuff
84 ifeq ($(TARGET_ARCH_ARMV4L),yes)
85 ASM_OBJS += armv4l/jrevdct_arm.o
86 OBJS += armv4l/dsputil_arm.o armv4l/mpegvideo_arm.o
87 endif
88
89 # sun mediaLib specific stuff
90 # currently only works when libavcodec is used in mplayer
91 ifeq ($(HAVE_MLIB),yes)
92 OBJS += mlib/dsputil_mlib.o
93 CFLAGS += $(MLIB_INC)
94 endif
95
96 # alpha specific stuff
97 ifeq ($(TARGET_ARCH_ALPHA),yes)
98 OBJS += alpha/dsputil_alpha.o alpha/mpegvideo_alpha.o \
99 alpha/simple_idct_alpha.o alpha/motion_est_alpha.o
100 ASM_OBJS += alpha/dsputil_alpha_asm.o alpha/motion_est_mvi_asm.o
101 CFLAGS += -fforce-addr -freduce-all-givs
102 endif
103
104 ifeq ($(TARGET_ARCH_POWERPC),yes)
105 OBJS += ppc/dsputil_ppc.o ppc/mpegvideo_ppc.o
106 endif
107
108 ifeq ($(TARGET_MMI),yes)
109 OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
110 endif
111
112 ifeq ($(TARGET_ALTIVEC),yes)
113 ifeq ($(TARGET_OS),Darwin)
114 CFLAGS += -faltivec
115 else
116 CFLAGS += -maltivec -mabi=altivec
117 endif
118 OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \
119 ppc/fft_altivec.o ppc/gmc_altivec.o
120 endif
121
122 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S)
123 OBJS := $(OBJS) $(ASM_OBJS)
124
125 LIB= $(LIBPREF)avcodec$(LIBSUF)
126 ifeq ($(BUILD_SHARED),yes)
127 SLIB= $(SLIBPREF)avcodec$(SLIBSUF)
128 endif
129 TESTS= imgresample-test dct-test motion-test fft-test
130
131 all: $(LIB) $(SLIB)
132
133 tests: apiexample cpuid_test $(TESTS)
134
135 $(LIB): $(OBJS)
136 rm -f $@
137 $(AR) rc $@ $(OBJS)
138 $(RANLIB) $@
139
140 $(SLIB): $(OBJS)
141 $(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS)
142
143 dsputil.o: dsputil.c dsputil.h
144
145 libpostproc/libpostproc.a:
146 $(MAKE) -C libpostproc
147
148 %.o: %.c
149 $(CC) $(CFLAGS) -c -o $@ $<
150
151 %.o: %.S
152 $(CC) $(CFLAGS) -c -o $@ $<
153
154 # motion_est_alpha uses the MVI extension, which is not available with
155 # -mcpu=ev4 (default) or ev5/ev56. Thus, force -mcpu=pca56 in those
156 # cases.
157 ifeq ($(TARGET_ARCH_ALPHA),yes)
158 alpha/motion_est_alpha.o: alpha/motion_est_alpha.c
159 cpu=`echo "$(CFLAGS)" | sed -n 's,.*-mcpu=\([a-zA-Z0-9]*\).*,\1,p'`; \
160 case x"$$cpu" in x|xev[45]*) newcpu=pca56;; *) newcpu=$$cpu;; esac; \
161 echo $(CC) $(CFLAGS) -mcpu=$$newcpu -c -o $@ $<;\
162 $(CC) $(CFLAGS) -mcpu=$$newcpu -c -o $@ $<
163 endif
164
165 depend: $(SRCS)
166 $(CC) -MM $(CFLAGS) $^ 1>.depend
167
168 dep: depend
169
170 clean:
171 rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so i386/*.o i386/*~ \
172 armv4l/*.o armv4l/*~ \
173 mlib/*.o mlib/*~ \
174 alpha/*.o alpha/*~ \
175 ppc/*.o ppc/*~ \
176 ps2/*.o ps2/*~ \
177 liba52/*.o liba52/*~ \
178 apiexample $(TESTS)
179 $(MAKE) -C libpostproc clean
180
181 distclean: clean
182 rm -f Makefile.bak .depend
183
184 # api example program
185 apiexample: apiexample.c $(LIB)
186 $(CC) $(CFLAGS) -o $@ $< $(LIB) $(EXTRALIBS) -lm
187
188 # cpuid test
189 cpuid_test: i386/cputest.c
190 $(CC) $(CFLAGS) -D__TEST__ -o $@ $<
191
192 # testing progs
193
194 imgresample-test: imgresample.c
195 $(CC) $(CFLAGS) -DTEST -o $@ $^ -lm
196
197 dct-test: dct-test.o fdctref.o $(LIB)
198 $(CC) -o $@ $^ -lm
199
200 motion-test: motion_test.o $(LIB)
201 $(CC) -o $@ $^ -lm
202
203 fft-test: fft-test.o $(LIB)
204 $(CC) -o $@ $^ -lm
205
206 install: all
207 ifeq ($(BUILD_SHARED),yes)
208 install -d $(prefix)/lib
209 install -s -m 755 $(SLIB) $(prefix)/lib/libavcodec-$(VERSION).so
210 ln -sf libavcodec-$(VERSION).so $(prefix)/lib/libavcodec.so
211 ldconfig || true
212 mkdir -p $(prefix)/include/ffmpeg
213 install -m 644 $(VPATH)/avcodec.h $(prefix)/include/ffmpeg/avcodec.h
214 install -m 644 $(VPATH)/common.h $(prefix)/include/ffmpeg/common.h
215 endif
216
217 installlib: all
218 install -m 644 $(LIB) $(prefix)/lib
219 mkdir -p $(prefix)/include/ffmpeg
220 install -m 644 $(SRC_PATH)/libavcodec/avcodec.h $(SRC_PATH)/libavcodec/common.h \
221 $(prefix)/include/ffmpeg
222
223 #
224 # include dependency files if they exist
225 #
226 ifneq ($(wildcard .depend),)
227 include .depend
228 endif