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