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