use diff -u -w in codec regression test
[ffmpeg.git] / Makefile
1 #
2 # Main ffmpeg Makefile
3 # (c) 2000-2004 Fabrice Bellard
4 #
5 include config.mak
6
7 VPATH=$(SRC_PATH_BARE)
8
9 CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
10        -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libswscale \
11        -I$(SRC_PATH)/libavdevice \
12        -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -DHAVE_AV_CONFIG_H
13 LDFLAGS+= -g
14
15 PROGS-$(CONFIG_FFMPEG)   += ffmpeg
16 PROGS-$(CONFIG_FFPLAY)   += ffplay
17 PROGS-$(CONFIG_FFSERVER) += ffserver
18
19 PROGS       = $(addsuffix   $(EXESUF), $(PROGS-yes))
20 PROGS_G     = $(addsuffix _g$(EXESUF), $(PROGS-yes))
21 MANPAGES    = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
22
23 BASENAMES   = ffmpeg ffplay ffserver
24 ALLPROGS    = $(addsuffix   $(EXESUF), $(BASENAMES))
25 ALLPROGS_G  = $(addsuffix _g$(EXESUF), $(BASENAMES))
26 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
27
28 ifeq ($(BUILD_SHARED),yes)
29 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
30 else
31 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
32 endif
33
34 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
35 ALL_TARGETS-$(BUILD_DOC)    += documentation
36
37 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
38 ifneq ($(PROGS),)
39 INSTALL_TARGETS-yes             += install-progs
40 INSTALL_TARGETS-$(BUILD_DOC)    += install-man
41 endif
42
43 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
44
45 BASEHOOKS = fish null watermark
46 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
47 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
48
49 HOOKS-$(HAVE_FORK)      += ppm
50 HOOKS-$(HAVE_IMLIB2)    += imlib2
51 HOOKS-$(HAVE_FREETYPE2) += drawtext
52
53 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
54
55 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
56 LIBS_imlib2$(SLIBSUF)       = `imlib2-config --libs`
57
58 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
59 LIBS_drawtext$(SLIBSUF)        = `freetype-config --libs`
60
61 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
62
63 SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
64 LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
65 EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
66
67 ifeq ($(CONFIG_SWSCALER),yes)
68 LDFLAGS+=-L$(BUILD_ROOT)/libswscale
69 EXTRALIBS+=-lswscale$(BUILDSUF)
70 endif
71
72 MAKE-yes = $(MAKE)
73 MAKE-    = : $(MAKE)
74
75 all: lib $(PROGS) $(ALL_TARGETS-yes)
76
77 lib:
78         $(MAKE)                    -C libavutil   all
79         $(MAKE)                    -C libavcodec  all
80         $(MAKE)                    -C libavformat all
81         $(MAKE)                    -C libavdevice all
82         $(MAKE-$(CONFIG_PP))       -C libpostproc all
83         $(MAKE-$(CONFIG_SWSCALER)) -C libswscale  all
84
85 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
86         $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
87
88 ffserver$(EXESUF): ffserver.o cmdutils.o .libs
89         $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o cmdutils.o $(EXTRALIBS)
90
91 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
92         $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
93
94 %$(EXESUF): %_g$(EXESUF)
95         cp -p $< $@
96         $(STRIP) $@
97
98 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
99 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
100 version.h: $(SVN_ENTRIES)
101 endif
102
103 version.h:
104         $(SRC_PATH)/version.sh $(SRC_PATH)
105
106 output_example$(EXESUF): output_example.o .libs
107         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
108
109 tools/%$(EXESUF): tools/%.c
110         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
111
112 ffplay.o: CFLAGS += $(SDL_CFLAGS)
113
114 ffmpeg.o ffplay.o ffserver.o: version.h
115
116 videohook: .libs $(HOOKS)
117
118 vhook/%$(SLIBSUF): vhook/%.o
119         $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
120
121 vhook/%.o: vhook/%.c
122         $(CC) $(VHOOKCFLAGS) -c -o $@ $<
123
124 %.o: %.c
125         $(CC) $(CFLAGS) -c -o $@ $<
126
127 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
128                                  ffplay-doc.html general.html hooks.html \
129                                  $(ALLMANPAGES))
130
131 doc/%.html: doc/%.texi
132         texi2html -monolithic -number $<
133         mv $(@F) $@
134
135 doc/%.pod: doc/%-doc.texi
136         doc/texi2pod.pl $< $@
137
138 doc/%.1: doc/%.pod
139         pod2man --section=1 --center=" " --release=" " $< > $@
140
141 install: install-libs install-headers $(INSTALL_TARGETS-yes)
142
143 ifeq ($(BUILD_SHARED),yes)
144 install-progs: install-libs
145 endif
146 install-progs: $(PROGS)
147         install -d "$(BINDIR)"
148         install -c -m 755 $(PROGS) "$(BINDIR)"
149
150 # Create the Windows installer.
151 wininstaller: all install
152         makensis ffinstall.nsi
153
154 install-man:
155         install -d "$(MANDIR)/man1"
156         install -m 644 $(MANPAGES) "$(MANDIR)/man1"
157
158 install-vhook: videohook
159         install -d "$(SHLIBDIR)/vhook"
160         install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
161
162 install-libs:
163         $(MAKE)                    -C libavutil   install-libs
164         $(MAKE)                    -C libavcodec  install-libs
165         $(MAKE)                    -C libavformat install-libs
166         $(MAKE)                    -C libavdevice install-libs
167         $(MAKE-$(CONFIG_PP))       -C libpostproc install-libs
168         $(MAKE-$(CONFIG_SWSCALER)) -C libswscale  install-libs
169
170 install-headers:
171         $(MAKE)              -C libavutil   install-headers
172         $(MAKE)              -C libavcodec  install-headers
173         $(MAKE)              -C libavformat install-headers
174         $(MAKE)              -C libavdevice install-headers
175         $(MAKE-$(CONFIG_PP)) -C libpostproc install-headers
176         $(MAKE)              -C libswscale  install-headers
177
178 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
179
180 uninstall-progs:
181         rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
182
183 uninstall-man:
184         rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
185
186 uninstall-vhook:
187         rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
188         -rmdir "$(SHLIBDIR)/vhook/"
189
190 uninstall-libs:
191         $(MAKE) -C libavutil   uninstall-libs
192         $(MAKE) -C libavcodec  uninstall-libs
193         $(MAKE) -C libavformat uninstall-libs
194         $(MAKE) -C libavdevice uninstall-libs
195         $(MAKE) -C libpostproc uninstall-libs
196         $(MAKE) -C libswscale  uninstall-libs
197
198 uninstall-headers:
199         $(MAKE) -C libavutil   uninstall-headers
200         $(MAKE) -C libavcodec  uninstall-headers
201         $(MAKE) -C libavformat uninstall-headers
202         $(MAKE) -C libavdevice uninstall-headers
203         $(MAKE) -C libpostproc uninstall-headers
204         $(MAKE) -C libswscale  uninstall-headers
205         -rmdir "$(INCDIR)"
206
207 depend dep: .depend .vhookdep
208         $(MAKE)                    -C libavutil   depend
209         $(MAKE)                    -C libavcodec  depend
210         $(MAKE)                    -C libavformat depend
211         $(MAKE)                    -C libavdevice depend
212         $(MAKE-$(CONFIG_PP))       -C libpostproc depend
213         $(MAKE-$(CONFIG_SWSCALER)) -C libswscale  depend
214
215 .depend: $(SRCS) version.h
216         $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
217
218 # gcc stupidly only outputs the basename of targets with -MM
219 .vhookdep: $(ALLHOOKS_SRCS) version.h
220         $(CC) $(VHOOKCFLAGS) -MM $^ | sed 's,^\([a-z]\),vhook/\1,' > $@
221
222 $(DEP_LIBS): lib
223
224 .libs: $(DEP_LIBS)
225         touch $@
226
227 clean:
228         $(MAKE) -C libavutil   clean
229         $(MAKE) -C libavcodec  clean
230         $(MAKE) -C libavformat clean
231         $(MAKE) -C libavdevice clean
232         $(MAKE) -C libpostproc clean
233         $(MAKE) -C libswscale  clean
234         rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
235            output_example$(EXESUF)
236         rm -f doc/*.html doc/*.pod doc/*.1
237         rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
238         rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
239         rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
240         rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
241
242 distclean: clean
243         $(MAKE) -C libavutil   distclean
244         $(MAKE) -C libavcodec  distclean
245         $(MAKE) -C libavformat distclean
246         $(MAKE) -C libavdevice distclean
247         $(MAKE) -C libpostproc distclean
248         $(MAKE) -C libswscale  distclean
249         rm -f .depend .vhookdep version.h config.* *.pc
250
251 TAGS:
252         etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
253
254 # regression tests
255
256 fulltest test: codectest libavtest seektest
257
258 FFMPEG_REFFILE   = $(SRC_PATH)/tests/ffmpeg.regression.ref
259 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
260 LIBAV_REFFILE    = $(SRC_PATH)/tests/libav.regression.ref
261 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
262 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
263
264 CODEC_TESTS = $(addprefix regtest-,             \
265         mpeg                                    \
266         mpeg2                                   \
267         mpeg2thread                             \
268         msmpeg4v2                               \
269         msmpeg4                                 \
270         wmv1                                    \
271         wmv2                                    \
272         h261                                    \
273         h263                                    \
274         h263p                                   \
275         mpeg4                                   \
276         huffyuv                                 \
277         rc                                      \
278         mpeg4adv                                \
279         mpeg4thread                             \
280         mp4psp                                  \
281         error                                   \
282         mpeg4nr                                 \
283         mpeg1b                                  \
284         mjpeg                                   \
285         ljpeg                                   \
286         jpegls                                  \
287         rv10                                    \
288         rv20                                    \
289         asv1                                    \
290         asv2                                    \
291         flv                                     \
292         ffv1                                    \
293         snow                                    \
294         snowll                                  \
295         dv                                      \
296         dv50                                    \
297         svq1                                    \
298         flashsv                                 \
299         mp2                                     \
300         ac3                                     \
301         g726                                    \
302         adpcm_ima_wav                           \
303         adpcm_ms                                \
304         adpcm_yam                               \
305         adpcm_swf                               \
306         flac                                    \
307         wma                                     \
308     )
309
310 LAVF_TESTS = $(addprefix regtest-,              \
311         avi                                     \
312         asf                                     \
313         rm                                      \
314         mpg                                     \
315         ts                                      \
316         swf                                     \
317         ffm                                     \
318         flv_fmt                                 \
319         mov                                     \
320         dv_fmt                                  \
321         gxf                                     \
322         nut                                     \
323         mkv                                     \
324         pbmpipe                                 \
325         pgmpipe                                 \
326         ppmpipe                                 \
327         gif                                     \
328         yuv4mpeg                                \
329         pgm                                     \
330         ppm                                     \
331         bmp                                     \
332         tga                                     \
333         tiff                                    \
334         sgi                                     \
335         jpg                                     \
336         wav                                     \
337         alaw                                    \
338         mulaw                                   \
339         au                                      \
340         mmf                                     \
341         aiff                                    \
342         voc                                     \
343         ogg                                     \
344         pixfmt                                  \
345     )
346
347 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
348
349 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
350 CODEC_VSYNTH   = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
351
352 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
353
354 LAVF_REG     = tests/data/lavf.regression
355 ROTOZOOM_REG = tests/data/rotozoom.regression
356 VSYNTH_REG   = tests/data/vsynth.regression
357
358 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
359         diff -u -w $(FFMPEG_REFFILE)   $(VSYNTH_REG)
360         diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
361
362 libavtest: $(LAVF_REG)
363         diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
364
365 $(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
366         cat $^ > $@
367
368 $(LAVF_REG):     $(LAVF_REGFILES)
369 $(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
370 $(VSYNTH_REG):   $(CODEC_VSYNTH)
371
372 $(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
373
374 $(LAVF_REGFILES): $(LAVF_TESTS)
375
376 $(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
377
378 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
379
380 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
381         $(SRC_PATH)/tests/regression.sh $@ vsynth   tests/vsynth1 a
382         $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
383
384 $(LAVF_TESTS):
385         $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
386
387 seektest: codectest libavtest tests/seek_test$(EXESUF)
388         $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
389
390 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
391         @echo
392         @echo "Unfortunately ffserver is broken and therefore its regression"
393         @echo "test fails randomly. Treat the results accordingly."
394         @echo
395         $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
396
397 ifeq ($(CONFIG_SWSCALER),yes)
398 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
399 swscale_error:
400         @echo
401         @echo "This regression test is incompatible with --enable-swscaler."
402         @echo
403         @exit 1
404 endif
405
406 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
407         mkdir -p tests/vsynth1
408         $(BUILD_ROOT)/$< 'tests/vsynth1/'
409
410 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
411         mkdir -p tests/vsynth2
412         $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
413
414 tests/asynth1.sw: tests/audiogen$(EXESUF)
415         $(BUILD_ROOT)/$< $@
416
417 %$(EXESUF): %.c
418         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
419
420 tests/seek_test$(EXESUF): tests/seek_test.c .libs
421         $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
422
423
424 .PHONY: all lib videohook documentation install* wininstaller uninstall*
425 .PHONY: dep depend clean distclean TAGS
426 .PHONY: codectest libavtest seektest test-server fulltest test
427 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
428
429 -include .depend
430 -include .vhookdep