ARM: factor some repetitive code into macros
[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
151c5841 132install-progs-yes:
623ffe8c
MR
133install-progs-$(CONFIG_DOC): install-man
134install-progs-$(CONFIG_SHARED): install-libs
135
136install-progs: install-progs-yes $(PROGS)
63611f31 137 $(Q)mkdir -p "$(BINDIR)"
fd676deb 138 $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
bde51e6a 139
a1a84f69 140install-data: $(DATA_FILES)
63611f31 141 $(Q)mkdir -p "$(DATADIR)"
fd676deb 142 $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
a1a84f69 143
bde51e6a 144install-man: $(MANPAGES)
63611f31 145 $(Q)mkdir -p "$(MANDIR)/man1"
fd676deb 146 $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
bde51e6a 147
d7a72d25 148uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data uninstall-man
d3cb93b3
RP
149
150uninstall-progs:
50e10cbd 151 $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
d3cb93b3
RP
152
153uninstall-data:
50e10cbd 154 $(RM) -r "$(DATADIR)"
d3cb93b3
RP
155
156uninstall-man:
50e10cbd 157 $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
bde51e6a 158
250dd6f0 159testclean:
50e10cbd
MR
160 $(RM) -r tests/vsynth1 tests/vsynth2 tests/data
161 $(RM) $(addprefix tests/,$(CLEANSUFFIXES))
162 $(RM) tests/seek_test$(EXESUF) tests/seek_test.o
3d157bf3 163 $(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF))
250dd6f0
FC
164
165clean:: testclean
e0be794a 166 $(RM) $(ALLPROGS)
50e10cbd
MR
167 $(RM) $(CLEANSUFFIXES)
168 $(RM) doc/*.html doc/*.pod doc/*.1
169 $(RM) $(TOOLS)
40321376 170 $(RM) $(CLEANSUFFIXES:%=tools/%)
bde51e6a
JR
171
172distclean::
50e10cbd 173 $(RM) $(DISTCLEANSUFFIXES)
59748689 174 $(RM) config.* .version version.h libavutil/avconfig.h
bde51e6a 175
9d0b3042 176config:
29ba0911 177 $(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
0c3b2d65 178
bde51e6a
JR
179# regression tests
180
5bab8536
DB
181check: test checkheaders
182
b3dce4b9 183fulltest test: codectest lavftest lavfitest seektest
bde51e6a 184
bde51e6a 185FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
bde51e6a 186
57f09630
MR
187codectest: fate-codec
188lavftest: fate-lavf
189lavfitest: fate-lavfi
190seektest: fate-seek
40e02409 191
70378ea1
MR
192AREF = fate-acodec-aref
193VREF = fate-vsynth1-vref fate-vsynth2-vref
9770a7ad
MR
194REFS = $(AREF) $(VREF)
195
9be24c60 196$(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm
9be24c60 197$(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw
70378ea1 198
d7167f05 199ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw
bde51e6a
JR
200 @echo
201 @echo "Unfortunately ffserver is broken and therefore its regression"
202 @echo "test fails randomly. Treat the results accordingly."
203 @echo
767e14c3 204 $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf
bde51e6a 205
82bb3329 206tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
4ab20de6 207 @mkdir -p tests/vsynth1
798b2646 208 $(M)./$< 'tests/vsynth1/'
bde51e6a 209
82bb3329 210tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
4ab20de6 211 @mkdir -p tests/vsynth2
798b2646 212 $(M)./$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
bde51e6a 213
d7167f05 214tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
4ab20de6 215 @mkdir -p tests/data
798b2646 216 $(M)./$< $@
4ab20de6
MR
217
218tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN
bde51e6a 219
684b28e0
MR
220tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
221 $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
bde51e6a 222
43d2c6a5
SS
223tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS)
224 $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
225
2fad0977 226include $(SRC_PATH_BARE)/tests/fate.mak
7e264ca1
MR
227include $(SRC_PATH_BARE)/tests/fate2.mak
228
4c3fbd4f
MR
229include $(SRC_PATH_BARE)/tests/fate/aac.mak
230include $(SRC_PATH_BARE)/tests/fate/als.mak
231include $(SRC_PATH_BARE)/tests/fate/fft.mak
232include $(SRC_PATH_BARE)/tests/fate/h264.mak
680aefa2 233include $(SRC_PATH_BARE)/tests/fate/mp3.mak
4c3fbd4f
MR
234include $(SRC_PATH_BARE)/tests/fate/vorbis.mak
235include $(SRC_PATH_BARE)/tests/fate/vp8.mak
236
57f09630
MR
237FATE_ACODEC = $(ACODEC_TESTS:%=fate-acodec-%)
238FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%)
239FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%)
9a3f31ef 240FATE_VCODEC = $(FATE_VSYNTH1) $(FATE_VSYNTH2)
57f09630
MR
241FATE_LAVF = $(LAVF_TESTS:%=fate-lavf-%)
242FATE_LAVFI = $(LAVFI_TESTS:%=fate-lavfi-%)
9a3f31ef
MR
243FATE_SEEK = $(SEEK_TESTS:seek_%=fate-seek-%)
244
245FATE = $(FATE_ACODEC) \
246 $(FATE_VCODEC) \
247 $(FATE_LAVF) \
248 $(FATE_LAVFI) \
249 $(FATE_SEEK) \
250
164c24c8
MR
251$(filter-out %-aref,$(FATE_ACODEC)): $(AREF)
252$(filter-out %-vref,$(FATE_VCODEC)): $(VREF)
9a3f31ef 253$(FATE_LAVF): $(REFS)
43d2c6a5 254$(FATE_LAVFI): $(REFS) tools/lavfi-showfiltfmts$(EXESUF)
9a3f31ef
MR
255$(FATE_SEEK): fate-codec fate-lavf tests/seek_test$(EXESUF)
256
257$(FATE_ACODEC): CMD = codectest acodec
258$(FATE_VSYNTH1): CMD = codectest vsynth1
259$(FATE_VSYNTH2): CMD = codectest vsynth2
260$(FATE_LAVF): CMD = lavftest
261$(FATE_LAVFI): CMD = lavfitest
262$(FATE_SEEK): CMD = seektest
263
264fate-codec: fate-acodec fate-vcodec
265fate-acodec: $(FATE_ACODEC)
266fate-vcodec: $(FATE_VCODEC)
267fate-lavf: $(FATE_LAVF)
268fate-lavfi: $(FATE_LAVFI)
269fate-seek: $(FATE_SEEK)
270
666d7d18 271ifdef SAMPLES
9a3f31ef 272FATE += $(FATE_TESTS)
8ce67bca
RT
273fate-rsync:
274 rsync -vaLW rsync://fate-suite.libav.org/fate-suite/ $(SAMPLES)
2fad0977 275else
8ce67bca
RT
276fate-rsync:
277 @echo "use 'make fate-rsync SAMPLES=/path/to/samples' to sync the fate suite"
715e9be2 278$(FATE_TESTS):
2fad0977
MR
279 @echo "SAMPLES not specified, cannot run FATE"
280endif
bde51e6a 281
b82be636
MR
282FATE_UTILS = base64 tiny_psnr
283
9a3f31ef 284fate: $(FATE)
9a3f31ef 285
164c24c8 286$(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
f6ae77d4 287 @echo "TEST $(@:fate-%=%)"
3283f274 288 $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)' '$(THREADS)' '$(THREAD_TYPE)'
9a3f31ef 289
d29d9ccc
MR
290fate-list:
291 @printf '%s\n' $(sort $(FATE))
292
0018b7f0
MR
293.PHONY: all alltools *clean check config documentation examples install*
294.PHONY: *test testprogs uninstall*