3 # (c) 2000-2004 Fabrice Bellard
7 SRC_DIR = $(SRC_PATH_BARE)
9 vpath %.texi $(SRC_PATH_BARE)
11 PROGS-$(CONFIG_FFMPEG) += ffmpeg
12 PROGS-$(CONFIG_FFPLAY) += ffplay
13 PROGS-$(CONFIG_FFSERVER) += ffserver
15 PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
16 PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
17 OBJS = $(addsuffix .o, $(PROGS-yes)) cmdutils.o
18 MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
20 BASENAMES = ffmpeg ffplay ffserver
21 ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
22 ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
23 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
25 FFLIBS-$(CONFIG_AVFILTER) += avfilter
26 FFLIBS-$(CONFIG_POSTPROC) += postproc
27 FFLIBS-$(CONFIG_SWSCALE) += swscale
29 FFLIBS := avdevice avformat avcodec avutil
33 FF_LDFLAGS := $(FFLDFLAGS)
34 FF_EXTRALIBS := $(FFEXTRALIBS)
35 FF_DEP_LIBS := $(DEP_LIBS)
37 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
38 ALL_TARGETS-$(BUILD_DOC) += documentation
40 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
42 INSTALL_TARGETS-yes += install-progs
43 INSTALL_TARGETS-$(BUILD_DOC) += install-man
45 INSTALL_PROGS_TARGETS-$(BUILD_SHARED) = install-libs
47 all: $(FF_DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
49 $(PROGS): %$(EXESUF): %_g$(EXESUF)
53 SUBDIR_VARS := OBJS ASM_OBJS CPP_OBJS FFLIBS CLEANFILES
61 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
66 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
68 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
69 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
71 %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
72 $(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
74 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
75 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
76 version.h: $(SVN_ENTRIES)
80 $(SRC_PATH)/version.sh $(SRC_PATH)
82 output_example$(EXESUF): output_example.o $(FF_DEP_LIBS)
83 $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
85 tools/%$(EXESUF): tools/%.c
86 $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
88 ffplay.o: CFLAGS += $(SDL_CFLAGS)
90 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
92 BASEHOOKS = fish null watermark
93 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
94 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
96 HOOKS-$(HAVE_FORK) += ppm
97 HOOKS-$(HAVE_IMLIB2) += imlib2
98 HOOKS-$(HAVE_FREETYPE2) += drawtext
100 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
102 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
103 LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
105 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
106 LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
108 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
110 vhook/%.o vhook/%.d: CFLAGS:=$(VHOOKCFLAGS)
112 # vhooks compile fine without libav*, but need them nonetheless.
113 videohook: $(FF_DEP_LIBS) $(HOOKS)
115 vhook/%$(SLIBSUF): vhook/%.o
116 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
118 VHOOK_DEPS = $(HOOKS:$(SLIBSUF)=.d)
119 depend dep: $(VHOOK_DEPS)
121 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
122 ffplay-doc.html general.html hooks.html \
125 doc/%.html: doc/%.texi
126 texi2html -monolithic -number $<
129 doc/%.pod: doc/%-doc.texi
130 doc/texi2pod.pl $< $@
133 pod2man --section=1 --center=" " --release=" " $< > $@
135 install: $(INSTALL_TARGETS-yes)
137 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
138 install -d "$(BINDIR)"
139 install -c -m 755 $(PROGS) "$(BINDIR)"
141 install-man: $(MANPAGES)
142 install -d "$(MANDIR)/man1"
143 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
145 install-vhook: videohook
146 install -d "$(SHLIBDIR)/vhook"
147 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
149 uninstall: uninstall-progs uninstall-man uninstall-vhook
152 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
155 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
158 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
159 -rmdir "$(SHLIBDIR)/vhook/"
162 rm -f gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
163 output_example$(EXESUF)
164 rm -f doc/*.html doc/*.pod doc/*.1
165 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
166 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
167 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
168 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
171 rm -f version.h config.* *.pc vhook/*.d
175 fulltest test: codectest libavtest seektest
177 FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
178 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
179 LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
180 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
181 SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
183 CODEC_TESTS = $(addprefix regtest-, \
229 LAVF_TESTS = $(addprefix regtest-, \
266 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
268 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
269 CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
271 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
273 LAVF_REG = tests/data/lavf.regression
274 ROTOZOOM_REG = tests/data/rotozoom.regression
275 VSYNTH_REG = tests/data/vsynth.regression
277 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
278 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
279 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
281 libavtest: $(LAVF_REG)
282 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
284 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
287 $(LAVF_REG): $(LAVF_REGFILES)
288 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
289 $(VSYNTH_REG): $(CODEC_VSYNTH)
291 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
293 $(LAVF_REGFILES): $(LAVF_TESTS)
295 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
297 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
299 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
300 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
301 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
304 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
306 seektest: codectest libavtest tests/seek_test$(EXESUF)
307 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
309 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
311 @echo "Unfortunately ffserver is broken and therefore its regression"
312 @echo "test fails randomly. Treat the results accordingly."
314 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
316 ifeq ($(CONFIG_SWSCALE),yes)
317 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
320 @echo "This regression test is incompatible with --enable-swscale."
325 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
326 mkdir -p tests/vsynth1
327 $(BUILD_ROOT)/$< 'tests/vsynth1/'
329 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
330 mkdir -p tests/vsynth2
331 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
333 tests/asynth1.sw: tests/audiogen$(EXESUF)
337 $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $<
339 tests/seek_test$(EXESUF): tests/seek_test.c $(FF_DEP_LIBS)
340 $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $< $(FF_EXTRALIBS)
343 .PHONY: lib videohook documentation TAGS
344 .PHONY: codectest libavtest seektest test-server fulltest test
345 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
347 -include $(VHOOK_DEPS)