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 PROGS-$(CONFIG_FFMPEG) += ffmpeg
14 PROGS-$(CONFIG_FFPLAY) += ffplay
15 PROGS-$(CONFIG_FFSERVER) += ffserver
17 PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
18 PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
19 PROGS_SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
20 MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
22 BASENAMES = ffmpeg ffplay ffserver
23 ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
24 ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
25 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
27 ifeq ($(BUILD_SHARED),yes)
28 DEP_LIBS = libavdevice/$(SLIBPREF)avdevice$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavutil/$(SLIBPREF)avutil$(SLIBSUF)
30 DEP_LIBS = libavdevice/$(LIBPREF)avdevice$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavutil/$(LIBPREF)avutil$(LIBSUF)
33 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
34 ALL_TARGETS-$(BUILD_DOC) += documentation
36 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
38 INSTALL_TARGETS-yes += install-progs
39 INSTALL_TARGETS-$(BUILD_DOC) += install-man
41 INSTALL_PROGS_TARGETS-$(BUILD_SHARED) = install-libs
43 main: lib $(PROGS) $(ALL_TARGETS-yes)
45 $(PROGS): %$(EXESUF): %_g$(EXESUF)
50 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
52 .depend: version.h $(PROGS_SRCS)
54 # bandaid to disable triggering shared library installation routines
59 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
61 BASEHOOKS = fish null watermark
62 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
63 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
65 HOOKS-$(HAVE_FORK) += ppm
66 HOOKS-$(HAVE_IMLIB2) += imlib2
67 HOOKS-$(HAVE_FREETYPE2) += drawtext
69 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
71 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
72 LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
74 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
75 LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
77 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
79 LDFLAGS-$(CONFIG_SWSCALE) += -L$(BUILD_ROOT)/libswscale
80 LDFLAGS-$(CONFIG_AVFILTER) += -L$(BUILD_ROOT)/libavfilter
81 LDFLAGS := $(LDFLAGS-yes) -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil -g $(LDFLAGS)
83 EXTRALIBS-$(CONFIG_AVFILTER) += -lavfilter$(BUILDSUF)
84 EXTRALIBS-$(CONFIG_SWSCALE) += -lswscale$(BUILDSUF)
85 EXTRALIBS := $(EXTRALIBS-yes) -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
91 $(MAKE) -C libavutil all
92 $(MAKE) -C libavcodec all
93 $(MAKE) -C libavformat all
94 $(MAKE) -C libavdevice all
95 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
96 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale all
97 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
99 ffplay_g$(EXESUF): EXTRALIBS += $(SDL_LIBS)
100 ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
102 %_g$(EXESUF): %.o cmdutils.o .libs
103 $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
105 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
106 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
107 version.h: $(SVN_ENTRIES)
111 $(SRC_PATH)/version.sh $(SRC_PATH)
113 output_example$(EXESUF): output_example.o .libs
114 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
116 tools/%$(EXESUF): tools/%.c
117 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
119 ffplay.o .depend: CFLAGS += $(SDL_CFLAGS)
121 ffmpeg.o ffplay.o ffserver.o: version.h
123 # vhooks compile fine without libav*, but need them nonetheless.
124 videohook: .libs $(HOOKS)
126 vhook/%$(SLIBSUF): vhook/%.o
127 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
129 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
130 ffplay-doc.html general.html hooks.html \
133 doc/%.html: doc/%.texi
134 texi2html -monolithic -number $<
137 doc/%.pod: doc/%-doc.texi
138 doc/texi2pod.pl $< $@
141 pod2man --section=1 --center=" " --release=" " $< > $@
143 install: $(INSTALL_TARGETS-yes)
145 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
146 install -d "$(BINDIR)"
147 install -c -m 755 $(PROGS) "$(BINDIR)"
150 install -d "$(MANDIR)/man1"
151 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
153 install-vhook: videohook
154 install -d "$(SHLIBDIR)/vhook"
155 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
158 $(MAKE) -C libavutil install-libs
159 $(MAKE) -C libavcodec install-libs
160 $(MAKE) -C libavformat install-libs
161 $(MAKE) -C libavdevice install-libs
162 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
163 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale install-libs
164 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
167 $(MAKE) -C libavutil install-headers
168 $(MAKE) -C libavcodec install-headers
169 $(MAKE) -C libavformat install-headers
170 $(MAKE) -C libavdevice install-headers
171 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
172 $(MAKE) -C libswscale install-headers
173 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
175 uninstall: uninstall-progs uninstall-man uninstall-vhook
178 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
181 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
184 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
185 -rmdir "$(SHLIBDIR)/vhook/"
188 $(MAKE) -C libavutil uninstall-libs
189 $(MAKE) -C libavcodec uninstall-libs
190 $(MAKE) -C libavformat uninstall-libs
191 $(MAKE) -C libavdevice uninstall-libs
192 $(MAKE) -C libpostproc uninstall-libs
193 $(MAKE) -C libswscale uninstall-libs
194 $(MAKE) -C libavfilter uninstall-libs
197 $(MAKE) -C libavutil uninstall-headers
198 $(MAKE) -C libavcodec uninstall-headers
199 $(MAKE) -C libavformat uninstall-headers
200 $(MAKE) -C libavdevice uninstall-headers
201 $(MAKE) -C libpostproc uninstall-headers
202 $(MAKE) -C libswscale uninstall-headers
203 $(MAKE) -C libavfilter uninstall-headers
206 depend dep: .vhookdep
207 $(MAKE) -C libavutil depend
208 $(MAKE) -C libavcodec depend
209 $(MAKE) -C libavformat depend
210 $(MAKE) -C libavdevice depend
211 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
212 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale depend
213 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
215 .vhookdep: $(ALLHOOKS_SRCS) version.h
216 $(VHOOK_DEPEND_CMD) > $@
224 $(MAKE) -C libavutil clean
225 $(MAKE) -C libavcodec clean
226 $(MAKE) -C libavformat clean
227 $(MAKE) -C libavdevice clean
228 $(MAKE) -C libpostproc clean
229 $(MAKE) -C libswscale clean
230 $(MAKE) -C libavfilter clean
231 rm -f .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
232 output_example$(EXESUF)
233 rm -f doc/*.html doc/*.pod doc/*.1
234 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
235 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
236 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
237 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
240 $(MAKE) -C libavutil distclean
241 $(MAKE) -C libavcodec distclean
242 $(MAKE) -C libavformat distclean
243 $(MAKE) -C libavdevice distclean
244 $(MAKE) -C libpostproc distclean
245 $(MAKE) -C libswscale distclean
246 $(MAKE) -C libavfilter distclean
247 rm -f .vhookdep version.h config.* *.pc
251 fulltest test: codectest libavtest seektest
253 FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
254 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
255 LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
256 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
257 SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
259 CODEC_TESTS = $(addprefix regtest-, \
305 LAVF_TESTS = $(addprefix regtest-, \
342 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
344 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
345 CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
347 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
349 LAVF_REG = tests/data/lavf.regression
350 ROTOZOOM_REG = tests/data/rotozoom.regression
351 VSYNTH_REG = tests/data/vsynth.regression
353 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
354 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
355 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
357 libavtest: $(LAVF_REG)
358 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
360 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
363 $(LAVF_REG): $(LAVF_REGFILES)
364 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
365 $(VSYNTH_REG): $(CODEC_VSYNTH)
367 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
369 $(LAVF_REGFILES): $(LAVF_TESTS)
371 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
373 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
375 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
376 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
377 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
380 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
382 seektest: codectest libavtest tests/seek_test$(EXESUF)
383 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
385 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
387 @echo "Unfortunately ffserver is broken and therefore its regression"
388 @echo "test fails randomly. Treat the results accordingly."
390 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
392 ifeq ($(CONFIG_SWSCALE),yes)
393 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
396 @echo "This regression test is incompatible with --enable-swscale."
401 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
402 mkdir -p tests/vsynth1
403 $(BUILD_ROOT)/$< 'tests/vsynth1/'
405 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
406 mkdir -p tests/vsynth2
407 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
409 tests/asynth1.sw: tests/audiogen$(EXESUF)
413 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
415 tests/seek_test$(EXESUF): tests/seek_test.c .libs
416 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
419 .PHONY: lib videohook documentation TAGS
420 .PHONY: codectest libavtest seektest test-server fulltest test
421 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error