generate separate dependency files per object file
[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 9vpath %.texi $(SRC_PATH_BARE)
dd9ca370 10
0cb8579a
MR
11PROGS-$(CONFIG_FFMPEG) += ffmpeg
12PROGS-$(CONFIG_FFPLAY) += ffplay
13PROGS-$(CONFIG_FFSERVER) += ffserver
01310af2 14
bb8fe69a
DB
15PROGS = $(addsuffix $(EXESUF), $(PROGS-yes))
16PROGS_G = $(addsuffix _g$(EXESUF), $(PROGS-yes))
caec74dd 17OBJS = $(addsuffix .o, $(PROGS-yes)) cmdutils.o
bb8fe69a 18MANPAGES = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
85f07f22 19
bb8fe69a
DB
20BASENAMES = ffmpeg ffplay ffserver
21ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
22ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
23ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
6b991cb2 24
b8fcb619
MR
25FFLIBS-$(CONFIG_AVFILTER) += avfilter
26FFLIBS-$(CONFIG_POSTPROC) += postproc
27FFLIBS-$(CONFIG_SWSCALE) += swscale
43527e3e 28
b8fcb619 29FFLIBS := avdevice avformat avcodec avutil
f02be79d 30
71c61f62
MR
31include common.mak
32
33FF_LDFLAGS := $(FFLDFLAGS)
34FF_EXTRALIBS := $(FFEXTRALIBS)
35
36S := $(BUILD_SHARED:yes=S)
37DEP_LIBS := $(foreach L,$(FFLIBS),lib$(L)/$($(S)LIBPREF)$(L)$($(S)LIBSUF))
38
7d6ac9a3
MR
39ALL_TARGETS-$(CONFIG_VHOOK) += videohook
40ALL_TARGETS-$(BUILD_DOC) += documentation
41
42INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
1217916b
DB
43ifneq ($(PROGS),)
44INSTALL_TARGETS-yes += install-progs
282db5fd 45INSTALL_TARGETS-$(BUILD_DOC) += install-man
1217916b 46endif
dfd10838 47INSTALL_PROGS_TARGETS-$(BUILD_SHARED) = install-libs
dd9f3d97 48
71c61f62 49all: $(DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
27217159 50
473a88ca 51$(PROGS): %$(EXESUF): %_g$(EXESUF)
27217159
DB
52 cp -p $< $@
53 $(STRIP) $@
54
71c61f62 55SUBDIR_VARS := OBJS ASM_OBJS CPP_OBJS FFLIBS CLEANFILES
9bcc2883 56
71c61f62
MR
57define RESET
58$(1) :=
59$(1)-yes :=
60endef
7716f7ff 61
71c61f62
MR
62define DOSUBDIR
63$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
64SUBDIR := $(1)/
65include $(1)/Makefile
66endef
67
68$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
b8fcb619 69
71c61f62
MR
70ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
71ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
85f07f22 72
71c61f62
MR
73%_g$(EXESUF): %.o cmdutils.o $(DEP_LIBS)
74 $(CC) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
01310af2 75
a4da50e1
MR
76SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
77ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
78version.h: $(SVN_ENTRIES)
79endif
80
f1cc88a5 81version.h:
997baf01 82 $(SRC_PATH)/version.sh $(SRC_PATH)
f1cc88a5 83
71c61f62
MR
84output_example$(EXESUF): output_example.o $(DEP_LIBS)
85 $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
8de65d4f 86
1521c500 87tools/%$(EXESUF): tools/%.c
71c61f62 88 $(CC) $(CFLAGS) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
6da7cc81 89
caec74dd 90ffplay.o: CFLAGS += $(SDL_CFLAGS)
496cfa3c 91
465d9b1f
MR
92VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
93
94BASEHOOKS = fish null watermark
95ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
96ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
97
98HOOKS-$(HAVE_FORK) += ppm
99HOOKS-$(HAVE_IMLIB2) += imlib2
100HOOKS-$(HAVE_FREETYPE2) += drawtext
101
102HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
103
104VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
105LIBS_imlib2$(SLIBSUF) = `imlib2-config --libs`
106
107VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
108LIBS_drawtext$(SLIBSUF) = `freetype-config --libs`
109
110VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
111
caec74dd 112vhook/%.o vhook/%.d: CFLAGS:=$(VHOOKCFLAGS)
465d9b1f 113
bab785a5 114# vhooks compile fine without libav*, but need them nonetheless.
71c61f62 115videohook: $(DEP_LIBS) $(HOOKS)
ed5614eb
DB
116
117vhook/%$(SLIBSUF): vhook/%.o
3b26ee47 118 $(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
ed5614eb 119
caec74dd
MR
120VHOOK_DEPS = $(HOOKS:$(SLIBSUF)=.d)
121depend dep: $(VHOOK_DEPS)
465d9b1f 122
e9b19db8 123documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
d0e1cd3d
DB
124 ffplay-doc.html general.html hooks.html \
125 $(ALLMANPAGES))
e9b19db8
DB
126
127doc/%.html: doc/%.texi
128 texi2html -monolithic -number $<
129 mv $(@F) $@
130
131doc/%.pod: doc/%-doc.texi
132 doc/texi2pod.pl $< $@
133
134doc/%.1: doc/%.pod
135 pod2man --section=1 --center=" " --release=" " $< > $@
146ea952 136
a7319cc2
DB
137install: $(INSTALL_TARGETS-yes)
138
c1ac39b3 139install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
22a324da
DB
140 install -d "$(BINDIR)"
141 install -c -m 755 $(PROGS) "$(BINDIR)"
85f07f22 142
d05e360c 143install-man: $(MANPAGES)
22a324da
DB
144 install -d "$(MANDIR)/man1"
145 install -m 644 $(MANPAGES) "$(MANDIR)/man1"
23a65308 146
ed5614eb 147install-vhook: videohook
22a324da
DB
148 install -d "$(SHLIBDIR)/vhook"
149 install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
142fc6b9 150
7716f7ff 151uninstall: uninstall-progs uninstall-man uninstall-vhook
f9edb717 152
f9edb717 153uninstall-progs:
1c2211bd 154 rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
f9edb717 155
f9edb717 156uninstall-man:
1c2211bd 157 rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
f9edb717
DB
158
159uninstall-vhook:
1c2211bd 160 rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
22a324da 161 -rmdir "$(SHLIBDIR)/vhook/"
f9edb717 162
7716f7ff 163clean::
71c61f62 164 rm -f gmon.out TAGS $(ALLPROGS) $(ALLPROGS_G) \
2b258bba 165 output_example$(EXESUF)
e9b19db8 166 rm -f doc/*.html doc/*.pod doc/*.1
4fbd52f0
DB
167 rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
168 rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
2b258bba 169 rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
ed5614eb 170 rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
142fc6b9 171
7716f7ff 172distclean::
caec74dd 173 rm -f version.h config.* *.pc vhook/*.d
85f07f22 174
dd9ca370
FB
175# regression tests
176
4fbd52f0 177fulltest test: codectest libavtest seektest
4fbd52f0
DB
178
179FFMPEG_REFFILE = $(SRC_PATH)/tests/ffmpeg.regression.ref
180FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
181LIBAV_REFFILE = $(SRC_PATH)/tests/libav.regression.ref
182ROTOZOOM_REFFILE = $(SRC_PATH)/tests/rotozoom.regression.ref
183SEEK_REFFILE = $(SRC_PATH)/tests/seek.regression.ref
184
4383ed5c
MR
185CODEC_TESTS = $(addprefix regtest-, \
186 mpeg \
187 mpeg2 \
188 mpeg2thread \
189 msmpeg4v2 \
190 msmpeg4 \
191 wmv1 \
192 wmv2 \
193 h261 \
194 h263 \
195 h263p \
196 mpeg4 \
197 huffyuv \
198 rc \
199 mpeg4adv \
200 mpeg4thread \
4383ed5c
MR
201 error \
202 mpeg4nr \
203 mpeg1b \
204 mjpeg \
205 ljpeg \
206 jpegls \
207 rv10 \
208 rv20 \
209 asv1 \
210 asv2 \
211 flv \
212 ffv1 \
213 snow \
214 snowll \
215 dv \
216 dv50 \
217 svq1 \
218 flashsv \
219 mp2 \
220 ac3 \
221 g726 \
222 adpcm_ima_wav \
9dc92a38 223 adpcm_ima_qt \
4383ed5c
MR
224 adpcm_ms \
225 adpcm_yam \
226 adpcm_swf \
227 flac \
228 wma \
229 )
230
2009721d
MR
231LAVF_TESTS = $(addprefix regtest-, \
232 avi \
233 asf \
234 rm \
235 mpg \
236 ts \
237 swf \
238 ffm \
239 flv_fmt \
240 mov \
241 dv_fmt \
242 gxf \
243 nut \
244 mkv \
245 pbmpipe \
246 pgmpipe \
247 ppmpipe \
248 gif \
249 yuv4mpeg \
250 pgm \
251 ppm \
252 bmp \
253 tga \
254 tiff \
255 sgi \
256 jpg \
257 wav \
258 alaw \
259 mulaw \
260 au \
261 mmf \
262 aiff \
263 voc \
264 ogg \
265 pixfmt \
266 )
4383ed5c
MR
267
268REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
269
270CODEC_ROTOZOOM = $(call REGFILES,rotozoom.regression,$(CODEC_TESTS))
271CODEC_VSYNTH = $(call REGFILES,vsynth.regression,$(CODEC_TESTS))
272
273LAVF_REGFILES = $(call REGFILES,lavf.regression,$(LAVF_TESTS))
274
275LAVF_REG = tests/data/lavf.regression
276ROTOZOOM_REG = tests/data/rotozoom.regression
277VSYNTH_REG = tests/data/vsynth.regression
278
279codectest: $(VSYNTH_REG) $(ROTOZOOM_REG)
4411cb11
MR
280 diff -u -w $(FFMPEG_REFFILE) $(VSYNTH_REG)
281 diff -u -w $(ROTOZOOM_REFFILE) $(ROTOZOOM_REG)
4383ed5c
MR
282
283libavtest: $(LAVF_REG)
284 diff -u -w $(LIBAV_REFFILE) $(LAVF_REG)
285
286$(VSYNTH_REG) $(ROTOZOOM_REG) $(LAVF_REG):
287 cat $^ > $@
288
289$(LAVF_REG): $(LAVF_REGFILES)
290$(ROTOZOOM_REG): $(CODEC_ROTOZOOM)
291$(VSYNTH_REG): $(CODEC_VSYNTH)
292
293$(CODEC_VSYNTH) $(CODEC_ROTOZOOM): $(CODEC_TESTS)
294
295$(LAVF_REGFILES): $(LAVF_TESTS)
296
297$(CODEC_TESTS) $(LAVF_TESTS): regtest-ref
298
299regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
300
301$(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
2009721d
MR
302 $(SRC_PATH)/tests/regression.sh $@ vsynth tests/vsynth1 a
303 $(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a
4383ed5c
MR
304
305$(LAVF_TESTS):
2009721d 306 $(SRC_PATH)/tests/regression.sh $@ lavf tests/vsynth1 b
4383ed5c
MR
307
308seektest: codectest libavtest tests/seek_test$(EXESUF)
309 $(SRC_PATH)/tests/seek_test.sh $(SEEK_REFFILE)
310
b13cdd33 311test-server: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/asynth1.sw
4fbd52f0
DB
312 @echo
313 @echo "Unfortunately ffserver is broken and therefore its regression"
314 @echo "test fails randomly. Treat the results accordingly."
315 @echo
316 $(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
317
13ca50f3 318ifeq ($(CONFIG_SWSCALE),yes)
4383ed5c 319test-server codectest $(CODEC_TESTS) libavtest: swscale_error
4fbd52f0
DB
320swscale_error:
321 @echo
13ca50f3 322 @echo "This regression test is incompatible with --enable-swscale."
4fbd52f0
DB
323 @echo
324 @exit 1
325endif
326
327tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
328 mkdir -p tests/vsynth1
329 $(BUILD_ROOT)/$< 'tests/vsynth1/'
330
331tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
332 mkdir -p tests/vsynth2
333 $(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
334
335tests/asynth1.sw: tests/audiogen$(EXESUF)
336 $(BUILD_ROOT)/$< $@
337
338%$(EXESUF): %.c
71c61f62 339 $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $<
4fbd52f0 340
71c61f62
MR
341tests/seek_test$(EXESUF): tests/seek_test.c $(DEP_LIBS)
342 $(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $< $(FF_EXTRALIBS)
4fbd52f0 343
dd9ca370 344
7716f7ff 345.PHONY: lib videohook documentation TAGS
5e2dfd39 346.PHONY: codectest libavtest seektest test-server fulltest test
4383ed5c 347.PHONY: $(CODEC_TESTS) $(LAVF_TESTS) regtest-ref swscale-error
cf2818b0 348
caec74dd 349-include $(VHOOK_DEPS)