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