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