Use common.mak in the top-level Makefile as well.
[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
a426bbfc
MR
7SRC_DIR = $(SRC_PATH_BARE)
8
de2f77d8
MR
9vpath %.c $(SRC_PATH_BARE)
10vpath %.h $(SRC_PATH_BARE)
11vpath %.texi $(SRC_PATH_BARE)
dd9ca370 12
0cb8579a
MR
13PROGS-$(CONFIG_FFMPEG) += ffmpeg
14PROGS-$(CONFIG_FFPLAY) += ffplay
15PROGS-$(CONFIG_FFSERVER) += ffserver
01310af2 16
bb8fe69a
DB
17PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
18PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
916dafd5 19PROGS_SRCS = $(addsuffix .c, $(PROGS-yes)) cmdutils.c
bb8fe69a 20MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
85f07f22 21
bb8fe69a
DB
22BASENAMES = ffmpeg ffplay ffserver
23ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
24ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
25ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
6b991cb2 26
0fd94442 27ifeq ($(BUILD_SHARED),yes)
c721d803 28DEP_LIBS=libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavdevice/$(SLIBPREF)avdevice$(SLIBSUF)
0fd94442 29else
c721d803 30DEP_LIBS=libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavdevice/$(LIBPREF)avdevice$(LIBSUF)
f02be79d
RS
31endif
32
7d6ac9a3
MR
33ALL_TARGETS-$(CONFIG_VHOOK) += videohook
34ALL_TARGETS-$(BUILD_DOC) += documentation
35
36INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
1217916b
DB
37ifneq ($(PROGS),)
38INSTALL_TARGETS-yes += install-progs
282db5fd 39INSTALL_TARGETS-$(BUILD_DOC) += install-man
1217916b 40endif
dd9f3d97 41
27217159
DB
42main: lib $(PROGS_G) $(PROGS) $(ALL_TARGETS-yes)
43
44%$(EXESUF): %_g$(EXESUF)
45 cp -p $< $@
46 $(STRIP) $@
47
48vhook/%.o: vhook/%.c
49 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
50
7716f7ff
DB
51.depend: version.h $(PROGS_SRCS)
52
53include common.mak
54
3b26ee47 55VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
dd9f3d97
MR
56
57BASEHOOKS = fish null watermark
58ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
59ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
60
61HOOKS-$(HAVE_FORK) += ppm
62HOOKS-$(HAVE_IMLIB2) += imlib2
63HOOKS-$(HAVE_FREETYPE2) += drawtext
64
65HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
66
67VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
cbefadbd 68LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
dd9f3d97
MR
69
70VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
cbefadbd 71LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
dd9f3d97
MR
72
73VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
142fc6b9 74
f4428f99 75LDFLAGS := -L$(BUILD_ROOT)/libavdevice -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil -g $(LDFLAGS)
c721d803 76EXTRALIBS := -lavdevice$(BUILDSUF) -lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)
57514323 77
13ca50f3 78ifeq ($(CONFIG_SWSCALE),yes)
06694949 79LDFLAGS+=-L$(BUILD_ROOT)/libswscale
6de9e506 80EXTRALIBS+=-lswscale$(BUILDSUF)
790c9ca7
LA
81endif
82
f7679c54
VS
83ifeq ($(CONFIG_AVFILTER),yes)
84LDFLAGS+=-L$(BUILD_ROOT)/libavfilter
85EXTRALIBS := -lavfilter$(BUILDSUF) $(EXTRALIBS)
86endif
87
a11f43a4
MR
88MAKE-yes = $(MAKE)
89MAKE- = : $(MAKE)
90
951bf3e6 91lib:
20963a71
MR
92 $(MAKE) -C libavutil all
93 $(MAKE) -C libavcodec all
94 $(MAKE) -C libavformat all
95 $(MAKE) -C libavdevice all
4a24ab64 96 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc all
13ca50f3 97 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale all
f7679c54 98 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter all
85f07f22 99
b1b18481
DB
100ffplay_g$(EXESUF): EXTRALIBS += $(SDL_LIBS)
101ffserver_g$(EXESUF): LDFLAGS += $(FFSERVERLDFLAGS)
85f07f22 102
b1b18481
DB
103%_g$(EXESUF): %.o cmdutils.o .libs
104 $(CC) $(LDFLAGS) -o $@ $< cmdutils.o $(EXTRALIBS)
01310af2 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
3c889b5c 120ffplay.o .depend: CFLAGS += $(SDL_CFLAGS)
2744a37f 121
496cfa3c
MR
122ffmpeg.o ffplay.o ffserver.o: version.h
123
bab785a5
DB
124# vhooks compile fine without libav*, but need them nonetheless.
125videohook: .libs $(HOOKS)
ed5614eb
DB
126
127vhook/%$(SLIBSUF): vhook/%.o
3b26ee47 128 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
ed5614eb 129
e9b19db8 130documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
d0e1cd3d
DB
131 ffplay-doc.html general.html hooks.html \
132 $(ALLMANPAGES))
e9b19db8
DB
133
134doc/%.html: doc/%.texi
135 texi2html -monolithic -number $<
136 mv $(@F) $@
137
138doc/%.pod: doc/%-doc.texi
139 doc/texi2pod.pl $< $@
140
141doc/%.1: doc/%.pod
142 pod2man --section=1 --center=" " --release=" " $< > $@
146ea952 143
a4848db6 144ifeq ($(BUILD_SHARED),yes)
e1a3a63f 145install-progs: install-libs
a4848db6 146endif
c4fa7ebc 147install-progs: $(PROGS)
22a324da
DB
148 install -d "$(BINDIR)"
149 install -c -m 755 $(PROGS) "$(BINDIR)"
85f07f22 150
23a65308 151install-man:
22a324da
DB
152 install -d "$(MANDIR)/man1"
153 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
23a65308 154
ed5614eb 155install-vhook: videohook
22a324da
DB
156 install -d "$(SHLIBDIR)/vhook"
157 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
142fc6b9 158
b12f8273 159install-libs:
20963a71
MR
160 $(MAKE) -C libavutil install-libs
161 $(MAKE) -C libavcodec install-libs
162 $(MAKE) -C libavformat install-libs
163 $(MAKE) -C libavdevice install-libs
4a24ab64 164 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
13ca50f3 165 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale install-libs
3d323571 166 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
37736979 167
7716f7ff 168install-headers::
61c51088
DB
169 $(MAKE) -C libavutil install-headers
170 $(MAKE) -C libavcodec install-headers
171 $(MAKE) -C libavformat install-headers
172 $(MAKE) -C libavdevice install-headers
4a24ab64 173 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
61c51088 174 $(MAKE) -C libswscale install-headers
f7679c54 175 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
f29f3b5d 176
7716f7ff 177uninstall: uninstall-progs uninstall-man uninstall-vhook
f9edb717 178
f9edb717 179uninstall-progs:
1c2211bd 180 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
f9edb717 181
f9edb717 182uninstall-man:
1c2211bd 183 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
f9edb717
DB
184
185uninstall-vhook:
1c2211bd 186 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
22a324da 187 -rmdir "$(SHLIBDIR)/vhook/"
f9edb717 188
7716f7ff 189uninstall-libs::
f9edb717
DB
190 $(MAKE) -C libavutil uninstall-libs
191 $(MAKE) -C libavcodec uninstall-libs
192 $(MAKE) -C libavformat uninstall-libs
c721d803 193 $(MAKE) -C libavdevice uninstall-libs
6d9a2421 194 $(MAKE) -C libpostproc uninstall-libs
65f37992 195 $(MAKE) -C libswscale uninstall-libs
f7679c54 196 $(MAKE) -C libavfilter uninstall-libs
f9edb717 197
7716f7ff 198uninstall-headers::
f9edb717
DB
199 $(MAKE) -C libavutil uninstall-headers
200 $(MAKE) -C libavcodec uninstall-headers
201 $(MAKE) -C libavformat uninstall-headers
c721d803 202 $(MAKE) -C libavdevice uninstall-headers
6d9a2421 203 $(MAKE) -C libpostproc uninstall-headers
65f37992 204 $(MAKE) -C libswscale uninstall-headers
f7679c54 205 $(MAKE) -C libavfilter uninstall-headers
22a324da 206 -rmdir "$(INCDIR)"
f9edb717 207
7716f7ff 208depend dep: .vhookdep
20963a71
MR
209 $(MAKE) -C libavutil depend
210 $(MAKE) -C libavcodec depend
211 $(MAKE) -C libavformat depend
212 $(MAKE) -C libavdevice depend
4a24ab64 213 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
13ca50f3 214 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale depend
f7679c54 215 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
4b8b2edb 216
fc900b7b 217.vhookdep: $(ALLHOOKS_SRCS) version.h
315c741d 218 $(VHOOK_DEPEND_CMD) > $@
57514323 219
da34f7ac
MR
220$(DEP_LIBS): lib
221
222.libs: $(DEP_LIBS)
223 touch $@
cf2818b0 224
7716f7ff 225clean::
5d22ccf7
DB
226 $(MAKE) -C libavutil clean
227 $(MAKE) -C libavcodec clean
abac6175 228 $(MAKE) -C libavformat clean
c721d803 229 $(MAKE) -C libavdevice clean
6d9a2421 230 $(MAKE) -C libpostproc clean
790c9ca7 231 $(MAKE) -C libswscale clean
f7679c54 232 $(MAKE) -C libavfilter clean
7716f7ff 233 rm -f .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
2b258bba 234 output_example$(EXESUF)
e9b19db8 235 rm -f doc/*.html doc/*.pod doc/*.1
4fbd52f0
DB
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))
2b258bba 238 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
ed5614eb 239 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
142fc6b9 240
7716f7ff 241distclean::
98013cc1
DB
242 $(MAKE) -C libavutil distclean
243 $(MAKE) -C libavcodec distclean
244 $(MAKE) -C libavformat distclean
c721d803 245 $(MAKE) -C libavdevice distclean
6d9a2421 246 $(MAKE) -C libpostproc distclean
790c9ca7 247 $(MAKE) -C libswscale distclean
f7679c54 248 $(MAKE) -C libavfilter distclean
7716f7ff 249 rm -f .vhookdep version.h config.* *.pc
85f07f22
FB
250
251TAGS:
abac6175 252 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
57514323 253
dd9ca370
FB
254# regression tests
255
4fbd52f0 256fulltest test: codectest libavtest seektest
4fbd52f0
DB
257
258FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
259FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
260LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
261ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
262SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
263
4383ed5c
MR
264CODEC_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 \
4383ed5c
MR
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 \
9dc92a38 302 adpcm_ima_qt \
4383ed5c
MR
303 adpcm_ms \
304 adpcm_yam \
305 adpcm_swf \
306 flac \
307 wma \
308 )
309
2009721d
MR
310LAVF_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 )
4383ed5c
MR
346
347REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
348
349CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
350CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
351
352LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
353
354LAVF_REG = tests/data/lavf.regression
355ROTOZOOM_REG = tests/data/rotozoom.regression
356VSYNTH_REG = tests/data/vsynth.regression
357
358codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
4411cb11
MR
359 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
360 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
4383ed5c
MR
361
362libavtest: $(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
378regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
379
380$(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
2009721d
MR
381 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
382 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
4383ed5c
MR
383
384$(LAVF_TESTS):
2009721d 385 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
4383ed5c
MR
386
387seektest: codectest libavtest tests/seek_test$(EXESUF)
388 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
389
b13cdd33 390test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
4fbd52f0
DB
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
13ca50f3 397ifeq ($(CONFIG_SWSCALE),yes)
4383ed5c 398test-server codectest $(CODEC_TESTS) libavtest: swscale_error
4fbd52f0
DB
399swscale_error:
400 @echo
13ca50f3 401 @echo "This regression test is incompatible with --enable-swscale."
4fbd52f0
DB
402 @echo
403 @exit 1
404endif
405
406tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
407 mkdir -p tests/vsynth1
408 $(BUILD_ROOT)/$< 'tests/vsynth1/'
409
410tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
411 mkdir -p tests/vsynth2
412 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
413
414tests/asynth1.sw: tests/audiogen$(EXESUF)
415 $(BUILD_ROOT)/$< $@
416
417%$(EXESUF): %.c
418 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
419
06396e11 420tests/seek_test$(EXESUF): tests/seek_test.c .libs
ff21c1b0 421 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
4fbd52f0 422
dd9ca370 423
7716f7ff 424.PHONY: lib videohook documentation TAGS
5e2dfd39 425.PHONY: codectest libavtest seektest test-server fulltest test
4383ed5c 426.PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
cf2818b0 427
3b26ee47 428-include .vhookdep