3 # (c) 2000-2004 Fabrice Bellard
7 SRC_DIR = $(SRC_PATH_BARE)
9 vpath %.c $(SRC_PATH_BARE)
10 vpath %.h $(SRC_PATH_BARE)
11 vpath %.texi $(SRC_PATH_BARE)
13 CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
14 -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libswscale \
15 -I$(SRC_PATH)/libavdevice -I$(SRC_PATH)/libavfilter \
16 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -DHAVE_AV_CONFIG_H
19 PROGS-$(CONFIG_FFMPEG) += ffmpeg
20 PROGS-$(CONFIG_FFPLAY) += ffplay
21 PROGS-$(CONFIG_FFSERVER) += ffserver
23 PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
24 PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
25 SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
26 MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
28 BASENAMES = ffmpeg ffplay ffserver
29 ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
30 ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
31 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
33 ifeq ($(BUILD_SHARED),yes)
34 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
36 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
39 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
40 ALL_TARGETS-$(BUILD_DOC) += documentation
42 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
44 INSTALL_TARGETS-yes += install-progs
45 INSTALL_TARGETS-$(BUILD_DOC) += install-man
48 main: lib $(PROGS_G) $(PROGS) $(ALL_TARGETS-yes)
50 %$(EXESUF): %_g$(EXESUF)
55 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
57 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
59 BASEHOOKS = fish null watermark
60 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
61 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
63 HOOKS-$(HAVE_FORK) += ppm
64 HOOKS-$(HAVE_IMLIB2) += imlib2
65 HOOKS-$(HAVE_FREETYPE2) += drawtext
67 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
69 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
70 LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
72 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
73 LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
75 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
77 LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
78 EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
80 ifeq ($(CONFIG_SWSCALE),yes)
81 LDFLAGS+=-L$(BUILD_ROOT)/libswscale
82 EXTRALIBS+=-lswscale$(BUILDSUF)
85 ifeq ($(CONFIG_AVFILTER),yes)
86 LDFLAGS+=-L$(BUILD_ROOT)/libavfilter
87 EXTRALIBS := -lavfilter$(BUILDSUF) $(EXTRALIBS)
94 $(MAKE) -C libavutil all
95 $(MAKE) -C libavcodec all
96 $(MAKE) -C libavformat all
97 $(MAKE) -C libavdevice all
98 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
99 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale all
100 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
102 ffplay_g$(EXESUF): EXTRALIBS += $(SDL_LIBS)
103 ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
105 %_g$(EXESUF): %.o cmdutils.o .libs
106 $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
108 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
109 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
110 version.h: $(SVN_ENTRIES)
114 $(SRC_PATH)/version.sh $(SRC_PATH)
116 output_example$(EXESUF): output_example.o .libs
117 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
119 tools/%$(EXESUF): tools/%.c
120 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
122 ffplay.o .depend: CFLAGS += $(SDL_CFLAGS)
124 ffmpeg.o ffplay.o ffserver.o: version.h
126 # vhooks compile fine without libav*, but need them nonetheless.
127 videohook: .libs $(HOOKS)
129 vhook/%$(SLIBSUF): vhook/%.o
130 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
133 $(CC) $(CFLAGS) -c -o $@ $<
135 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
136 ffplay-doc.html general.html hooks.html \
139 doc/%.html: doc/%.texi
140 texi2html -monolithic -number $<
143 doc/%.pod: doc/%-doc.texi
144 doc/texi2pod.pl $< $@
147 pod2man --section=1 --center=" " --release=" " $< > $@
149 install: install-libs install-headers $(INSTALL_TARGETS-yes)
151 ifeq ($(BUILD_SHARED),yes)
152 install-progs: install-libs
154 install-progs: $(PROGS)
155 install -d "$(BINDIR)"
156 install -c -m 755 $(PROGS) "$(BINDIR)"
159 install -d "$(MANDIR)/man1"
160 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
162 install-vhook: videohook
163 install -d "$(SHLIBDIR)/vhook"
164 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
167 $(MAKE) -C libavutil install-libs
168 $(MAKE) -C libavcodec install-libs
169 $(MAKE) -C libavformat install-libs
170 $(MAKE) -C libavdevice install-libs
171 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
172 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale install-libs
173 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
176 $(MAKE) -C libavutil install-headers
177 $(MAKE) -C libavcodec install-headers
178 $(MAKE) -C libavformat install-headers
179 $(MAKE) -C libavdevice install-headers
180 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
181 $(MAKE) -C libswscale install-headers
182 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
184 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
187 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
190 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
193 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
194 -rmdir "$(SHLIBDIR)/vhook/"
197 $(MAKE) -C libavutil uninstall-libs
198 $(MAKE) -C libavcodec uninstall-libs
199 $(MAKE) -C libavformat uninstall-libs
200 $(MAKE) -C libavdevice uninstall-libs
201 $(MAKE) -C libpostproc uninstall-libs
202 $(MAKE) -C libswscale uninstall-libs
203 $(MAKE) -C libavfilter uninstall-libs
206 $(MAKE) -C libavutil uninstall-headers
207 $(MAKE) -C libavcodec uninstall-headers
208 $(MAKE) -C libavformat uninstall-headers
209 $(MAKE) -C libavdevice uninstall-headers
210 $(MAKE) -C libpostproc uninstall-headers
211 $(MAKE) -C libswscale uninstall-headers
212 $(MAKE) -C libavfilter uninstall-headers
215 depend dep: .depend .vhookdep
216 $(MAKE) -C libavutil depend
217 $(MAKE) -C libavcodec depend
218 $(MAKE) -C libavformat depend
219 $(MAKE) -C libavdevice depend
220 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
221 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale depend
222 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
224 .depend: $(SRCS) version.h
227 .vhookdep: $(ALLHOOKS_SRCS) version.h
228 $(VHOOK_DEPEND_CMD) > $@
236 $(MAKE) -C libavutil clean
237 $(MAKE) -C libavcodec clean
238 $(MAKE) -C libavformat clean
239 $(MAKE) -C libavdevice clean
240 $(MAKE) -C libpostproc clean
241 $(MAKE) -C libswscale clean
242 $(MAKE) -C libavfilter clean
243 rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
244 output_example$(EXESUF)
245 rm -f doc/*.html doc/*.pod doc/*.1
246 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
247 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
248 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
249 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
252 $(MAKE) -C libavutil distclean
253 $(MAKE) -C libavcodec distclean
254 $(MAKE) -C libavformat distclean
255 $(MAKE) -C libavdevice distclean
256 $(MAKE) -C libpostproc distclean
257 $(MAKE) -C libswscale distclean
258 $(MAKE) -C libavfilter distclean
259 rm -f .depend .vhookdep version.h config.* *.pc
262 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
266 fulltest test: codectest libavtest seektest
268 FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
269 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
270 LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
271 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
272 SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
274 CODEC_TESTS = $(addprefix regtest-, \
320 LAVF_TESTS = $(addprefix regtest-, \
357 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
359 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
360 CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
362 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
364 LAVF_REG = tests/data/lavf.regression
365 ROTOZOOM_REG = tests/data/rotozoom.regression
366 VSYNTH_REG = tests/data/vsynth.regression
368 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
369 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
370 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
372 libavtest: $(LAVF_REG)
373 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
375 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
378 $(LAVF_REG): $(LAVF_REGFILES)
379 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
380 $(VSYNTH_REG): $(CODEC_VSYNTH)
382 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
384 $(LAVF_REGFILES): $(LAVF_TESTS)
386 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
388 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
390 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
391 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
392 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
395 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
397 seektest: codectest libavtest tests/seek_test$(EXESUF)
398 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
400 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
402 @echo "Unfortunately ffserver is broken and therefore its regression"
403 @echo "test fails randomly. Treat the results accordingly."
405 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
407 ifeq ($(CONFIG_SWSCALE),yes)
408 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
411 @echo "This regression test is incompatible with --enable-swscale."
416 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
417 mkdir -p tests/vsynth1
418 $(BUILD_ROOT)/$< 'tests/vsynth1/'
420 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
421 mkdir -p tests/vsynth2
422 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
424 tests/asynth1.sw: tests/audiogen$(EXESUF)
428 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
430 tests/seek_test$(EXESUF): tests/seek_test.c .libs
431 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
434 .PHONY: all lib videohook documentation install* uninstall*
435 .PHONY: dep depend clean distclean TAGS
436 .PHONY: codectest libavtest seektest test-server fulltest test
437 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error