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