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