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