Merge remote-tracking branch 'qatar/master'
[ffmpeg.git] / Makefile
1 include config.mak
2
3 SRC_DIR = $(SRC_PATH_BARE)
4
5 vpath %.texi $(SRC_PATH_BARE)
6
7 PROGS-$(CONFIG_FFMPEG)   += ffmpeg
8 PROGS-$(CONFIG_FFPLAY)   += ffplay
9 PROGS-$(CONFIG_FFPROBE)  += ffprobe
10 PROGS-$(CONFIG_FFSERVER) += ffserver
11
12 PROGS      := $(PROGS-yes:%=%$(EXESUF))
13 PROGS_G     = $(PROGS-yes:%=%_g$(EXESUF))
14 OBJS        = $(PROGS-yes:%=%.o) cmdutils.o
15 MANPAGES    = $(PROGS-yes:%=doc/%.1)
16 PODPAGES    = $(PROGS-yes:%=doc/%.pod)
17 HTMLPAGES   = $(PROGS-yes:%=doc/%.html)
18 TOOLS       = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher))
19 TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
20 HOSTPROGS  := $(TESTTOOLS:%=tests/%)
21
22 BASENAMES   = ffmpeg ffplay ffprobe ffserver
23 ALLPROGS    = $(BASENAMES:%=%$(EXESUF))
24 ALLPROGS_G  = $(BASENAMES:%=%_g$(EXESUF))
25 ALLMANPAGES = $(BASENAMES:%=%.1)
26
27 FFLIBS-$(CONFIG_AVDEVICE) += avdevice
28 FFLIBS-$(CONFIG_AVFILTER) += avfilter
29 FFLIBS-$(CONFIG_AVFORMAT) += avformat
30 FFLIBS-$(CONFIG_AVCODEC)  += avcodec
31 FFLIBS-$(CONFIG_POSTPROC) += postproc
32 FFLIBS-$(CONFIG_SWSCALE)  += swscale
33
34 FFLIBS := avutil
35
36 DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
37
38 SKIPHEADERS = cmdutils_common_opts.h
39
40 include common.mak
41
42 FF_LDFLAGS   := $(FFLDFLAGS)
43 FF_EXTRALIBS := $(FFEXTRALIBS)
44 FF_DEP_LIBS  := $(DEP_LIBS)
45
46 ALL_TARGETS-$(CONFIG_DOC)       += documentation
47
48 ifdef PROGS
49 INSTALL_TARGETS-yes             += install-progs install-data
50 INSTALL_TARGETS-$(CONFIG_DOC)   += install-man
51 endif
52 INSTALL_PROGS_TARGETS-$(CONFIG_SHARED) = install-libs
53
54 all: $(FF_DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
55
56 $(PROGS): %$(EXESUF): %_g$(EXESUF)
57         $(CP) $< $@
58         $(STRIP) $@
59
60 config.h: .config
61 .config: $(wildcard $(FFLIBS:%=$(SRC_DIR)/lib%/all*.c))
62         @-tput bold 2>/dev/null
63         @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
64         @-tput sgr0 2>/dev/null
65
66 SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
67                ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
68                HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS
69
70 define RESET
71 $(1) :=
72 $(1)-yes :=
73 endef
74
75 define DOSUBDIR
76 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
77 SUBDIR := $(1)/
78 include $(1)/Makefile
79 endef
80
81 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
82
83 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
84 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
85
86 %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
87         $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
88
89 tools/%$(EXESUF): tools/%.o
90         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
91
92 tools/%.o: tools/%.c
93         $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
94
95 -include $(wildcard tools/*.d)
96 -include $(wildcard tests/*.d)
97
98 ffplay.o: CFLAGS += $(SDL_CFLAGS)
99
100 VERSION_SH  = $(SRC_PATH_BARE)/version.sh
101 GIT_LOG     = $(SRC_PATH_BARE)/.git/logs/HEAD
102
103 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
104 .version: M=@
105
106 version.h .version:
107         $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
108         $(Q)touch .version
109
110 # force version.sh to run whenever version might have changed
111 -include .version
112
113 alltools: $(TOOLS)
114
115 DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES)
116
117 documentation: $(DOCS)
118
119 -include $(wildcard $(DOCS:%=%.d))
120
121 TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
122
123 doc/%.html: TAG = HTML
124 doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init
125         $(Q)$(TEXIDEP)
126         $(M)cd doc && texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init $(<:doc/%=%)
127
128 doc/%.pod: TAG = POD
129 doc/%.pod: doc/%.texi
130         $(Q)$(TEXIDEP)
131         $(M)doc/texi2pod.pl $< $@
132
133 doc/%.1: TAG = MAN
134 doc/%.1: doc/%.pod
135         $(M)pod2man --section=1 --center=" " --release=" " $< > $@
136
137 install: $(INSTALL_TARGETS-yes)
138
139 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
140         $(Q)mkdir -p "$(BINDIR)"
141         $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
142
143 install-data: $(DATA_FILES)
144         $(Q)mkdir -p "$(DATADIR)"
145         $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
146
147 install-man: $(MANPAGES)
148         $(Q)mkdir -p "$(MANDIR)/man1"
149         $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
150
151 uninstall: uninstall-progs uninstall-data uninstall-man
152
153 uninstall-progs:
154         $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
155
156 uninstall-data:
157         $(RM) -r "$(DATADIR)"
158
159 uninstall-man:
160         $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
161
162 testclean:
163         $(RM) -r tests/vsynth1 tests/vsynth2 tests/data
164         $(RM) $(addprefix tests/,$(CLEANSUFFIXES))
165         $(RM) tests/seek_test$(EXESUF) tests/seek_test.o
166         $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF))
167
168 clean:: testclean
169         $(RM) $(ALLPROGS) $(ALLPROGS_G)
170         $(RM) $(CLEANSUFFIXES)
171         $(RM) doc/*.html doc/*.pod doc/*.1
172         $(RM) $(TOOLS)
173         $(RM) $(CLEANSUFFIXES:%=tools/%)
174
175 distclean::
176         $(RM) $(DISTCLEANSUFFIXES)
177         $(RM) config.* .version version.h libavutil/avconfig.h
178
179 config:
180         $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
181
182 # regression tests
183
184 check: test
185
186 fulltest test: codectest lavftest lavfitest seektest
187
188 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
189
190 codectest: fate-codec
191 lavftest:  fate-lavf
192 lavfitest: fate-lavfi
193 seektest:  fate-seek
194
195 AREF = fate-acodec-aref
196 VREF = fate-vsynth1-vref fate-vsynth2-vref
197 REFS = $(AREF) $(VREF)
198
199 $(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm
200 $(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw
201
202 ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw
203         @echo
204         @echo "Unfortunately ffserver is broken and therefore its regression"
205         @echo "test fails randomly. Treat the results accordingly."
206         @echo
207         $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf
208
209 tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
210         @mkdir -p tests/vsynth1
211         $(M)./$< 'tests/vsynth1/'
212
213 tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
214         @mkdir -p tests/vsynth2
215         $(M)./$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
216
217 tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
218         @mkdir -p tests/data
219         $(M)./$< $@
220
221 tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN
222
223 tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
224         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
225
226 tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS)
227         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
228
229 include $(SRC_PATH_BARE)/tests/fate.mak
230 include $(SRC_PATH_BARE)/tests/fate2.mak
231
232 include $(SRC_PATH_BARE)/tests/fate/aac.mak
233 include $(SRC_PATH_BARE)/tests/fate/als.mak
234 include $(SRC_PATH_BARE)/tests/fate/fft.mak
235 include $(SRC_PATH_BARE)/tests/fate/h264.mak
236 include $(SRC_PATH_BARE)/tests/fate/mp3.mak
237 include $(SRC_PATH_BARE)/tests/fate/vorbis.mak
238 include $(SRC_PATH_BARE)/tests/fate/vp8.mak
239
240 FATE_ACODEC  = $(ACODEC_TESTS:%=fate-acodec-%)
241 FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%)
242 FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%)
243 FATE_VCODEC  = $(FATE_VSYNTH1) $(FATE_VSYNTH2)
244 FATE_LAVF    = $(LAVF_TESTS:%=fate-lavf-%)
245 FATE_LAVFI   = $(LAVFI_TESTS:%=fate-lavfi-%)
246 FATE_SEEK    = $(SEEK_TESTS:seek_%=fate-seek-%)
247
248 FATE = $(FATE_ACODEC)                                                   \
249        $(FATE_VCODEC)                                                   \
250        $(FATE_LAVF)                                                     \
251        $(FATE_LAVFI)                                                    \
252        $(FATE_SEEK)                                                     \
253
254 $(filter-out %-aref,$(FATE_ACODEC)): $(AREF)
255 $(filter-out %-vref,$(FATE_VCODEC)): $(VREF)
256 $(FATE_LAVF):   $(REFS)
257 $(FATE_LAVFI):  $(REFS) tools/lavfi-showfiltfmts$(EXESUF)
258 $(FATE_SEEK):   fate-codec fate-lavf tests/seek_test$(EXESUF)
259
260 $(FATE_ACODEC):  CMD = codectest acodec
261 $(FATE_VSYNTH1): CMD = codectest vsynth1
262 $(FATE_VSYNTH2): CMD = codectest vsynth2
263 $(FATE_LAVF):    CMD = lavftest
264 $(FATE_LAVFI):   CMD = lavfitest
265 $(FATE_SEEK):    CMD = seektest
266
267 fate-codec:  fate-acodec fate-vcodec
268 fate-acodec: $(FATE_ACODEC)
269 fate-vcodec: $(FATE_VCODEC)
270 fate-lavf:   $(FATE_LAVF)
271 fate-lavfi:  $(FATE_LAVFI)
272 fate-seek:   $(FATE_SEEK)
273
274 ifdef SAMPLES
275 FATE += $(FATE_TESTS)
276 fate-rsync:
277         rsync -vaLW rsync://fate-suite.libav.org/fate-suite/ $(SAMPLES)
278 else
279 fate-rsync:
280         @echo "use 'make fate-rsync SAMPLES=/path/to/samples' to sync the fate suite"
281 $(FATE_TESTS):
282         @echo "SAMPLES not specified, cannot run FATE. See doc/fate.txt for more information."
283 endif
284
285 FATE_UTILS = base64 tiny_psnr
286
287 fate: $(FATE)
288
289 $(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
290         @echo "TEST    $(@:fate-%=%)"
291         $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' '$(THREAD_TYPE)'
292
293 fate-list:
294         @printf '%s\n' $(sort $(FATE))
295
296 .PHONY: documentation *test regtest-* alltools check config