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