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_SWSCALER),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_SWSCALER)) -C libswscale all
91 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
93 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
94 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
96 ffserver$(EXESUF): ffserver.o cmdutils.o .libs
97 $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o cmdutils.o $(EXTRALIBS)
99 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
100 $(CC) $(LDFLAGS) -o $@ ffplay.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: CFLAGS += $(SDL_CFLAGS)
122 ffmpeg.o ffplay.o ffserver.o: version.h
126 vhook/%$(SLIBSUF): vhook/%.o
127 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
130 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
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)"
158 # Create the Windows installer.
159 wininstaller: all install
160 makensis ffinstall.nsi
163 install -d "$(MANDIR)/man1"
164 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
166 install-vhook: videohook
167 install -d "$(SHLIBDIR)/vhook"
168 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
171 $(MAKE) -C libavutil install-libs
172 $(MAKE) -C libavcodec install-libs
173 $(MAKE) -C libavformat install-libs
174 $(MAKE) -C libavdevice install-libs
175 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
176 $(MAKE-$(CONFIG_SWSCALER)) -C libswscale install-libs
177 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
180 $(MAKE) -C libavutil install-headers
181 $(MAKE) -C libavcodec install-headers
182 $(MAKE) -C libavformat install-headers
183 $(MAKE) -C libavdevice install-headers
184 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
185 $(MAKE) -C libswscale install-headers
186 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
188 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
191 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
194 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
197 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
198 -rmdir "$(SHLIBDIR)/vhook/"
201 $(MAKE) -C libavutil uninstall-libs
202 $(MAKE) -C libavcodec uninstall-libs
203 $(MAKE) -C libavformat uninstall-libs
204 $(MAKE) -C libavdevice uninstall-libs
205 $(MAKE) -C libpostproc uninstall-libs
206 $(MAKE) -C libswscale uninstall-libs
207 $(MAKE) -C libavfilter uninstall-libs
210 $(MAKE) -C libavutil uninstall-headers
211 $(MAKE) -C libavcodec uninstall-headers
212 $(MAKE) -C libavformat uninstall-headers
213 $(MAKE) -C libavdevice uninstall-headers
214 $(MAKE) -C libpostproc uninstall-headers
215 $(MAKE) -C libswscale uninstall-headers
216 $(MAKE) -C libavfilter uninstall-headers
219 depend dep: .depend .vhookdep
220 $(MAKE) -C libavutil depend
221 $(MAKE) -C libavcodec depend
222 $(MAKE) -C libavformat depend
223 $(MAKE) -C libavdevice depend
224 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
225 $(MAKE-$(CONFIG_SWSCALER)) -C libswscale depend
226 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
228 .depend: $(SRCS) version.h
229 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
231 # gcc stupidly only outputs the basename of targets with -MM
232 .vhookdep: $(ALLHOOKS_SRCS) version.h
233 $(CC) $(VHOOKCFLAGS) -MM $^ | sed 's,^\([a-z]\),vhook/\1,' > $@
241 $(MAKE) -C libavutil clean
242 $(MAKE) -C libavcodec clean
243 $(MAKE) -C libavformat clean
244 $(MAKE) -C libavdevice clean
245 $(MAKE) -C libpostproc clean
246 $(MAKE) -C libswscale clean
247 $(MAKE) -C libavfilter clean
248 rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
249 output_example$(EXESUF)
250 rm -f doc/*.html doc/*.pod doc/*.1
251 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
252 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
253 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
254 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
257 $(MAKE) -C libavutil distclean
258 $(MAKE) -C libavcodec distclean
259 $(MAKE) -C libavformat distclean
260 $(MAKE) -C libavdevice distclean
261 $(MAKE) -C libpostproc distclean
262 $(MAKE) -C libswscale distclean
263 $(MAKE) -C libavfilter distclean
264 rm -f .depend .vhookdep version.h config.* *.pc
267 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
271 fulltest test: codectest libavtest seektest
273 FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
274 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
275 LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
276 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
277 SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
279 CODEC_TESTS = $(addprefix regtest-, \
325 LAVF_TESTS = $(addprefix regtest-, \
362 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
364 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
365 CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
367 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
369 LAVF_REG = tests/data/lavf.regression
370 ROTOZOOM_REG = tests/data/rotozoom.regression
371 VSYNTH_REG = tests/data/vsynth.regression
373 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
374 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
375 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
377 libavtest: $(LAVF_REG)
378 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
380 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
383 $(LAVF_REG): $(LAVF_REGFILES)
384 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
385 $(VSYNTH_REG): $(CODEC_VSYNTH)
387 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
389 $(LAVF_REGFILES): $(LAVF_TESTS)
391 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
393 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
395 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
396 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
397 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
400 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
402 seektest: codectest libavtest tests/seek_test$(EXESUF)
403 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
405 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
407 @echo "Unfortunately ffserver is broken and therefore its regression"
408 @echo "test fails randomly. Treat the results accordingly."
410 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
412 ifeq ($(CONFIG_SWSCALER),yes)
413 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
416 @echo "This regression test is incompatible with --enable-swscaler."
421 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
422 mkdir -p tests/vsynth1
423 $(BUILD_ROOT)/$< 'tests/vsynth1/'
425 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
426 mkdir -p tests/vsynth2
427 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
429 tests/asynth1.sw: tests/audiogen$(EXESUF)
433 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
435 tests/seek_test$(EXESUF): tests/seek_test.c .libs
436 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
439 .PHONY: all lib videohook documentation install* wininstaller uninstall*
440 .PHONY: dep depend clean distclean TAGS
441 .PHONY: codectest libavtest seektest test-server fulltest test
442 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error