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