f745a939bcb2418b6b69b9ce71729008b0cc8689
[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.o: CFLAGS += $(SDL_CFLAGS)
78 ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
79 ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
80
81 %$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
82         $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
83
84 alltools: $(TOOLS)
85
86 tools/%$(EXESUF): tools/%.o
87         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
88
89 tools/%.o: tools/%.c
90         $(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
91
92 -include $(wildcard tools/*.d)
93 -include $(wildcard tests/*.d)
94
95 VERSION_SH  = $(SRC_PATH_BARE)/version.sh
96 GIT_LOG     = $(SRC_PATH_BARE)/.git/logs/HEAD
97
98 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
99 .version: M=@
100
101 version.h .version:
102         $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
103         $(Q)touch .version
104
105 # force version.sh to run whenever version might have changed
106 -include .version
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)texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init --output $@ $<
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-libs install-headers $(INSTALL_TARGETS-yes)
131
132 install-libs: install-libs-yes
133
134 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
135         $(Q)mkdir -p "$(BINDIR)"
136         $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
137
138 install-data: $(DATA_FILES)
139         $(Q)mkdir -p "$(DATADIR)"
140         $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
141
142 install-man: $(MANPAGES)
143         $(Q)mkdir -p "$(MANDIR)/man1"
144         $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
145
146 uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data uninstall-man
147
148 uninstall-progs:
149         $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
150
151 uninstall-data:
152         $(RM) -r "$(DATADIR)"
153
154 uninstall-man:
155         $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
156
157 testclean:
158         $(RM) -r tests/vsynth1 tests/vsynth2 tests/data
159         $(RM) $(addprefix tests/,$(CLEANSUFFIXES))
160         $(RM) tests/seek_test$(EXESUF) tests/seek_test.o
161         $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF))
162
163 clean:: testclean
164         $(RM) $(ALLPROGS)
165         $(RM) $(CLEANSUFFIXES)
166         $(RM) doc/*.html doc/*.pod doc/*.1
167         $(RM) $(TOOLS)
168         $(RM) $(CLEANSUFFIXES:%=tools/%)
169
170 distclean::
171         $(RM) $(DISTCLEANSUFFIXES)
172         $(RM) config.* .version version.h libavutil/avconfig.h
173
174 config:
175         $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
176
177 # regression tests
178
179 check: test checkheaders
180
181 fulltest test: codectest lavftest lavfitest seektest
182
183 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
184
185 codectest: fate-codec
186 lavftest:  fate-lavf
187 lavfitest: fate-lavfi
188 seektest:  fate-seek
189
190 AREF = fate-acodec-aref
191 VREF = fate-vsynth1-vref fate-vsynth2-vref
192 REFS = $(AREF) $(VREF)
193
194 $(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm
195 $(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw
196
197 ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw
198         @echo
199         @echo "Unfortunately ffserver is broken and therefore its regression"
200         @echo "test fails randomly. Treat the results accordingly."
201         @echo
202         $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf
203
204 tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
205         @mkdir -p tests/vsynth1
206         $(M)./$< 'tests/vsynth1/'
207
208 tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
209         @mkdir -p tests/vsynth2
210         $(M)./$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
211
212 tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
213         @mkdir -p tests/data
214         $(M)./$< $@
215
216 tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN
217
218 tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
219         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
220
221 tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS)
222         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
223
224 include $(SRC_PATH_BARE)/tests/fate.mak
225 include $(SRC_PATH_BARE)/tests/fate2.mak
226
227 include $(SRC_PATH_BARE)/tests/fate/aac.mak
228 include $(SRC_PATH_BARE)/tests/fate/als.mak
229 include $(SRC_PATH_BARE)/tests/fate/fft.mak
230 include $(SRC_PATH_BARE)/tests/fate/h264.mak
231 include $(SRC_PATH_BARE)/tests/fate/mp3.mak
232 include $(SRC_PATH_BARE)/tests/fate/vorbis.mak
233 include $(SRC_PATH_BARE)/tests/fate/vp8.mak
234
235 FATE_ACODEC  = $(ACODEC_TESTS:%=fate-acodec-%)
236 FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%)
237 FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%)
238 FATE_VCODEC  = $(FATE_VSYNTH1) $(FATE_VSYNTH2)
239 FATE_LAVF    = $(LAVF_TESTS:%=fate-lavf-%)
240 FATE_LAVFI   = $(LAVFI_TESTS:%=fate-lavfi-%)
241 FATE_SEEK    = $(SEEK_TESTS:seek_%=fate-seek-%)
242
243 FATE = $(FATE_ACODEC)                                                   \
244        $(FATE_VCODEC)                                                   \
245        $(FATE_LAVF)                                                     \
246        $(FATE_LAVFI)                                                    \
247        $(FATE_SEEK)                                                     \
248
249 $(filter-out %-aref,$(FATE_ACODEC)): $(AREF)
250 $(filter-out %-vref,$(FATE_VCODEC)): $(VREF)
251 $(FATE_LAVF):   $(REFS)
252 $(FATE_LAVFI):  $(REFS) tools/lavfi-showfiltfmts$(EXESUF)
253 $(FATE_SEEK):   fate-codec fate-lavf tests/seek_test$(EXESUF)
254
255 $(FATE_ACODEC):  CMD = codectest acodec
256 $(FATE_VSYNTH1): CMD = codectest vsynth1
257 $(FATE_VSYNTH2): CMD = codectest vsynth2
258 $(FATE_LAVF):    CMD = lavftest
259 $(FATE_LAVFI):   CMD = lavfitest
260 $(FATE_SEEK):    CMD = seektest
261
262 fate-codec:  fate-acodec fate-vcodec
263 fate-acodec: $(FATE_ACODEC)
264 fate-vcodec: $(FATE_VCODEC)
265 fate-lavf:   $(FATE_LAVF)
266 fate-lavfi:  $(FATE_LAVFI)
267 fate-seek:   $(FATE_SEEK)
268
269 ifdef SAMPLES
270 FATE += $(FATE_TESTS)
271 fate-rsync:
272         rsync -vaLW rsync://fate-suite.libav.org/fate-suite/ $(SAMPLES)
273 else
274 fate-rsync:
275         @echo "use 'make fate-rsync SAMPLES=/path/to/samples' to sync the fate suite"
276 $(FATE_TESTS):
277         @echo "SAMPLES not specified, cannot run FATE"
278 endif
279
280 FATE_UTILS = base64 tiny_psnr
281
282 fate: $(FATE)
283
284 $(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
285         @echo "TEST    $(@:fate-%=%)"
286         $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' '$(THREAD_TYPE)'
287
288 fate-list:
289         @printf '%s\n' $(sort $(FATE))
290
291 .PHONY: all alltools *clean check config documentation examples install*
292 .PHONY: *test testprogs uninstall*