Fix dnxhd custom options, add AVClass in private context
[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 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
91 ffplay.o: CFLAGS += $(SDL_CFLAGS)
92
93 VERSION_SH  = $(SRC_PATH_BARE)/version.sh
94 GIT_LOG     = $(SRC_PATH_BARE)/.git/logs/HEAD
95
96 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
97 .version: M=@
98
99 version.h .version:
100         $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
101         $(Q)touch .version
102
103 # force version.sh to run whenever version might have changed
104 -include .version
105
106 alltools: $(TOOLS)
107
108 DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES)
109
110 documentation: $(DOCS)
111
112 -include $(wildcard $(DOCS:%=%.d))
113
114 TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
115
116 doc/%.html: TAG = HTML
117 doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init
118         $(Q)$(TEXIDEP)
119         $(M)cd doc && texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init $(<:doc/%=%)
120
121 doc/%.pod: TAG = POD
122 doc/%.pod: doc/%.texi
123         $(Q)$(TEXIDEP)
124         $(M)doc/texi2pod.pl $< $@
125
126 doc/%.1: TAG = MAN
127 doc/%.1: doc/%.pod
128         $(M)pod2man --section=1 --center=" " --release=" " $< > $@
129
130 install: $(INSTALL_TARGETS-yes)
131
132 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
133         $(Q)mkdir -p "$(BINDIR)"
134         $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
135
136 install-data: $(DATA_FILES)
137         $(Q)mkdir -p "$(DATADIR)"
138         $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
139
140 install-man: $(MANPAGES)
141         $(Q)mkdir -p "$(MANDIR)/man1"
142         $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
143
144 uninstall: uninstall-progs uninstall-data uninstall-man
145
146 uninstall-progs:
147         $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
148
149 uninstall-data:
150         $(RM) -r "$(DATADIR)"
151
152 uninstall-man:
153         $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
154
155 testclean:
156         $(RM) -r tests/vsynth1 tests/vsynth2 tests/data
157         $(RM) $(addprefix tests/,$(CLEANSUFFIXES))
158         $(RM) tests/seek_test$(EXESUF) tests/seek_test.o
159         $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF))
160
161 clean:: testclean
162         $(RM) $(ALLPROGS)
163         $(RM) $(CLEANSUFFIXES)
164         $(RM) doc/*.html doc/*.pod doc/*.1
165         $(RM) $(TOOLS)
166         $(RM) $(CLEANSUFFIXES:%=tools/%)
167
168 distclean::
169         $(RM) $(DISTCLEANSUFFIXES)
170         $(RM) version.h config.* libavutil/avconfig.h
171
172 config:
173         $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
174
175 # regression tests
176
177 check: test checkheaders
178
179 fulltest test: codectest lavftest lavfitest seektest
180
181 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
182 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
183
184 codectest: fate-codec
185 lavftest:  fate-lavf
186 lavfitest: fate-lavfi
187 seektest:  fate-seek
188
189 AREF = tests/data/acodec.ref.wav
190 VREF = tests/data/vsynth1.ref.yuv
191 REFS = $(AREF) $(VREF)
192
193 $(REFS): TAG = GEN
194
195 $(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm
196         $(M)$(SRC_PATH)/tests/codec-regression.sh vref vsynth1 tests/vsynth1 "$(TARGET_EXEC)" "$(TARGET_PATH)"
197         $(Q)$(SRC_PATH)/tests/codec-regression.sh vref vsynth2 tests/vsynth2 "$(TARGET_EXEC)" "$(TARGET_PATH)"
198
199 $(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw
200         $(M)$(SRC_PATH)/tests/codec-regression.sh aref acodec tests/acodec "$(TARGET_EXEC)" "$(TARGET_PATH)"
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)$(BUILD_ROOT)/$< 'tests/vsynth1/'
212
213 tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
214         @mkdir -p tests/vsynth2
215         $(M)$(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
216
217 tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
218         @mkdir -p tests/data
219         $(M)$(BUILD_ROOT)/$< $@
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 $(FATE_ACODEC): $(AREF)
255 $(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 else
277 $(FATE_TESTS):
278         @echo "SAMPLES not specified, cannot run FATE"
279 endif
280
281 FATE_UTILS = base64 tiny_psnr
282
283 fate: $(FATE)
284
285 $(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
286         @echo "TEST    $(@:fate-%=%)"
287         $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)'
288
289 fate-list:
290         @printf '%s\n' $(sort $(FATE))
291
292 .PHONY: documentation *test regtest-* alltools check config