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