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