Correctly handle empty frames
[libav.git] / Makefile
1 #
2 # Main ffmpeg Makefile
3 # (c) 2000-2004 Fabrice Bellard
4 #
5 include config.mak
6
7 vpath %.c $(SRC_PATH_BARE)
8 vpath %.h $(SRC_PATH_BARE)
9 vpath %.texi $(SRC_PATH_BARE)
10
11 CFLAGS=$(OPTFLAGS) -I$(BUILD_ROOT) -I$(SRC_PATH) -I$(SRC_PATH)/libavutil \
12 -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavformat -I$(SRC_PATH)/libswscale \
13 -I$(SRC_PATH)/libavdevice -I$(SRC_PATH)/libavfilter \
14 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -DHAVE_AV_CONFIG_H
15 LDFLAGS+= -g
16
17 PROGS-$(CONFIG_FFMPEG) += ffmpeg
18 PROGS-$(CONFIG_FFPLAY) += ffplay
19 PROGS-$(CONFIG_FFSERVER) += ffserver
20
21 PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
22 PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
23 MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
24
25 BASENAMES = ffmpeg ffplay ffserver
26 ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
27 ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
28 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
29
30 ifeq ($(BUILD_SHARED),yes)
31 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
32 else
33 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
34 endif
35
36 ALL_TARGETS-$(CONFIG_VHOOK) += videohook
37 ALL_TARGETS-$(BUILD_DOC) += documentation
38
39 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
40 ifneq ($(PROGS),)
41 INSTALL_TARGETS-yes += install-progs
42 INSTALL_TARGETS-$(BUILD_DOC) += install-man
43 endif
44
45 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
46
47 BASEHOOKS = fish null watermark
48 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
49 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
50
51 HOOKS-$(HAVE_FORK) += ppm
52 HOOKS-$(HAVE_IMLIB2) += imlib2
53 HOOKS-$(HAVE_FREETYPE2) += drawtext
54
55 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
56
57 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
58 LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
59
60 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
61 LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
62
63 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
64
65 SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
66 LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil $(LDFLAGS)
67 EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
68
69 ifeq ($(CONFIG_SWSCALER),yes)
70 LDFLAGS+=-L$(BUILD_ROOT)/libswscale
71 EXTRALIBS+=-lswscale$(BUILDSUF)
72 endif
73
74 ifeq ($(CONFIG_AVFILTER),yes)
75 LDFLAGS+=-L$(BUILD_ROOT)/libavfilter
76 EXTRALIBS := -lavfilter$(BUILDSUF) $(EXTRALIBS)
77 endif
78
79 MAKE-yes = $(MAKE)
80 MAKE- = : $(MAKE)
81
82 all: lib $(PROGS) $(ALL_TARGETS-yes)
83
84 lib:
85 $(MAKE) -C libavutil all
86 $(MAKE) -C libavcodec all
87 $(MAKE) -C libavformat all
88 $(MAKE) -C libavdevice all
89 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
90 $(MAKE-$(CONFIG_SWSCALER)) -C libswscale all
91 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
92
93 ffmpeg_g$(EXESUF): ffmpeg.o cmdutils.o .libs
94 $(CC) $(LDFLAGS) -o $@ ffmpeg.o cmdutils.o $(EXTRALIBS)
95
96 ffserver$(EXESUF): ffserver.o cmdutils.o .libs
97 $(CC) $(LDFLAGS) $(FFSERVERLDFLAGS) -o $@ ffserver.o cmdutils.o $(EXTRALIBS)
98
99 ffplay_g$(EXESUF): ffplay.o cmdutils.o .libs
100 $(CC) $(LDFLAGS) -o $@ ffplay.o cmdutils.o $(EXTRALIBS) $(SDL_LIBS)
101
102 %$(EXESUF): %_g$(EXESUF)
103 cp -p $< $@
104 $(STRIP) $@
105
106 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
107 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
108 version.h: $(SVN_ENTRIES)
109 endif
110
111 version.h:
112 $(SRC_PATH)/version.sh $(SRC_PATH)
113
114 output_example$(EXESUF): output_example.o .libs
115 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
116
117 tools/%$(EXESUF): tools/%.c
118 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(EXTRALIBS)
119
120 ffplay.o: CFLAGS += $(SDL_CFLAGS)
121
122 ffmpeg.o ffplay.o ffserver.o: version.h
123
124 videohook: $(HOOKS)
125
126 vhook/%$(SLIBSUF): vhook/%.o
127 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
128
129 vhook/%.o: vhook/%.c
130 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
131
132 %.o: %.c
133 $(CC) $(CFLAGS) -c -o $@ $<
134
135 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
136 ffplay-doc.html general.html hooks.html \
137 $(ALLMANPAGES))
138
139 doc/%.html: doc/%.texi
140 texi2html -monolithic -number $<
141 mv $(@F) $@
142
143 doc/%.pod: doc/%-doc.texi
144 doc/texi2pod.pl $< $@
145
146 doc/%.1: doc/%.pod
147 pod2man --section=1 --center=" " --release=" " $< > $@
148
149 install: install-libs install-headers $(INSTALL_TARGETS-yes)
150
151 ifeq ($(BUILD_SHARED),yes)
152 install-progs: install-libs
153 endif
154 install-progs: $(PROGS)
155 install -d "$(BINDIR)"
156 install -c -m 755 $(PROGS) "$(BINDIR)"
157
158 # Create the Windows installer.
159 wininstaller: all install
160 makensis ffinstall.nsi
161
162 install-man:
163 install -d "$(MANDIR)/man1"
164 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
165
166 install-vhook: videohook
167 install -d "$(SHLIBDIR)/vhook"
168 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
169
170 install-libs:
171 $(MAKE) -C libavutil install-libs
172 $(MAKE) -C libavcodec install-libs
173 $(MAKE) -C libavformat install-libs
174 $(MAKE) -C libavdevice install-libs
175 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
176 $(MAKE-$(CONFIG_SWSCALER)) -C libswscale install-libs
177 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
178
179 install-headers:
180 $(MAKE) -C libavutil install-headers
181 $(MAKE) -C libavcodec install-headers
182 $(MAKE) -C libavformat install-headers
183 $(MAKE) -C libavdevice install-headers
184 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
185 $(MAKE) -C libswscale install-headers
186 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
187
188 uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
189
190 uninstall-progs:
191 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
192
193 uninstall-man:
194 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
195
196 uninstall-vhook:
197 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
198 -rmdir "$(SHLIBDIR)/vhook/"
199
200 uninstall-libs:
201 $(MAKE) -C libavutil uninstall-libs
202 $(MAKE) -C libavcodec uninstall-libs
203 $(MAKE) -C libavformat uninstall-libs
204 $(MAKE) -C libavdevice uninstall-libs
205 $(MAKE) -C libpostproc uninstall-libs
206 $(MAKE) -C libswscale uninstall-libs
207 $(MAKE) -C libavfilter uninstall-libs
208
209 uninstall-headers:
210 $(MAKE) -C libavutil uninstall-headers
211 $(MAKE) -C libavcodec uninstall-headers
212 $(MAKE) -C libavformat uninstall-headers
213 $(MAKE) -C libavdevice uninstall-headers
214 $(MAKE) -C libpostproc uninstall-headers
215 $(MAKE) -C libswscale uninstall-headers
216 $(MAKE) -C libavfilter uninstall-headers
217 -rmdir "$(INCDIR)"
218
219 depend dep: .depend .vhookdep
220 $(MAKE) -C libavutil depend
221 $(MAKE) -C libavcodec depend
222 $(MAKE) -C libavformat depend
223 $(MAKE) -C libavdevice depend
224 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
225 $(MAKE-$(CONFIG_SWSCALER)) -C libswscale depend
226 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
227
228 .depend: $(SRCS) version.h
229 $(CC) -MM $(CFLAGS) $(SDL_CFLAGS) $(filter-out %.h,$^) 1>.depend
230
231 # gcc stupidly only outputs the basename of targets with -MM
232 .vhookdep: $(ALLHOOKS_SRCS) version.h
233 $(CC) $(VHOOKCFLAGS) -MM $^ | sed 's,^\([a-z]\),vhook/\1,' > $@
234
235 $(DEP_LIBS): lib
236
237 .libs: $(DEP_LIBS)
238 touch $@
239
240 clean:
241 $(MAKE) -C libavutil clean
242 $(MAKE) -C libavcodec clean
243 $(MAKE) -C libavformat clean
244 $(MAKE) -C libavdevice clean
245 $(MAKE) -C libpostproc clean
246 $(MAKE) -C libswscale clean
247 $(MAKE) -C libavfilter clean
248 rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
249 output_example$(EXESUF)
250 rm -f doc/*.html doc/*.pod doc/*.1
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))
253 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
254 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
255
256 distclean: clean
257 $(MAKE) -C libavutil distclean
258 $(MAKE) -C libavcodec distclean
259 $(MAKE) -C libavformat distclean
260 $(MAKE) -C libavdevice distclean
261 $(MAKE) -C libpostproc distclean
262 $(MAKE) -C libswscale distclean
263 $(MAKE) -C libavfilter distclean
264 rm -f .depend .vhookdep version.h config.* *.pc
265
266 TAGS:
267 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
268
269 # regression tests
270
271 fulltest test: codectest libavtest seektest
272
273 FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
274 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
275 LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
276 ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
277 SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
278
279 CODEC_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 \
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 \
317 adpcm_ima_qt \
318 adpcm_ms \
319 adpcm_yam \
320 adpcm_swf \
321 flac \
322 wma \
323 )
324
325 LAVF_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 )
361
362 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
363
364 CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
365 CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
366
367 LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
368
369 LAVF_REG = tests/data/lavf.regression
370 ROTOZOOM_REG = tests/data/rotozoom.regression
371 VSYNTH_REG = tests/data/vsynth.regression
372
373 codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
374 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
375 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
376
377 libavtest: $(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
393 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
394
395 $(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
396 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
397 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
398
399 $(LAVF_TESTS):
400 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
401
402 seektest: codectest libavtest tests/seek_test$(EXESUF)
403 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
404
405 test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
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
412 ifeq ($(CONFIG_SWSCALER),yes)
413 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
414 swscale_error:
415 @echo
416 @echo "This regression test is incompatible with --enable-swscaler."
417 @echo
418 @exit 1
419 endif
420
421 tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
422 mkdir -p tests/vsynth1
423 $(BUILD_ROOT)/$< 'tests/vsynth1/'
424
425 tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
426 mkdir -p tests/vsynth2
427 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
428
429 tests/asynth1.sw: tests/audiogen$(EXESUF)
430 $(BUILD_ROOT)/$< $@
431
432 %$(EXESUF): %.c
433 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
434
435 tests/seek_test$(EXESUF): tests/seek_test.c .libs
436 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
437
438
439 .PHONY: all lib videohook documentation install* wininstaller uninstall*
440 .PHONY: dep depend clean distclean TAGS
441 .PHONY: codectest libavtest seektest test-server fulltest test
442 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
443
444 -include .depend
445 -include .vhookdep