Use common.mak in the top-level Makefile as well.
[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 ifeq ($(BUILD_SHARED),yes)
28 DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
29 else
30 DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
31 endif
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
42 main: lib $(PROGS_G) $(PROGS) $(ALL_TARGETS-yes)
43
44 %$(EXESUF): %_g$(EXESUF)
45 cp -p $< $@
46 $(STRIP) $@
47
48 vhook/%.o: vhook/%.c
49 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
50
51 .depend: version.h $(PROGS_SRCS)
52
53 include common.mak
54
55 VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
56
57 BASEHOOKS = fish null watermark
58 ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
59 ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
60
61 HOOKS-$(HAVE_FORK) += ppm
62 HOOKS-$(HAVE_IMLIB2) += imlib2
63 HOOKS-$(HAVE_FREETYPE2) += drawtext
64
65 HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
66
67 VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
68 LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
69
70 VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
71 LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
72
73 VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
74
75 LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil -g $(LDFLAGS)
76 EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
77
78 ifeq ($(CONFIG_SWSCALE),yes)
79 LDFLAGS+=-L$(BUILD_ROOT)/libswscale
80 EXTRALIBS+=-lswscale$(BUILDSUF)
81 endif
82
83 ifeq ($(CONFIG_AVFILTER),yes)
84 LDFLAGS+=-L$(BUILD_ROOT)/libavfilter
85 EXTRALIBS := -lavfilter$(BUILDSUF) $(EXTRALIBS)
86 endif
87
88 MAKE-yes = $(MAKE)
89 MAKE- = : $(MAKE)
90
91 lib:
92 $(MAKE) -C libavutil all
93 $(MAKE) -C libavcodec all
94 $(MAKE) -C libavformat all
95 $(MAKE) -C libavdevice all
96 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
97 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale all
98 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
99
100 ffplay_g$(EXESUF): EXTRALIBS += $(SDL_LIBS)
101 ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
102
103 %_g$(EXESUF): %.o cmdutils.o .libs
104 $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
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 .depend: CFLAGS += $(SDL_CFLAGS)
121
122 ffmpeg.o ffplay.o ffserver.o: version.h
123
124 # vhooks compile fine without libav*, but need them nonetheless.
125 videohook: .libs $(HOOKS)
126
127 vhook/%$(SLIBSUF): vhook/%.o
128 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
129
130 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
131 ffplay-doc.html general.html hooks.html \
132 $(ALLMANPAGES))
133
134 doc/%.html: doc/%.texi
135 texi2html -monolithic -number $<
136 mv $(@F) $@
137
138 doc/%.pod: doc/%-doc.texi
139 doc/texi2pod.pl $< $@
140
141 doc/%.1: doc/%.pod
142 pod2man --section=1 --center=" " --release=" " $< > $@
143
144 ifeq ($(BUILD_SHARED),yes)
145 install-progs: install-libs
146 endif
147 install-progs: $(PROGS)
148 install -d "$(BINDIR)"
149 install -c -m 755 $(PROGS) "$(BINDIR)"
150
151 install-man:
152 install -d "$(MANDIR)/man1"
153 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
154
155 install-vhook: videohook
156 install -d "$(SHLIBDIR)/vhook"
157 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
158
159 install-libs:
160 $(MAKE) -C libavutil install-libs
161 $(MAKE) -C libavcodec install-libs
162 $(MAKE) -C libavformat install-libs
163 $(MAKE) -C libavdevice install-libs
164 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
165 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale install-libs
166 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
167
168 install-headers::
169 $(MAKE) -C libavutil install-headers
170 $(MAKE) -C libavcodec install-headers
171 $(MAKE) -C libavformat install-headers
172 $(MAKE) -C libavdevice install-headers
173 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
174 $(MAKE) -C libswscale install-headers
175 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
176
177 uninstall: uninstall-progs uninstall-man uninstall-vhook
178
179 uninstall-progs:
180 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
181
182 uninstall-man:
183 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
184
185 uninstall-vhook:
186 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
187 -rmdir "$(SHLIBDIR)/vhook/"
188
189 uninstall-libs::
190 $(MAKE) -C libavutil uninstall-libs
191 $(MAKE) -C libavcodec uninstall-libs
192 $(MAKE) -C libavformat uninstall-libs
193 $(MAKE) -C libavdevice uninstall-libs
194 $(MAKE) -C libpostproc uninstall-libs
195 $(MAKE) -C libswscale uninstall-libs
196 $(MAKE) -C libavfilter 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 $(MAKE) -C libavfilter uninstall-headers
206 -rmdir "$(INCDIR)"
207
208 depend dep: .vhookdep
209 $(MAKE) -C libavutil depend
210 $(MAKE) -C libavcodec depend
211 $(MAKE) -C libavformat depend
212 $(MAKE) -C libavdevice depend
213 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
214 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale depend
215 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
216
217 .vhookdep: $(ALLHOOKS_SRCS) version.h
218 $(VHOOK_DEPEND_CMD) > $@
219
220 $(DEP_LIBS): lib
221
222 .libs: $(DEP_LIBS)
223 touch $@
224
225 clean::
226 $(MAKE) -C libavutil clean
227 $(MAKE) -C libavcodec clean
228 $(MAKE) -C libavformat clean
229 $(MAKE) -C libavdevice clean
230 $(MAKE) -C libpostproc clean
231 $(MAKE) -C libswscale clean
232 $(MAKE) -C libavfilter clean
233 rm -f .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
234 output_example$(EXESUF)
235 rm -f doc/*.html doc/*.pod doc/*.1
236 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
237 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
238 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
239 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
240
241 distclean::
242 $(MAKE) -C libavutil distclean
243 $(MAKE) -C libavcodec distclean
244 $(MAKE) -C libavformat distclean
245 $(MAKE) -C libavdevice distclean
246 $(MAKE) -C libpostproc distclean
247 $(MAKE) -C libswscale distclean
248 $(MAKE) -C libavfilter distclean
249 rm -f .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 error \
281 mpeg4nr \
282 mpeg1b \
283 mjpeg \
284 ljpeg \
285 jpegls \
286 rv10 \
287 rv20 \
288 asv1 \
289 asv2 \
290 flv \
291 ffv1 \
292 snow \
293 snowll \
294 dv \
295 dv50 \
296 svq1 \
297 flashsv \
298 mp2 \
299 ac3 \
300 g726 \
301 adpcm_ima_wav \
302 adpcm_ima_qt \
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_SWSCALE),yes)
398 test-server codectest $(CODEC_TESTS) libavtest: swscale_error
399 swscale_error:
400 @echo
401 @echo "This regression test is incompatible with --enable-swscale."
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: lib videohook documentation TAGS
425 .PHONY: codectest libavtest seektest test-server fulltest test
426 .PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
427
428 -include .vhookdep