Makefile 5.02 KB
Newer Older
1 2
#
# libavcodec Makefile
Fabrice Bellard's avatar
Fabrice Bellard committed
3
# (c) 2000, 2001, 2002 Fabrice Bellard
4
#
5 6
include ../config.mak

7 8
VPATH=$(SRC_PATH)/libavcodec

Fabrice Bellard's avatar
Fabrice Bellard committed
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
Fabrice Bellard's avatar
Fabrice Bellard committed
11 12
LDFLAGS= -g

13
OBJS= common.o utils.o mem.o allcodecs.o \
Michael Niedermayer's avatar
Michael Niedermayer committed
14
      mpegvideo.o jrevdct.o jfdctfst.o jfdctint.o\
15
      mpegaudio.o ac3enc.o mjpeg.o resample.o dsputil.o \
Michael Niedermayer's avatar
Michael Niedermayer committed
16 17
      motion_est.o imgconvert.o imgresample.o \
      mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \
18
      ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \
Zdenek Kabelac's avatar
Zdenek Kabelac committed
19
      fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o
20
ASM_OBJS=
Fabrice Bellard's avatar
Fabrice Bellard committed
21

Michael Niedermayer's avatar
Michael Niedermayer committed
22 23 24 25 26
# codecs which are patented in some non free countries like the us
ifeq ($(CONFIG_RISKY),yes)
OBJS+= h263.o msmpeg4.o h263dec.o svq1.o rv10.o wmadec.o
endif

Zdenek Kabelac's avatar
Zdenek Kabelac committed
27
# currently using liba52 for ac3 decoding
28
ifeq ($(CONFIG_AC3),yes)
Zdenek Kabelac's avatar
Zdenek Kabelac committed
29 30 31
OBJS+= a52dec.o

# using builtin liba52 or runtime linked liba52.so.0
Fabrice Bellard's avatar
Fabrice Bellard committed
32
ifneq ($(CONFIG_A52BIN),yes)
Zdenek Kabelac's avatar
Zdenek Kabelac committed
33 34
OBJS+= liba52/bit_allocate.o liba52/bitstream.o liba52/downmix.o \
	liba52/imdct.o  liba52/parse.o
35
endif
Fabrice Bellard's avatar
Fabrice Bellard committed
36
endif
Fabrice Bellard's avatar
Fabrice Bellard committed
37

38 39
ifeq ($(CONFIG_MP3LAME),yes)
OBJS += mp3lameaudio.o
Zdenek Kabelac's avatar
Zdenek Kabelac committed
40
EXTRALIBS += -lmp3lame
41 42
endif

43 44 45 46 47
ifeq ($(CONFIG_VORBIS),yes)
OBJS += oggvorbis.o
EXTRALIBS += -lvorbis -lvorbisenc
endif

48 49 50 51 52
ifeq ($(TARGET_GPROF),yes)
CFLAGS+=-p
LDFLAGS+=-p
endif

Fabrice Bellard's avatar
Fabrice Bellard committed
53
# i386 mmx specific stuff
54
ifeq ($(TARGET_MMX),yes)
Fabrice Bellard's avatar
Fabrice Bellard committed
55
OBJS += i386/fdct_mmx.o i386/cputest.o \
Fabrice Bellard's avatar
Fabrice Bellard committed
56
	i386/dsputil_mmx.o i386/mpegvideo_mmx.o \
Zdenek Kabelac's avatar
Zdenek Kabelac committed
57
	i386/idct_mmx.o i386/motion_est_mmx.o \
58
	i386/simple_idct_mmx.o i386/fft_sse.o
59 60 61
ifdef TARGET_BUILTIN_VECTOR
i386/fft_sse.o: CFLAGS+= -msse
endif
Fabrice Bellard's avatar
Fabrice Bellard committed
62 63
endif

Fabrice Bellard's avatar
Fabrice Bellard committed
64 65 66
# armv4l specific stuff
ifeq ($(TARGET_ARCH_ARMV4L),yes)
ASM_OBJS += armv4l/jrevdct_arm.o
67
OBJS += armv4l/dsputil_arm.o armv4l/mpegvideo_arm.o
Fabrice Bellard's avatar
Fabrice Bellard committed
68 69
endif

Fabrice Bellard's avatar
Fabrice Bellard committed
70 71 72 73 74 75 76
# sun mediaLib specific stuff
# currently only works when libavcodec is used in mplayer
ifeq ($(HAVE_MLIB),yes)
OBJS += mlib/dsputil_mlib.o
CFLAGS += $(MLIB_INC)
endif

77 78
# alpha specific stuff
ifeq ($(TARGET_ARCH_ALPHA),yes)
79 80
OBJS += alpha/dsputil_alpha.o alpha/mpegvideo_alpha.o \
	alpha/simple_idct_alpha.o alpha/motion_est_alpha.o
81
ASM_OBJS += alpha/dsputil_alpha_asm.o alpha/motion_est_mvi_asm.o
82
CFLAGS += -fforce-addr -freduce-all-givs
83 84
endif

85
ifeq ($(TARGET_ARCH_POWERPC),yes)
86
OBJS += ppc/dsputil_ppc.o ppc/mpegvideo_ppc.o
87 88
endif

89
ifeq ($(TARGET_MMI),yes)
90
OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
91 92
endif

93
ifeq ($(TARGET_ALTIVEC),yes)
94
ifeq ($(TARGET_OS),Darwin)
95
CFLAGS += -faltivec
96 97 98
else
CFLAGS += -maltivec -mabi=altivec
endif
99
OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \
100
        ppc/fft_altivec.o ppc/gmc_altivec.o
101 102
endif

103
SRCS := $(OBJS:.o=.c) $(ASM_OBJS:.o=.S)
Fabrice Bellard's avatar
Fabrice Bellard committed
104
OBJS := $(OBJS) $(ASM_OBJS)
105

106
LIB= $(LIBPREF)avcodec$(LIBSUF)
Nick Kurshev's avatar
Nick Kurshev committed
107
ifeq ($(BUILD_SHARED),yes)
108
SLIB= $(SLIBPREF)avcodec$(SLIBSUF)
Nick Kurshev's avatar
Nick Kurshev committed
109
endif
110
TESTS= imgresample-test dct-test motion-test fft-test
Fabrice Bellard's avatar
Fabrice Bellard committed
111

Nick Kurshev's avatar
Nick Kurshev committed
112
all: $(LIB) $(SLIB)
Fabrice Bellard's avatar
Fabrice Bellard committed
113

Nick Kurshev's avatar
Nick Kurshev committed
114
tests: apiexample cpuid_test $(TESTS)
Fabrice Bellard's avatar
Fabrice Bellard committed
115

116
$(LIB): $(OBJS)
Fabrice Bellard's avatar
Fabrice Bellard committed
117
	rm -f $@
Michael Niedermayer's avatar
Michael Niedermayer committed
118
	$(AR) rc $@ $(OBJS)
119
ifneq ($(CONFIG_OS2),yes)
Michael Niedermayer's avatar
Michael Niedermayer committed
120
	$(RANLIB) $@
121
endif
Fabrice Bellard's avatar
Fabrice Bellard committed
122

123
$(SLIB): $(OBJS)
124
	$(CC) $(SHFLAGS) -o $@ $(OBJS) $(EXTRALIBS)
Fabrice Bellard's avatar
Fabrice Bellard committed
125 126 127 128 129 130

dsputil.o: dsputil.c dsputil.h

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $< 

Fabrice Bellard's avatar
Fabrice Bellard committed
131 132 133
%.o: %.S
	$(CC) $(CFLAGS) -c -o $@ $<

134 135 136 137 138 139 140 141 142 143 144
# motion_est_alpha uses the MVI extension, which is not available with
# -mcpu=ev4 (default) or ev5/ev56. Thus, force -mcpu=pca56 in those
# cases.
ifeq ($(TARGET_ARCH_ALPHA),yes)
alpha/motion_est_alpha.o: alpha/motion_est_alpha.c
	cpu=`echo "$(CFLAGS)" | sed -n 's,.*-mcpu=\([a-zA-Z0-9]*\).*,\1,p'`; \
	case x"$$cpu" in x|xev[45]*) newcpu=pca56;; *) newcpu=$$cpu;; esac; \
	echo $(CC) $(CFLAGS) -mcpu=$$newcpu -c -o $@ $<;\
	$(CC) $(CFLAGS) -mcpu=$$newcpu -c -o $@ $<
endif

145
depend: $(SRCS)
146
	$(CC) -MM $(CFLAGS) $^ 1>.depend
147

148 149
dep:	depend

Fabrice Bellard's avatar
Fabrice Bellard committed
150
clean: 
151
	rm -f *.o *.d *~ .depend $(LIB) $(SLIB) *.so i386/*.o i386/*~ \
Fabrice Bellard's avatar
Fabrice Bellard committed
152
	   armv4l/*.o armv4l/*~ \
Fabrice Bellard's avatar
Fabrice Bellard committed
153
	   mlib/*.o mlib/*~ \
154
	   alpha/*.o alpha/*~ \
155
	   ppc/*.o ppc/*~ \
156
	   ps2/*.o ps2/*~ \
Zdenek Kabelac's avatar
Zdenek Kabelac committed
157 158
	   liba52/*.o liba52/*~ \
	   apiexample $(TESTS)
Fabrice Bellard's avatar
Fabrice Bellard committed
159

160
distclean: clean
161 162
	rm -f Makefile.bak .depend

Fabrice Bellard's avatar
Fabrice Bellard committed
163 164
# api example program
apiexample: apiexample.c $(LIB)
165
	$(CC) $(CFLAGS) -o $@ $< $(LIB) $(EXTRALIBS) -lm
Fabrice Bellard's avatar
Fabrice Bellard committed
166

Nick Kurshev's avatar
Nick Kurshev committed
167 168 169 170
# cpuid test
cpuid_test: i386/cputest.c
	$(CC) $(CFLAGS) -D__TEST__ -o $@ $<

Fabrice Bellard's avatar
Fabrice Bellard committed
171 172 173
# testing progs

imgresample-test: imgresample.c
Michael Niedermayer's avatar
Michael Niedermayer committed
174
	$(CC) $(CFLAGS) -DTEST -o $@ $^ -lm
Fabrice Bellard's avatar
Fabrice Bellard committed
175

Fabrice Bellard's avatar
Fabrice Bellard committed
176
dct-test: dct-test.o fdctref.o $(LIB)
177
	$(CC) -o $@ $^ -lm
178

Fabrice Bellard's avatar
Fabrice Bellard committed
179
motion-test: motion_test.o $(LIB)
Michael Niedermayer's avatar
Michael Niedermayer committed
180
	$(CC) -o $@ $^ -lm
Fabrice Bellard's avatar
Fabrice Bellard committed
181

182
fft-test: fft-test.o $(LIB)
183 184
	$(CC) -o $@ $^ -lm

Nick Kurshev's avatar
Nick Kurshev committed
185 186
install: all
ifeq ($(BUILD_SHARED),yes)
187
	install -d $(prefix)/lib
Fabrice Bellard's avatar
Fabrice Bellard committed
188
	install -s -m 755 $(SLIB) $(prefix)/lib/libavcodec-$(VERSION).so
189 190
	ln -sf libavcodec-$(VERSION).so $(prefix)/lib/libavcodec.so
	ldconfig || true
Fabrice Bellard's avatar
Fabrice Bellard committed
191
	mkdir -p $(prefix)/include/ffmpeg
192 193
	install -m 644 $(VPATH)/avcodec.h $(prefix)/include/ffmpeg/avcodec.h
	install -m 644 $(VPATH)/common.h $(prefix)/include/ffmpeg/common.h
Nick Kurshev's avatar
Nick Kurshev committed
194
endif
195 196 197 198 199 200 201

installlib: all
	install -m 644 $(LIB) $(prefix)/lib
	mkdir -p $(prefix)/include/ffmpeg
	install -m 644 $(SRC_PATH)/libavcodec/avcodec.h $(SRC_PATH)/libavcodec/common.h \
                $(prefix)/include/ffmpeg

202 203 204 205 206 207
#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif