Rename 'tests' target to 'testprogs'. It is too easily confused with the
[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_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
16 BASENAMES   = ffmpeg ffplay ffserver
17 ALLPROGS    = $(addsuffix   $(EXESUF), $(BASENAMES))
18 ALLPROGS_G  = $(addsuffix _g$(EXESUF), $(BASENAMES))
19 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
20
21 FFLIBS-$(CONFIG_AVFILTER) += avfilter
22 FFLIBS-$(CONFIG_POSTPROC) += postproc
23
24 FFLIBS := avdevice avformat avcodec avutil swscale
25
26 DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
27
28 EXAMPLES = output_example$(EXESUF)
29
30 include common.mak
31
32 FF_LDFLAGS   := $(FFLDFLAGS)
33 FF_EXTRALIBS := $(FFEXTRALIBS)
34 FF_DEP_LIBS  := $(DEP_LIBS)
35
36 ALL_TARGETS-$(BUILD_DOC)    += documentation
37
38 ifneq ($(PROGS),)
39 INSTALL_TARGETS-yes             += install-progs install-data
40 INSTALL_TARGETS-$(BUILD_DOC)    += install-man
41 endif
42 INSTALL_PROGS_TARGETS-$(BUILD_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
51
52 define RESET
53 $(1) :=
54 $(1)-yes :=
55 endef
56
57 define DOSUBDIR
58 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
59 SUBDIR := $(1)/
60 include $(1)/Makefile
61 endef
62
63 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
64
65 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
66 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
67
68 %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
69         $(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
70
71 output_example$(EXESUF): output_example.o $(FF_DEP_LIBS)
72         $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
73
74 tools/%$(EXESUF): tools/%.c
75         $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
76
77 ffplay.o ffplay.d: CFLAGS += $(SDL_CFLAGS)
78
79 cmdutils.o cmdutils.d: version.h
80
81 alltools: $(addsuffix $(EXESUF),$(addprefix tools/, cws2fws pktdumper qt-faststart trasher))
82
83 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
84                                  ffplay-doc.html general.html $(ALLMANPAGES))
85
86 doc/%.html: doc/%.texi
87         texi2html -monolithic -number $<
88         mv $(@F) $@
89
90 doc/%.pod: doc/%-doc.texi
91         doc/texi2pod.pl $< $@
92
93 doc/%.1: doc/%.pod
94         pod2man --section=1 --center=" " --release=" " $< > $@
95
96 install: $(INSTALL_TARGETS-yes)
97
98 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
99         install -d "$(BINDIR)"
100         install -c -m 755 $(PROGS) "$(BINDIR)"
101
102 install-data: $(DATA_FILES)
103         install -d "$(DATADIR)"
104         install -m 644 $(DATA_FILES) "$(DATADIR)"
105
106 install-man: $(MANPAGES)
107         install -d "$(MANDIR)/man1"
108         install -m 644 $(MANPAGES) "$(MANDIR)/man1"
109
110 uninstall: uninstall-progs uninstall-data uninstall-man
111
112 uninstall-progs:
113         rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
114
115 uninstall-data:
116         rm -rf "$(DATADIR)"
117
118 uninstall-man:
119         rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
120
121 testclean:
122         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
123
124 clean:: testclean
125         rm -f $(ALLPROGS) $(ALLPROGS_G) output_example$(EXESUF)
126         rm -f doc/*.html doc/*.pod doc/*.1
127         rm -f tests/seek_test$(EXESUF)
128         rm -f $(addprefix tests/,$(addsuffix $(HOSTEXESUF),audiogen videogen rotozoom tiny_psnr))
129         rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
130
131 distclean::
132         rm -f version.h config.*
133
134 # regression tests
135
136 check: test checkheaders
137
138 fulltest test: codectest libavtest seektest
139
140 FFMPEG_REFFILE   = $(SRC_PATH)/tests/ffmpeg.regression.ref
141 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
142 LIBAV_REFFILE    = $(SRC_PATH)/tests/libav.regression.ref
143 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
144 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
145
146 CODEC_TESTS = $(addprefix regtest-,             \
147         mpeg                                    \
148         mpeg2                                   \
149         mpeg2thread                             \
150         msmpeg4v2                               \
151         msmpeg4                                 \
152         wmv1                                    \
153         wmv2                                    \
154         h261                                    \
155         h263                                    \
156         h263p                                   \
157         mpeg4                                   \
158         huffyuv                                 \
159         rc                                      \
160         mpeg4adv                                \
161         mpeg4thread                             \
162         error                                   \
163         mpeg4nr                                 \
164         mpeg1b                                  \
165         mjpeg                                   \
166         ljpeg                                   \
167         jpegls                                  \
168         rv10                                    \
169         rv20                                    \
170         asv1                                    \
171         asv2                                    \
172         flv                                     \
173         ffv1                                    \
174         snow                                    \
175         snowll                                  \
176         dv                                      \
177         dv50                                    \
178         svq1                                    \
179         flashsv                                 \
180         mp2                                     \
181         ac3                                     \
182         g726                                    \
183         adpcm_ima_wav                           \
184         adpcm_ima_qt                            \
185         adpcm_ms                                \
186         adpcm_yam                               \
187         adpcm_swf                               \
188         flac                                    \
189         wma                                     \
190         pcm                                     \
191     )
192
193 LAVF_TESTS = $(addprefix regtest-,              \
194         avi                                     \
195         asf                                     \
196         rm                                      \
197         mpg                                     \
198         mxf                                     \
199         ts                                      \
200         swf                                     \
201         ffm                                     \
202         flv_fmt                                 \
203         mov                                     \
204         dv_fmt                                  \
205         gxf                                     \
206         nut                                     \
207         mkv                                     \
208         pbmpipe                                 \
209         pgmpipe                                 \
210         ppmpipe                                 \
211         gif                                     \
212         yuv4mpeg                                \
213         pgm                                     \
214         ppm                                     \
215         bmp                                     \
216         tga                                     \
217         tiff                                    \
218         sgi                                     \
219         jpg                                     \
220         wav                                     \
221         alaw                                    \
222         mulaw                                   \
223         au                                      \
224         mmf                                     \
225         aiff                                    \
226         voc                                     \
227         ogg                                     \
228         pixfmt                                  \
229         pcx                                     \
230     )
231
232 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
233
234 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
235 CODEC_VSYNTH   = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
236
237 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
238
239 LAVF_REG     = tests/data/lavf.regression
240 ROTOZOOM_REG = tests/data/rotozoom.regression
241 VSYNTH_REG   = tests/data/vsynth.regression
242
243 ifneq ($(CONFIG_ZLIB),yes)
244 regtest-flashsv codectest: zlib-error
245 endif
246 zlib-error:
247         @echo
248         @echo "This regression test requires zlib."
249         @echo
250         @exit 1
251
252 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
253         diff -u -w $(FFMPEG_REFFILE)   $(VSYNTH_REG)
254         diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
255
256 libavtest: $(LAVF_REG)
257         diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
258
259 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
260         cat $^ > $@
261
262 $(LAVF_REG):     $(LAVF_REGFILES)
263 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
264 $(VSYNTH_REG):   $(CODEC_VSYNTH)
265
266 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
267
268 $(LAVF_REGFILES): $(LAVF_TESTS)
269
270 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
271
272 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
273
274 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(HOSTEXESUF)
275         $(SRC_PATH)/tests/regression.sh $@ vsynth   tests/vsynth1 a "$(TARGET_EXEC)" "$(TARGET_PATH)"
276         $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a "$(TARGET_EXEC)" "$(TARGET_PATH)"
277
278 $(LAVF_TESTS):
279         $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b "$(TARGET_EXEC)" "$(TARGET_PATH)"
280
281 seektest: codectest libavtest tests/seek_test$(EXESUF)
282         $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE) "$(TARGET_EXEC)" "$(TARGET_PATH)"
283
284 servertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
285         @echo
286         @echo "Unfortunately ffserver is broken and therefore its regression"
287         @echo "test fails randomly. Treat the results accordingly."
288         @echo
289         $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
290
291 tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
292         mkdir -p tests/vsynth1
293         $(BUILD_ROOT)/$< 'tests/vsynth1/'
294
295 tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
296         mkdir -p tests/vsynth2
297         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
298
299 tests/asynth1.sw: tests/audiogen$(HOSTEXESUF)
300         $(BUILD_ROOT)/$< $@
301
302 tests/%$(HOSTEXESUF): tests/%.c
303         $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)
304
305 tests/seek_test$(EXESUF): tests/seek_test.c $(FF_DEP_LIBS)
306         $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $< $(FF_EXTRALIBS)
307
308
309 .PHONY: documentation *test regtest-* zlib-error alltools check