b7ba13095df2b1ea8643c6a246276f990e637e97
[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 endif
42
43 ifeq ($(CONFIG_PP),yes)
44 ifeq ($(SHARED_PP),yes)
45 EXTRALIBS += -lpostproc
46 else
47 # LIBS += libpostproc/libpostproc.a ... should be fixed
48 OBJS += libpostproc/postprocess.o
49 endif
50 endif
51
52 ifeq ($(CONFIG_MP3LAME),yes)
53 OBJS += mp3lameaudio.o
54 EXTRALIBS += -lmp3lame
55 endif
56
57 ifeq ($(CONFIG_VORBIS),yes)
58 OBJS += oggvorbis.o
59 EXTRALIBS += -lvorbis -lvorbisenc
60 endif
61
62 ifeq ($(TARGET_GPROF),yes)
63 CFLAGS+=-p
64 LDFLAGS+=-p
65 endif
66
67 # i386 mmx specific stuff
68 ifeq ($(TARGET_MMX),yes)
69 OBJS += i386/fdct_mmx.o i386/cputest.o \
70 i386/dsputil_mmx.o i386/mpegvideo_mmx.o \
71 i386/idct_mmx.o i386/motion_est_mmx.o \
72 i386/simple_idct_mmx.o i386/fft_sse.o
73 ifdef TARGET_BUILTIN_VECTOR
74 i386/fft_sse.o: CFLAGS+= -msse
75 endif
76 endif
77
78 # armv4l specific stuff
79 ifeq ($(TARGET_ARCH_ARMV4L),yes)
80 ASM_OBJS += armv4l/jrevdct_arm.o
81 OBJS += armv4l/dsputil_arm.o armv4l/mpegvideo_arm.o
82 endif
83
84 # sun mediaLib specific stuff
85 # currently only works when libavcodec is used in mplayer
86 ifeq ($(HAVE_MLIB),yes)
87 OBJS += mlib/dsputil_mlib.o
88 CFLAGS += $(MLIB_INC)
89 endif
90
91 # alpha specific stuff
92 ifeq ($(TARGET_ARCH_ALPHA),yes)
93 OBJS += alpha/dsputil_alpha.o alpha/mpegvideo_alpha.o \
94 alpha/simple_idct_alpha.o alpha/motion_est_alpha.o
95 ASM_OBJS += alpha/dsputil_alpha_asm.o alpha/motion_est_mvi_asm.o
96 CFLAGS += -fforce-addr -freduce-all-givs
97 endif
98
99 ifeq ($(TARGET_ARCH_POWERPC),yes)
100 OBJS += ppc/dsputil_ppc.o ppc/mpegvideo_ppc.o
101 endif
102
103 ifeq ($(TARGET_MMI),yes)
104 OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
105 endif
106
107 ifeq ($(TARGET_ALTIVEC),yes)
108 ifeq ($(TARGET_OS),Darwin)
109 CFLAGS += -faltivec
110 else
111 CFLAGS += -maltivec -mabi=altivec
112 endif
113 OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \
114 ppc/fft_altivec.o ppc/gmc_altivec.o
115 endif
116
117 SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S)
118 OBJS := $(OBJS) $(ASM_OBJS)
119
120 LIB= $(LIBPREF)avcodec$(LIBSUF)
121 ifeq ($(BUILD_SHARED),yes)
122 SLIB= $(SLIBPREF)avcodec$(SLIBSUF)
123 endif
124 TESTS= imgresample-test dct-test motion-test fft-test
125
126 all: $(LIB) $(SLIB)
127
128 tests: apiexample cpuid_test $(TESTS)
129
130 $(LIB): $(OBJS)
131 rm -f $@
132 $(AR) rc $@ $(OBJS)
133 $(RANLIB) $@
134
135 $(SLIB): $(OBJS)
136 $(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS)
137
138 dsputil.o: dsputil.c dsputil.h
139
140 libpostproc/libpostproc.a:
141 $(MAKE) -C libpostproc
142
143 %.o: %.c
144 $(CC) $(CFLAGS) -c -o $@ $<
145
146 %.o: %.S
147 $(CC) $(CFLAGS) -c -o $@ $<
148
149 # motion_est_alpha uses the MVI extension, which is not available with
150 # -mcpu=ev4 (default) or ev5/ev56. Thus, force -mcpu=pca56 in those
151 # cases.
152 ifeq ($(TARGET_ARCH_ALPHA),yes)
153 alpha/motion_est_alpha.o: alpha/motion_est_alpha.c
154 cpu=`echo "$(CFLAGS)" | sed -n 's,.*-mcpu=\([a-zA-Z0-9]*\).*,\1,p'`; \
155 case x"$$cpu" in x|xev[45]*) newcpu=pca56;; *) newcpu=$$cpu;; esac; \
156 echo $(CC) $(CFLAGS) -mcpu=$$newcpu -c -o $@ $<;\
157 $(CC) $(CFLAGS) -mcpu=$$newcpu -c -o $@ $<
158 endif
159
160 depend: $(SRCS)
161 $(CC) -MM $(CFLAGS) $^ 1>.depend
162
163 dep: depend
164
165 clean:
166 rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so i386/*.o i386/*~ \
167 armv4l/*.o armv4l/*~ \
168 mlib/*.o mlib/*~ \
169 alpha/*.o alpha/*~ \
170 ppc/*.o ppc/*~ \
171 ps2/*.o ps2/*~ \
172 liba52/*.o liba52/*~ \
173 apiexample $(TESTS)
174 $(MAKE) -C libpostproc clean
175
176 distclean: clean
177 rm -f Makefile.bak .depend
178
179 # api example program
180 apiexample: apiexample.c $(LIB)
181 $(CC) $(CFLAGS) -o $@ $< $(LIB) $(EXTRALIBS) -lm
182
183 # cpuid test
184 cpuid_test: i386/cputest.c
185 $(CC) $(CFLAGS) -D__TEST__ -o $@ $<
186
187 # testing progs
188
189 imgresample-test: imgresample.c
190 $(CC) $(CFLAGS) -DTEST -o $@ $^ -lm
191
192 dct-test: dct-test.o fdctref.o $(LIB)
193 $(CC) -o $@ $^ -lm
194
195 motion-test: motion_test.o $(LIB)
196 $(CC) -o $@ $^ -lm
197
198 fft-test: fft-test.o $(LIB)
199 $(CC) -o $@ $^ -lm
200
201 install: all
202 ifeq ($(BUILD_SHARED),yes)
203 install -d $(prefix)/lib
204 install -s -m 755 $(SLIB) $(prefix)/lib/libavcodec-$(VERSION).so
205 ln -sf libavcodec-$(VERSION).so $(prefix)/lib/libavcodec.so
206 ldconfig || true
207 mkdir -p $(prefix)/include/ffmpeg
208 install -m 644 $(VPATH)/avcodec.h $(prefix)/include/ffmpeg/avcodec.h
209 install -m 644 $(VPATH)/common.h $(prefix)/include/ffmpeg/common.h
210 endif
211
212 installlib: all
213 install -m 644 $(LIB) $(prefix)/lib
214 mkdir -p $(prefix)/include/ffmpeg
215 install -m 644 $(SRC_PATH)/libavcodec/avcodec.h $(SRC_PATH)/libavcodec/common.h \
216 $(prefix)/include/ffmpeg
217
218 #
219 # include dependency files if they exist
220 #
221 ifneq ($(wildcard .depend),)
222 include .depend
223 endif