3 # (c) 2000-2004 Fabrice Bellard
7 vpath %.c $(SRC_PATH_BARE)
8 vpath %.h $(SRC_PATH_BARE)
9 vpath %.texi $(SRC_PATH_BARE)
11 CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
12 -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libswscale \
13 -I$(SRC_PATH)/libavdevice -I$(SRC_PATH)/libavfilter \
14 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -DHAVE_AV_CONFIG_H
17 PROGS-$(CONFIG_FFMPEG) += ffmpeg
18 PROGS-$(CONFIG_FFPLAY) += ffplay
19 PROGS-$(CONFIG_FFSERVER) += ffserver
21 PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
22 PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
23 MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
25 BASENAMES = ffmpeg ffplay ffserver
26 ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
27 ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
28 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
30 ifeq ($(BUILD_SHARED),yes)
31 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
33 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
36 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
37 ALL_TARGETS-$(BUILD_DOC) += documentation
39 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
41 INSTALL_TARGETS-yes += install-progs
42 INSTALL_TARGETS-$(BUILD_DOC) += install-man
45 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
47 BASEHOOKS = fish null watermark
48 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
49 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
51 HOOKS-$(HAVE_FORK) += ppm
52 HOOKS-$(HAVE_IMLIB2) += imlib2
53 HOOKS-$(HAVE_FREETYPE2) += drawtext
55 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
57 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
58 LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
60 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
61 LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
63 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
65 SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
66 LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
67 EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
69 ifeq ($(CONFIG_SWSCALE),yes)
70 LDFLAGS+=-L$(BUILD_ROOT)/libswscale
71 EXTRALIBS+=-lswscale$(BUILDSUF)
74 ifeq ($(CONFIG_AVFILTER),yes)
75 LDFLAGS+=-L$(BUILD_ROOT)/libavfilter
76 EXTRALIBS := -lavfilter$(BUILDSUF) $(EXTRALIBS)
82 all: lib $(PROGS) $(ALL_TARGETS-yes)
85 $(MAKE) -C libavutil all
86 $(MAKE) -C libavcodec all
87 $(MAKE) -C libavformat all
88 $(MAKE) -C libavdevice all
89 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
90 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale all
91 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
93 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
94 $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
96 ffserver_g$(EXESUF): ffserver.o cmdutils.o .libs
97 $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
99 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
100 $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
102 %$(EXESUF): %_g$(EXESUF)
106 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
107 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
108 version.h: $(SVN_ENTRIES)
112 $(SRC_PATH)/version.sh $(SRC_PATH)
114 output_example$(EXESUF): output_example.o .libs
115 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
117 tools/%$(EXESUF): tools/%.c
118 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
120 ffplay.o .depend: CFLAGS += $(SDL_CFLAGS)
122 ffmpeg.o ffplay.o ffserver.o: version.h
124 # vhooks compile fine without libav*, but need them nonetheless.
125 videohook: .libs $(HOOKS)
127 vhook/%$(SLIBSUF): vhook/%.o
128 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
131 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
134 $(CC) $(CFLAGS) -c -o $@ $<
136 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
137 ffplay-doc.html general.html hooks.html \
140 doc/%.html: doc/%.texi
141 texi2html -monolithic -number $<
144 doc/%.pod: doc/%-doc.texi
145 doc/texi2pod.pl $< $@
148 pod2man --section=1 --center=" " --release=" " $< > $@
150 install: install-libs install-headers $(INSTALL_TARGETS-yes)
152 ifeq ($(BUILD_SHARED),yes)
153 install-progs: install-libs
155 install-progs: $(PROGS)
156 install -d "$(BINDIR)"
157 install -c -m 755 $(PROGS) "$(BINDIR)"
160 install -d "$(MANDIR)/man1"
161 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
163 install-vhook: videohook
164 install -d "$(SHLIBDIR)/vhook"
165 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
168 $(MAKE) -C libavutil install-libs
169 $(MAKE) -C libavcodec install-libs
170 $(MAKE) -C libavformat install-libs
171 $(MAKE) -C libavdevice install-libs
172 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
173 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale install-libs
174 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
177 $(MAKE) -C libavutil install-headers
178 $(MAKE) -C libavcodec install-headers
179 $(MAKE) -C libavformat install-headers
180 $(MAKE) -C libavdevice install-headers
181 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
182 $(MAKE) -C libswscale install-headers
183 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
185 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
188 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
191 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
194 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
195 -rmdir "$(SHLIBDIR)/vhook/"
198 $(MAKE) -C libavutil uninstall-libs
199 $(MAKE) -C libavcodec uninstall-libs
200 $(MAKE) -C libavformat uninstall-libs
201 $(MAKE) -C libavdevice uninstall-libs
202 $(MAKE) -C libpostproc uninstall-libs
203 $(MAKE) -C libswscale uninstall-libs
204 $(MAKE) -C libavfilter uninstall-libs
207 $(MAKE) -C libavutil uninstall-headers
208 $(MAKE) -C libavcodec uninstall-headers
209 $(MAKE) -C libavformat uninstall-headers
210 $(MAKE) -C libavdevice uninstall-headers
211 $(MAKE) -C libpostproc uninstall-headers
212 $(MAKE) -C libswscale uninstall-headers
213 $(MAKE) -C libavfilter uninstall-headers
216 depend dep: .depend .vhookdep
217 $(MAKE) -C libavutil depend
218 $(MAKE) -C libavcodec depend
219 $(MAKE) -C libavformat depend
220 $(MAKE) -C libavdevice depend
221 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
222 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale depend
223 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
225 .depend: $(SRCS) version.h
228 .vhookdep: $(ALLHOOKS_SRCS) version.h
229 $(VHOOK_DEPEND_CMD) > $@
237 $(MAKE) -C libavutil clean
238 $(MAKE) -C libavcodec clean
239 $(MAKE) -C libavformat clean
240 $(MAKE) -C libavdevice clean
241 $(MAKE) -C libpostproc clean
242 $(MAKE) -C libswscale clean
243 $(MAKE) -C libavfilter clean
244 rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
245 output_example$(EXESUF)
246 rm -f doc/*.html doc/*.pod doc/*.1
247 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
248 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
249 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
250 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
253 $(MAKE) -C libavutil distclean
254 $(MAKE) -C libavcodec distclean
255 $(MAKE) -C libavformat distclean
256 $(MAKE) -C libavdevice distclean
257 $(MAKE) -C libpostproc distclean
258 $(MAKE) -C libswscale distclean
259 $(MAKE) -C libavfilter distclean
260 rm -f .depend .vhookdep version.h config.* *.pc
263 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
267 fulltest test: codectest libavtest seektest
269 FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
270 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
271 LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
272 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
273 SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
275 CODEC_TESTS = $(addprefix regtest-, \
321 LAVF_TESTS = $(addprefix regtest-, \
358 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
360 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
361 CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
363 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
365 LAVF_REG = tests/data/lavf.regression
366 ROTOZOOM_REG = tests/data/rotozoom.regression
367 VSYNTH_REG = tests/data/vsynth.regression
369 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
370 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
371 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
373 libavtest: $(LAVF_REG)
374 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
376 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
379 $(LAVF_REG): $(LAVF_REGFILES)
380 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
381 $(VSYNTH_REG): $(CODEC_VSYNTH)
383 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
385 $(LAVF_REGFILES): $(LAVF_TESTS)
387 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
389 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
391 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
392 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
393 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
396 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
398 seektest: codectest libavtest tests/seek_test$(EXESUF)
399 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
401 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
403 @echo "Unfortunately ffserver is broken and therefore its regression"
404 @echo "test fails randomly. Treat the results accordingly."
406 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
408 ifeq ($(CONFIG_SWSCALE),yes)
409 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
412 @echo "This regression test is incompatible with --enable-swscale."
417 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
418 mkdir -p tests/vsynth1
419 $(BUILD_ROOT)/$< 'tests/vsynth1/'
421 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
422 mkdir -p tests/vsynth2
423 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
425 tests/asynth1.sw: tests/audiogen$(EXESUF)
429 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
431 tests/seek_test$(EXESUF): tests/seek_test.c .libs
432 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
435 .PHONY: all lib videohook documentation install* uninstall*
436 .PHONY: dep depend clean distclean TAGS
437 .PHONY: codectest libavtest seektest test-server fulltest test
438 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error