Move dependency generation commands into configure.
[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
13ca50f3 69ifeq ($(CONFIG_SWSCALE),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
13ca50f3 90 $(MAKE-$(CONFIG_SWSCALE)) -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
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
3b26ee47
MR
130vhook/%.o: vhook/%.c
131 $(CC) $(VHOOKCFLAGS) -c -o $@ $<
132
133%.o: %.c
134 $(CC) $(CFLAGS) -c -o $@ $<
142fc6b9 135
e9b19db8 136documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
d0e1cd3d
DB
137 ffplay-doc.html general.html hooks.html \
138 $(ALLMANPAGES))
e9b19db8
DB
139
140doc/%.html: doc/%.texi
141 texi2html -monolithic -number $<
142 mv $(@F) $@
143
144doc/%.pod: doc/%-doc.texi
145 doc/texi2pod.pl $< $@
146
147doc/%.1: doc/%.pod
148 pod2man --section=1 --center=" " --release=" " $< > $@
146ea952 149
1217916b 150install: install-libs install-headers $(INSTALL_TARGETS-yes)
81dcdc53 151
a4848db6 152ifeq ($(BUILD_SHARED),yes)
e1a3a63f 153install-progs: install-libs
a4848db6 154endif
c4fa7ebc 155install-progs: $(PROGS)
22a324da
DB
156 install -d "$(BINDIR)"
157 install -c -m 755 $(PROGS) "$(BINDIR)"
85f07f22 158
23a65308 159install-man:
22a324da
DB
160 install -d "$(MANDIR)/man1"
161 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
23a65308 162
ed5614eb 163install-vhook: videohook
22a324da
DB
164 install -d "$(SHLIBDIR)/vhook"
165 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
142fc6b9 166
b12f8273 167install-libs:
20963a71
MR
168 $(MAKE) -C libavutil install-libs
169 $(MAKE) -C libavcodec install-libs
170 $(MAKE) -C libavformat install-libs
171 $(MAKE) -C libavdevice install-libs
4a24ab64 172 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-libs
13ca50f3 173 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale install-libs
3d323571 174 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-libs
37736979 175
f29f3b5d 176install-headers:
61c51088
DB
177 $(MAKE) -C libavutil install-headers
178 $(MAKE) -C libavcodec install-headers
179 $(MAKE) -C libavformat install-headers
180 $(MAKE) -C libavdevice install-headers
4a24ab64 181 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc install-headers
61c51088 182 $(MAKE) -C libswscale install-headers
f7679c54 183 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter install-headers
f29f3b5d 184
f9edb717
DB
185uninstall: uninstall-progs uninstall-libs uninstall-headers uninstall-man uninstall-vhook
186
f9edb717 187uninstall-progs:
1c2211bd 188 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
f9edb717 189
f9edb717 190uninstall-man:
1c2211bd 191 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
f9edb717
DB
192
193uninstall-vhook:
1c2211bd 194 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
22a324da 195 -rmdir "$(SHLIBDIR)/vhook/"
f9edb717
DB
196
197uninstall-libs:
198 $(MAKE) -C libavutil uninstall-libs
199 $(MAKE) -C libavcodec uninstall-libs
200 $(MAKE) -C libavformat uninstall-libs
c721d803 201 $(MAKE) -C libavdevice uninstall-libs
6d9a2421 202 $(MAKE) -C libpostproc uninstall-libs
65f37992 203 $(MAKE) -C libswscale uninstall-libs
f7679c54 204 $(MAKE) -C libavfilter uninstall-libs
f9edb717
DB
205
206uninstall-headers:
207 $(MAKE) -C libavutil uninstall-headers
208 $(MAKE) -C libavcodec uninstall-headers
209 $(MAKE) -C libavformat uninstall-headers
c721d803 210 $(MAKE) -C libavdevice uninstall-headers
6d9a2421 211 $(MAKE) -C libpostproc uninstall-headers
65f37992 212 $(MAKE) -C libswscale uninstall-headers
f7679c54 213 $(MAKE) -C libavfilter uninstall-headers
22a324da 214 -rmdir "$(INCDIR)"
f9edb717 215
3b26ee47 216depend dep: .depend .vhookdep
20963a71
MR
217 $(MAKE) -C libavutil depend
218 $(MAKE) -C libavcodec depend
219 $(MAKE) -C libavformat depend
220 $(MAKE) -C libavdevice depend
4a24ab64 221 $(MAKE-$(CONFIG_POSTPROC)) -C libpostproc depend
13ca50f3 222 $(MAKE-$(CONFIG_SWSCALE)) -C libswscale depend
f7679c54 223 $(MAKE-$(CONFIG_AVFILTER)) -C libavfilter depend
4b8b2edb 224
fd071c26 225.depend: $(SRCS) version.h
315c741d 226 $(DEPEND_CMD) > $@
3b26ee47 227
fc900b7b 228.vhookdep: $(ALLHOOKS_SRCS) version.h
315c741d 229 $(VHOOK_DEPEND_CMD) > $@
57514323 230
da34f7ac
MR
231$(DEP_LIBS): lib
232
233.libs: $(DEP_LIBS)
234 touch $@
cf2818b0 235
98013cc1 236clean:
5d22ccf7
DB
237 $(MAKE) -C libavutil clean
238 $(MAKE) -C libavcodec clean
abac6175 239 $(MAKE) -C libavformat clean
c721d803 240 $(MAKE) -C libavdevice clean
6d9a2421 241 $(MAKE) -C libpostproc clean
790c9ca7 242 $(MAKE) -C libswscale clean
f7679c54 243 $(MAKE) -C libavfilter clean
b8d40825 244 rm -f *.o *~ .libs gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
2b258bba 245 output_example$(EXESUF)
e9b19db8 246 rm -f doc/*.html doc/*.pod doc/*.1
4fbd52f0
DB
247 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
248 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
2b258bba 249 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
ed5614eb 250 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
142fc6b9 251
85f07f22 252distclean: clean
98013cc1
DB
253 $(MAKE) -C libavutil distclean
254 $(MAKE) -C libavcodec distclean
255 $(MAKE) -C libavformat distclean
c721d803 256 $(MAKE) -C libavdevice distclean
6d9a2421 257 $(MAKE) -C libpostproc distclean
790c9ca7 258 $(MAKE) -C libswscale distclean
f7679c54 259 $(MAKE) -C libavfilter distclean
2c8c5021 260 rm -f .depend .vhookdep version.h config.* *.pc
85f07f22
FB
261
262TAGS:
abac6175 263 etags *.[ch] libavformat/*.[ch] libavcodec/*.[ch]
57514323 264
dd9ca370
FB
265# regression tests
266
4fbd52f0 267fulltest test: codectest libavtest seektest
4fbd52f0
DB
268
269FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
270FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
271LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
272ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
273SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
274
4383ed5c
MR
275CODEC_TESTS = $(addprefix regtest-, \
276 mpeg \
277 mpeg2 \
278 mpeg2thread \
279 msmpeg4v2 \
280 msmpeg4 \
281 wmv1 \
282 wmv2 \
283 h261 \
284 h263 \
285 h263p \
286 mpeg4 \
287 huffyuv \
288 rc \
289 mpeg4adv \
290 mpeg4thread \
4383ed5c
MR
291 error \
292 mpeg4nr \
293 mpeg1b \
294 mjpeg \
295 ljpeg \
296 jpegls \
297 rv10 \
298 rv20 \
299 asv1 \
300 asv2 \
301 flv \
302 ffv1 \
303 snow \
304 snowll \
305 dv \
306 dv50 \
307 svq1 \
308 flashsv \
309 mp2 \
310 ac3 \
311 g726 \
312 adpcm_ima_wav \
9dc92a38 313 adpcm_ima_qt \
4383ed5c
MR
314 adpcm_ms \
315 adpcm_yam \
316 adpcm_swf \
317 flac \
318 wma \
319 )
320
2009721d
MR
321LAVF_TESTS = $(addprefix regtest-, \
322 avi \
323 asf \
324 rm \
325 mpg \
326 ts \
327 swf \
328 ffm \
329 flv_fmt \
330 mov \
331 dv_fmt \
332 gxf \
333 nut \
334 mkv \
335 pbmpipe \
336 pgmpipe \
337 ppmpipe \
338 gif \
339 yuv4mpeg \
340 pgm \
341 ppm \
342 bmp \
343 tga \
344 tiff \
345 sgi \
346 jpg \
347 wav \
348 alaw \
349 mulaw \
350 au \
351 mmf \
352 aiff \
353 voc \
354 ogg \
355 pixfmt \
356 )
4383ed5c
MR
357
358REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
359
360CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
361CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
362
363LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
364
365LAVF_REG = tests/data/lavf.regression
366ROTOZOOM_REG = tests/data/rotozoom.regression
367VSYNTH_REG = tests/data/vsynth.regression
368
369codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
4411cb11
MR
370 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
371 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
4383ed5c
MR
372
373libavtest: $(LAVF_REG)
374 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
375
376$(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
377 cat $^ > $@
378
379$(LAVF_REG): $(LAVF_REGFILES)
380$(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
381$(VSYNTH_REG): $(CODEC_VSYNTH)
382
383$(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
384
385$(LAVF_REGFILES): $(LAVF_TESTS)
386
387$(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
388
389regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
390
391$(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
2009721d
MR
392 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
393 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
4383ed5c
MR
394
395$(LAVF_TESTS):
2009721d 396 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
4383ed5c
MR
397
398seektest: codectest libavtest tests/seek_test$(EXESUF)
399 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
400
b13cdd33 401test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
4fbd52f0
DB
402 @echo
403 @echo "Unfortunately ffserver is broken and therefore its regression"
404 @echo "test fails randomly. Treat the results accordingly."
405 @echo
406 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
407
13ca50f3 408ifeq ($(CONFIG_SWSCALE),yes)
4383ed5c 409test-server codectest $(CODEC_TESTS) libavtest: swscale_error
4fbd52f0
DB
410swscale_error:
411 @echo
13ca50f3 412 @echo "This regression test is incompatible with --enable-swscale."
4fbd52f0
DB
413 @echo
414 @exit 1
415endif
416
417tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
418 mkdir -p tests/vsynth1
419 $(BUILD_ROOT)/$< 'tests/vsynth1/'
420
421tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
422 mkdir -p tests/vsynth2
423 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
424
425tests/asynth1.sw: tests/audiogen$(EXESUF)
426 $(BUILD_ROOT)/$< $@
427
428%$(EXESUF): %.c
429 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $<
430
06396e11 431tests/seek_test$(EXESUF): tests/seek_test.c .libs
ff21c1b0 432 $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< $(EXTRALIBS)
4fbd52f0 433
dd9ca370 434
1b9cec96 435.PHONY: all lib videohook documentation install* uninstall*
bedb3550 436.PHONY: dep depend clean distclean TAGS
5e2dfd39 437.PHONY: codectest libavtest seektest test-server fulltest test
4383ed5c 438.PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
cf2818b0 439
6ca0c110 440-include .depend
3b26ee47 441-include .vhookdep