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