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