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