Generate pkg-config files in each library subdirectory so that they do
[libav.git] / Makefile
CommitLineData
980fc7b8 1include config.mak
85f07f22 2
a426bbfc
MR
3SRC_DIR = $(SRC_PATH_BARE)
4
de2f77d8 5vpath %.texi $(SRC_PATH_BARE)
dd9ca370 6
0cb8579a
MR
7PROGS-$(CONFIG_FFMPEG) += ffmpeg
8PROGS-$(CONFIG_FFPLAY) += ffplay
9PROGS-$(CONFIG_FFSERVER) += ffserver
01310af2 10
bb8fe69a
DB
11PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
12PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
caec74dd 13OBJS = $(addsuffix .o, $(PROGS-yes)) cmdutils.o
bb8fe69a 14MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
85f07f22 15
bb8fe69a
DB
16BASENAMES = ffmpeg ffplay ffserver
17ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
18ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
19ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
6b991cb2 20
b8fcb619
MR
21FFLIBS-$(CONFIG_AVFILTER) += avfilter
22FFLIBS-$(CONFIG_POSTPROC) += postproc
23FFLIBS-$(CONFIG_SWSCALE) += swscale
43527e3e 24
b8fcb619 25FFLIBS := avdevice avformat avcodec avutil
f02be79d 26
71c61f62
MR
27include common.mak
28
29FF_LDFLAGS := $(FFLDFLAGS)
30FF_EXTRALIBS := $(FFEXTRALIBS)
791a3fc8 31FF_DEP_LIBS := $(DEP_LIBS)
71c61f62 32
7d6ac9a3
MR
33ALL_TARGETS-$(CONFIG_VHOOK) += videohook
34ALL_TARGETS-$(BUILD_DOC) += documentation
35
36INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
1217916b
DB
37ifneq ($(PROGS),)
38INSTALL_TARGETS-yes += install-progs
282db5fd 39INSTALL_TARGETS-$(BUILD_DOC) += install-man
1217916b 40endif
dfd10838 41INSTALL_PROGS_TARGETS-$(BUILD_SHARED) = install-libs
dd9f3d97 42
791a3fc8 43all: $(FF_DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
27217159 44
473a88ca 45$(PROGS): %$(EXESUF): %_g$(EXESUF)
27217159
DB
46 cp -p $< $@
47 $(STRIP) $@
48
54381d75 49SUBDIR_VARS := OBJS ASM_OBJS CPP_OBJS FFLIBS CLEANFILES DIRS TESTS
9bcc2883 50
71c61f62
MR
51define RESET
52$(1) :=
53$(1)-yes :=
54endef
7716f7ff 55
71c61f62
MR
56define DOSUBDIR
57$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
58SUBDIR := $(1)/
59include $(1)/Makefile
60endef
61
62$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
b8fcb619 63
71c61f62
MR
64ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
65ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
85f07f22 66
791a3fc8 67%_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
71c61f62 68 $(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
01310af2 69
a4da50e1
MR
70SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
71ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
72version.h: $(SVN_ENTRIES)
73endif
74
f1cc88a5 75version.h:
997baf01 76 $(SRC_PATH)/version.sh $(SRC_PATH)
f1cc88a5 77
791a3fc8 78output_example$(EXESUF): output_example.o $(FF_DEP_LIBS)
71c61f62 79 $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
8de65d4f 80
1521c500 81tools/%$(EXESUF): tools/%.c
71c61f62 82 $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
6da7cc81 83
d1300235 84ffplay.o ffplay.d: CFLAGS += $(SDL_CFLAGS)
496cfa3c 85
465d9b1f
MR
86VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
87
88BASEHOOKS = fish null watermark
89ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
90ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
91
92HOOKS-$(HAVE_FORK) += ppm
93HOOKS-$(HAVE_IMLIB2) += imlib2
94HOOKS-$(HAVE_FREETYPE2) += drawtext
95
96HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
97
98VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
99LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
100
101VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
102LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
103
104VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
105
caec74dd 106vhook/%.o vhook/%.d: CFLAGS:=$(VHOOKCFLAGS)
465d9b1f 107
bab785a5 108# vhooks compile fine without libav*, but need them nonetheless.
791a3fc8 109videohook: $(FF_DEP_LIBS) $(HOOKS)
ed5614eb 110
9987769a 111$(eval VHOOKSHFLAGS=$(VHOOKSHFLAGS))
ed5614eb 112vhook/%$(SLIBSUF): vhook/%.o
3b26ee47 113 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
ed5614eb 114
caec74dd
MR
115VHOOK_DEPS = $(HOOKS:$(SLIBSUF)=.d)
116depend dep: $(VHOOK_DEPS)
465d9b1f 117
e9b19db8 118documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
d0e1cd3d
DB
119 ffplay-doc.html general.html hooks.html \
120 $(ALLMANPAGES))
e9b19db8
DB
121
122doc/%.html: doc/%.texi
123 texi2html -monolithic -number $<
124 mv $(@F) $@
125
126doc/%.pod: doc/%-doc.texi
127 doc/texi2pod.pl $< $@
128
129doc/%.1: doc/%.pod
130 pod2man --section=1 --center=" " --release=" " $< > $@
146ea952 131
a7319cc2
DB
132install: $(INSTALL_TARGETS-yes)
133
c1ac39b3 134install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
22a324da
DB
135 install -d "$(BINDIR)"
136 install -c -m 755 $(PROGS) "$(BINDIR)"
85f07f22 137
d05e360c 138install-man: $(MANPAGES)
22a324da
DB
139 install -d "$(MANDIR)/man1"
140 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
23a65308 141
ed5614eb 142install-vhook: videohook
22a324da
DB
143 install -d "$(SHLIBDIR)/vhook"
144 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
142fc6b9 145
7716f7ff 146uninstall: uninstall-progs uninstall-man uninstall-vhook
f9edb717 147
f9edb717 148uninstall-progs:
1c2211bd 149 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
f9edb717 150
f9edb717 151uninstall-man:
1c2211bd 152 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
f9edb717
DB
153
154uninstall-vhook:
1c2211bd 155 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
22a324da 156 -rmdir "$(SHLIBDIR)/vhook/"
f9edb717 157
7716f7ff 158clean::
1eacdcc6 159 rm -f $(ALLPROGS) $(ALLPROGS_G) output_example$(EXESUF)
e9b19db8 160 rm -f doc/*.html doc/*.pod doc/*.1
4fbd52f0
DB
161 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
162 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
2b258bba 163 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
ed5614eb 164 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
142fc6b9 165
7716f7ff 166distclean::
25cd5cb3 167 rm -f version.h config.* vhook/*.d
85f07f22 168
dd9ca370
FB
169# regression tests
170
4fbd52f0 171fulltest test: codectest libavtest seektest
4fbd52f0
DB
172
173FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
174FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
175LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
176ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
177SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
178
4383ed5c
MR
179CODEC_TESTS = $(addprefix regtest-, \
180 mpeg \
181 mpeg2 \
182 mpeg2thread \
183 msmpeg4v2 \
184 msmpeg4 \
185 wmv1 \
186 wmv2 \
187 h261 \
188 h263 \
189 h263p \
190 mpeg4 \
191 huffyuv \
192 rc \
193 mpeg4adv \
194 mpeg4thread \
4383ed5c
MR
195 error \
196 mpeg4nr \
197 mpeg1b \
198 mjpeg \
199 ljpeg \
200 jpegls \
201 rv10 \
202 rv20 \
203 asv1 \
204 asv2 \
205 flv \
206 ffv1 \
207 snow \
208 snowll \
209 dv \
210 dv50 \
211 svq1 \
212 flashsv \
213 mp2 \
214 ac3 \
215 g726 \
216 adpcm_ima_wav \
9dc92a38 217 adpcm_ima_qt \
4383ed5c
MR
218 adpcm_ms \
219 adpcm_yam \
220 adpcm_swf \
221 flac \
222 wma \
223 )
224
2009721d
MR
225LAVF_TESTS = $(addprefix regtest-, \
226 avi \
227 asf \
228 rm \
229 mpg \
230 ts \
231 swf \
232 ffm \
233 flv_fmt \
234 mov \
235 dv_fmt \
236 gxf \
237 nut \
238 mkv \
239 pbmpipe \
240 pgmpipe \
241 ppmpipe \
242 gif \
243 yuv4mpeg \
244 pgm \
245 ppm \
246 bmp \
247 tga \
248 tiff \
249 sgi \
250 jpg \
251 wav \
252 alaw \
253 mulaw \
254 au \
255 mmf \
256 aiff \
257 voc \
258 ogg \
259 pixfmt \
260 )
4383ed5c
MR
261
262REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
263
264CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
265CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
266
267LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
268
269LAVF_REG = tests/data/lavf.regression
270ROTOZOOM_REG = tests/data/rotozoom.regression
271VSYNTH_REG = tests/data/vsynth.regression
272
273codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
4411cb11
MR
274 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
275 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
4383ed5c
MR
276
277libavtest: $(LAVF_REG)
278 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
279
280$(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
281 cat $^ > $@
282
283$(LAVF_REG): $(LAVF_REGFILES)
284$(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
285$(VSYNTH_REG): $(CODEC_VSYNTH)
286
287$(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
288
289$(LAVF_REGFILES): $(LAVF_TESTS)
290
291$(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
292
293regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
294
295$(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
2009721d
MR
296 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
297 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
4383ed5c
MR
298
299$(LAVF_TESTS):
2009721d 300 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
4383ed5c
MR
301
302seektest: codectest libavtest tests/seek_test$(EXESUF)
303 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
304
60598b2f 305servertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
4fbd52f0
DB
306 @echo
307 @echo "Unfortunately ffserver is broken and therefore its regression"
308 @echo "test fails randomly. Treat the results accordingly."
309 @echo
310 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
311
13ca50f3 312ifeq ($(CONFIG_SWSCALE),yes)
60598b2f 313servertest codectest $(CODEC_TESTS) libavtest: swscale_error
4fbd52f0
DB
314swscale_error:
315 @echo
13ca50f3 316 @echo "This regression test is incompatible with --enable-swscale."
4fbd52f0
DB
317 @echo
318 @exit 1
319endif
320
321tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
322 mkdir -p tests/vsynth1
323 $(BUILD_ROOT)/$< 'tests/vsynth1/'
324
325tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
326 mkdir -p tests/vsynth2
327 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
328
329tests/asynth1.sw: tests/audiogen$(EXESUF)
330 $(BUILD_ROOT)/$< $@
331
332%$(EXESUF): %.c
71c61f62 333 $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $<
4fbd52f0 334
791a3fc8 335tests/seek_test$(EXESUF): tests/seek_test.c $(FF_DEP_LIBS)
71c61f62 336 $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $< $(FF_EXTRALIBS)
4fbd52f0 337
dd9ca370 338
936d4891 339.PHONY: lib videohook documentation *test regtest-* swscale-error
cf2818b0 340
caec74dd 341-include $(VHOOK_DEPS)