regtest: run tests only for enabled codecs and formats
[platform/upstream/libav.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_FFSERVER) += ffserver
10
11 PROGS      := $(addsuffix   $(EXESUF), $(PROGS-yes))
12 PROGS_G     = $(addsuffix _g$(EXESUF), $(PROGS-yes))
13 OBJS        = $(addsuffix .o,          $(PROGS-yes)) cmdutils.o
14 MANPAGES    = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
15 TOOLS       = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws pktdumper probetest qt-faststart trasher))
16 HOSTPROGS   = $(addprefix tests/, audiogen videogen rotozoom tiny_psnr)
17
18 BASENAMES   = ffmpeg ffplay ffserver
19 ALLPROGS    = $(addsuffix   $(EXESUF), $(BASENAMES))
20 ALLPROGS_G  = $(addsuffix _g$(EXESUF), $(BASENAMES))
21 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
22
23 FFLIBS-$(CONFIG_AVFILTER) += avfilter
24 FFLIBS-$(CONFIG_POSTPROC) += postproc
25
26 FFLIBS := avdevice avformat avcodec avutil swscale
27
28 DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
29
30 include common.mak
31
32 FF_LDFLAGS   := $(FFLDFLAGS)
33 FF_EXTRALIBS := $(FFEXTRALIBS)
34 FF_DEP_LIBS  := $(DEP_LIBS)
35
36 ALL_TARGETS-$(CONFIG_DOC)       += documentation
37
38 ifdef PROGS
39 INSTALL_TARGETS-yes             += install-progs install-data
40 INSTALL_TARGETS-$(CONFIG_DOC)   += install-man
41 endif
42 INSTALL_PROGS_TARGETS-$(CONFIG_SHARED) = install-libs
43
44 all: $(FF_DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
45
46 $(PROGS): %$(EXESUF): %_g$(EXESUF)
47         cp -p $< $@
48         $(STRIP) $@
49
50 SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
51                ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
52                HOSTPROGS
53
54 define RESET
55 $(1) :=
56 $(1)-yes :=
57 endef
58
59 define DOSUBDIR
60 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
61 SUBDIR := $(1)/
62 include $(1)/Makefile
63 endef
64
65 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
66
67 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
68 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
69
70 %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
71         $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
72
73 tools/%$(EXESUF): tools/%.o
74         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
75
76 tools/%.o: tools/%.c
77         $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_O) $<
78
79 ffplay.o ffplay.d: CFLAGS += $(SDL_CFLAGS)
80
81 cmdutils.o cmdutils.d: version.h
82
83 alltools: $(TOOLS)
84
85 documentation: $(addprefix doc/, developer.html faq.html ffmpeg-doc.html \
86                                  ffplay-doc.html ffserver-doc.html       \
87                                  general.html libavfilter.html $(ALLMANPAGES))
88
89 doc/%.html: doc/%.texi
90         texi2html -monolithic -number $<
91         mv $(@F) $@
92
93 doc/%.pod: doc/%-doc.texi
94         doc/texi2pod.pl $< $@
95
96 doc/%.1: doc/%.pod
97         pod2man --section=1 --center=" " --release=" " $< > $@
98
99 install: $(INSTALL_TARGETS-yes)
100
101 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
102         install -d "$(BINDIR)"
103         install -c -m 755 $(PROGS) "$(BINDIR)"
104
105 install-data: $(DATA_FILES)
106         install -d "$(DATADIR)"
107         install -m 644 $(DATA_FILES) "$(DATADIR)"
108
109 install-man: $(MANPAGES)
110         install -d "$(MANDIR)/man1"
111         install -m 644 $(MANPAGES) "$(MANDIR)/man1"
112
113 uninstall:
114         @echo "I'm sorry, Dave. I'm afraid I can't do that"
115
116 testclean:
117         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/*~
118
119 clean:: testclean
120         rm -f $(ALLPROGS) $(ALLPROGS_G)
121         rm -f $(CLEANSUFFIXES)
122         rm -f doc/*.html doc/*.pod doc/*.1
123         rm -f tests/seek_test$(EXESUF) tests/seek_test.o
124         rm -f $(addprefix tests/,$(addsuffix $(HOSTEXESUF),audiogen videogen rotozoom tiny_psnr))
125         rm -f $(TOOLS)
126
127 distclean::
128         rm -f $(DISTCLEANSUFFIXES)
129         rm -f version.h config.*
130
131 config:
132         $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
133
134 # regression tests
135
136 check: test checkheaders
137
138 fulltest test: codectest lavftest seektest
139
140 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
141 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
142
143 ENCDEC = $(and $(CONFIG_$(1)_ENCODER),$(CONFIG_$(1)_DECODER))
144 MUXDEM = $(and $(CONFIG_$(1)_MUXER),$(CONFIG_$(or $(2),$(1))_DEMUXER))
145
146 CODEC_TESTS =
147 CODEC_TESTS-$(call ENCDEC,AC3)               += ac3
148 CODEC_TESTS-$(call ENCDEC,ADPCM_G726)        += g726
149 CODEC_TESTS-$(call ENCDEC,ADPCM_IMA_QT)      += adpcm_ima_qt
150 CODEC_TESTS-$(call ENCDEC,ADPCM_IMA_WAV)     += adpcm_ima_wav
151 CODEC_TESTS-$(call ENCDEC,ADPCM_MS)          += adpcm_ms
152 CODEC_TESTS-$(call ENCDEC,ADPCM_SWF)         += adpcm_swf
153 CODEC_TESTS-$(call ENCDEC,ADPCM_YAMAHA)      += adpcm_yam
154 CODEC_TESTS-$(call ENCDEC,ALAC)              += alac
155 CODEC_TESTS-$(call ENCDEC,ASV1)              += asv1
156 CODEC_TESTS-$(call ENCDEC,ASV2)              += asv2
157 CODEC_TESTS-$(call ENCDEC,DNXHD)             += dnxhd_1080i dnxhd_720p dnxhd_720p_rd
158 CODEC_TESTS-$(call ENCDEC,DVVIDEO)           += dv dv50
159 CODEC_TESTS-$(call ENCDEC,FFV1)              += ffv1
160 CODEC_TESTS-$(call ENCDEC,FLAC)              += flac
161 CODEC_TESTS-$(call ENCDEC,FLASHSV)           += flashsv
162 CODEC_TESTS-$(call ENCDEC,FLV)               += flv
163 CODEC_TESTS-$(call ENCDEC,H261)              += h261
164 CODEC_TESTS-$(call ENCDEC,H263)              += h263 h263p
165 CODEC_TESTS-$(call ENCDEC,HUFFYUV)           += huffyuv
166 CODEC_TESTS-$(call ENCDEC,JPEGLS)            += jpegls
167 CODEC_TESTS-$(call ENCDEC,MJPEG)             += mjpeg ljpeg
168 CODEC_TESTS-$(call ENCDEC,MP2)               += mp2
169 CODEC_TESTS-$(call ENCDEC,MPEG1VIDEO)        += mpeg mpeg1b
170 CODEC_TESTS-$(call ENCDEC,MPEG2VIDEO)        += mpeg2 mpeg2thread
171 CODEC_TESTS-$(call ENCDEC,MPEG4)             += mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc
172 CODEC_TESTS-$(call ENCDEC,MSMPEG4V1)         += msmpeg4
173 CODEC_TESTS-$(call ENCDEC,MSMPEG4V2)         += msmpeg4v2
174 CODEC_TESTS-$(call ENCDEC,PCM_S16LE)         += pcm         # fixme
175 CODEC_TESTS-$(call ENCDEC,ROQ)               += roq
176 CODEC_TESTS-$(call ENCDEC,RV10)              += rv10
177 CODEC_TESTS-$(call ENCDEC,RV20)              += rv20
178 CODEC_TESTS-$(call ENCDEC,SNOW)              += snow snowll
179 CODEC_TESTS-$(call ENCDEC,SVQ1)              += svq1
180 CODEC_TESTS-$(call ENCDEC,WMAV1)             += wmav1
181 CODEC_TESTS-$(call ENCDEC,WMAV1)             += wmav2
182 CODEC_TESTS-$(call ENCDEC,WMV1)              += wmv1
183 CODEC_TESTS-$(call ENCDEC,WMV2)              += wmv2
184
185 LAVF_TESTS =
186 LAVF_TESTS-$(call MUXDEM,AIFF)               += aiff
187 LAVF_TESTS-$(call MUXDEM,PCM_ALAW)           += alaw
188 LAVF_TESTS-$(call MUXDEM,ASF)                += asf
189 LAVF_TESTS-$(call MUXDEM,AU)                 += au
190 LAVF_TESTS-$(call MUXDEM,AVI)                += avi
191 LAVF_TESTS-$(call ENCDEC,BMP)                += bmp
192 LAVF_TESTS-$(call MUXDEM,DV)                 += dv_fmt
193 LAVF_TESTS-$(call MUXDEM,FFM)                += ffm
194 LAVF_TESTS-$(call MUXDEM,FLV)                += flv_fmt
195 LAVF_TESTS-$(call ENCDEC,GIF)                += gif
196 LAVF_TESTS-$(call MUXDEM,GXF)                += gxf
197 LAVF_TESTS-$(call ENCDEC,MJPEG)              += jpg
198 LAVF_TESTS-$(call MUXDEM,MATROSKA)           += mkv
199 LAVF_TESTS-$(call MUXDEM,MMF)                += mmf
200 LAVF_TESTS-$(call MUXDEM,MOV)                += mov
201 LAVF_TESTS-$(call MUXDEM,MPEG1SYSTEM,MPEGPS) += mpg
202 LAVF_TESTS-$(call MUXDEM,PCM_MULAW)          += mulaw
203 LAVF_TESTS-$(call MUXDEM,MXF)                += mxf
204 LAVF_TESTS-$(call MUXDEM,NUT)                += nut
205 LAVF_TESTS-$(call MUXDEM,OGG)                += ogg
206 LAVF_TESTS-$(call ENCDEC,PBM)                += pbmpipe
207 LAVF_TESTS-$(call ENCDEC,PCX)                += pcx
208 LAVF_TESTS-$(call ENCDEC,PGM)                += pgm pgmpipe
209 LAVF_TESTS-$(call MUXDEM,RAWVIDEO)           += pixfmt
210 LAVF_TESTS-$(call ENCDEC,PPM)                += ppm ppmpipe
211 LAVF_TESTS-$(call MUXDEM,RM)                 += rm
212 LAVF_TESTS-$(call ENCDEC,SGI)                += sgi
213 LAVF_TESTS-$(call MUXDEM,SWF)                += swf
214 LAVF_TESTS-$(call ENCDEC,TARGA)              += tga
215 LAVF_TESTS-$(call ENCDEC,TIFF)               += tiff
216 LAVF_TESTS-$(call MUXDEM,MPEGTS)             += ts
217 LAVF_TESTS-$(call MUXDEM,VOC)                += voc
218 LAVF_TESTS-$(call MUXDEM,WAV)                += wav
219 LAVF_TESTS-$(call MUXDEM,YUV4MPEGPIPE)       += yuv4mpeg
220
221 LAVFI_TESTS =
222
223 CODEC_TESTS := $(addprefix regtest-, $(CODEC_TESTS) $(CODEC_TESTS-yes))
224 LAVF_TESTS  := $(addprefix regtest-, $(LAVF_TESTS)  $(LAVF_TESTS-yes))
225 LAVFI_TESTS := $(addprefix regtest-, $(LAVFI_TESTS) $(LAVFI_TESTS-yes))
226
227 codectest: $(CODEC_TESTS)
228 lavftest:  $(LAVF_TESTS)
229
230 # lavfitest: $(LAVFI_TESTS)
231
232 $(CODEC_TESTS) $(LAVF_TESTS) $(LAVFI_TESTS): regtest-ref
233
234 REFFILE = $(SRC_PATH)/tests/ref/$(1)/$(2:regtest-%=%)
235 RESFILE = tests/data/$(2:regtest-%=%).$(1).regression
236
237 define CODECTEST_CMD
238         $(SRC_PATH)/tests/codec-regression.sh $@ vsynth1 tests/vsynth1 a "$(TARGET_EXEC)" "$(TARGET_PATH)"
239         $(SRC_PATH)/tests/codec-regression.sh $@ vsynth2 tests/vsynth2 a "$(TARGET_EXEC)" "$(TARGET_PATH)"
240 endef
241
242 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/data/asynth1.sw
243         $(CODECTEST_CMD)
244
245 $(CODEC_TESTS): tests/tiny_psnr$(HOSTEXESUF)
246         @echo "TEST CODEC $(@:regtest-%=%)"
247         @$(CODECTEST_CMD)
248         @diff -u -w $(call REFFILE,vsynth1,$@) $(call RESFILE,vsynth1,$@)
249         @diff -u -w $(call REFFILE,vsynth2,$@) $(call RESFILE,vsynth2,$@)
250
251 $(LAVF_TESTS):
252         @echo "TEST LAVF  $(@:regtest-%=%)"
253         @$(SRC_PATH)/tests/lavf-regression.sh $@ lavf tests/vsynth1 b "$(TARGET_EXEC)" "$(TARGET_PATH)"
254         @diff -u -w $(call REFFILE,lavf,$@) $(call RESFILE,lavf,$@)
255
256 $(LAVFI_TESTS):
257         @echo "TEST LAVFI $(@:regtest-%=%)"
258         @$(SRC_PATH)/tests/lavfi-regression.sh $@ lavfi tests/vsynth1 b "$(TARGET_EXEC)" "$(TARGET_PATH)"
259         @diff -u -w $(call REFFILE,lavfi,$@) $(call RESFILE,lavfi,$@)
260
261 seektest: codectest lavftest tests/seek_test$(EXESUF)
262         $(SRC_PATH)/tests/seek-regression.sh $(SEEK_REFFILE) "$(TARGET_EXEC)" "$(TARGET_PATH)"
263
264 ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw
265         @echo
266         @echo "Unfortunately ffserver is broken and therefore its regression"
267         @echo "test fails randomly. Treat the results accordingly."
268         @echo
269         $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf
270
271 tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
272         mkdir -p tests/vsynth1
273         $(BUILD_ROOT)/$< 'tests/vsynth1/'
274
275 tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
276         mkdir -p tests/vsynth2
277         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
278
279 tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
280         mkdir -p tests/data
281         $(BUILD_ROOT)/$< $@
282
283 tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
284         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
285
286
287 .PHONY: documentation *test regtest-* zlib-error alltools check config