Skip adding SDL_CFLAGS to CFLAGS for the ffplay.d target.
[ffmpeg.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_FFPROBE)  += ffprobe
10 PROGS-$(CONFIG_FFSERVER) += ffserver
11
12 PROGS      := $(addsuffix   $(EXESUF), $(PROGS-yes))
13 PROGS_G     = $(addsuffix _g$(EXESUF), $(PROGS-yes))
14 OBJS        = $(addsuffix .o,          $(PROGS-yes)) cmdutils.o
15 MANPAGES    = $(addprefix doc/, $(addsuffix .1, $(PROGS-yes)))
16 HTMLPAGES   = $(addprefix doc/, $(addsuffix -doc.html, $(PROGS-yes)))
17 TOOLS       = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws pktdumper probetest qt-faststart trasher))
18 HOSTPROGS   = $(addprefix tests/, audiogen videogen rotozoom tiny_psnr base64)
19
20 BASENAMES   = ffmpeg ffplay ffprobe ffserver
21 ALLPROGS    = $(addsuffix   $(EXESUF), $(BASENAMES))
22 ALLPROGS_G  = $(addsuffix _g$(EXESUF), $(BASENAMES))
23 ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
24 ALLHTMLPAGES= $(addsuffix -doc.html, $(BASENAMES))
25
26 FFLIBS-$(CONFIG_AVDEVICE) += avdevice
27 FFLIBS-$(CONFIG_AVFILTER) += avfilter
28 FFLIBS-$(CONFIG_AVFORMAT) += avformat
29 FFLIBS-$(CONFIG_AVCODEC)  += avcodec
30 FFLIBS-$(CONFIG_POSTPROC) += postproc
31 FFLIBS-$(CONFIG_SWSCALE)  += swscale
32 FFLIBS-$(CONFIG_AVCORE)   += avcore
33
34 FFLIBS := avutil
35
36 DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
37
38 SKIPHEADERS = cmdutils_common_opts.h
39
40 include common.mak
41
42 FF_LDFLAGS   := $(FFLDFLAGS)
43 FF_EXTRALIBS := $(FFEXTRALIBS)
44 FF_DEP_LIBS  := $(DEP_LIBS)
45
46 ALL_TARGETS-$(CONFIG_DOC)       += documentation
47
48 ifdef PROGS
49 INSTALL_TARGETS-yes             += install-progs install-data
50 INSTALL_TARGETS-$(CONFIG_DOC)   += install-man
51 endif
52 INSTALL_PROGS_TARGETS-$(CONFIG_SHARED) = install-libs
53
54 all: $(FF_DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)
55
56 $(PROGS): %$(EXESUF): %_g$(EXESUF)
57         $(CP) $< $@
58         $(STRIP) $@
59
60 config.h: .config
61 .config: $(wildcard $(FFLIBS:%=$(SRC_DIR)/lib%/all*.c))
62         @-tput bold 2>/dev/null
63         @-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
64         @-tput sgr0 2>/dev/null
65
66 SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
67                ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
68                HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS
69
70 define RESET
71 $(1) :=
72 $(1)-yes :=
73 endef
74
75 define DOSUBDIR
76 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
77 SUBDIR := $(1)/
78 include $(1)/Makefile
79 endef
80
81 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
82
83 ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
84 ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
85
86 %_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
87         $(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
88
89 tools/%$(EXESUF): tools/%.o
90         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
91
92 tools/%.o: tools/%.c
93         $(CC) $(CPPFLAGS) $(CFLAGS) $(CC_O) $<
94
95 ffplay.o: CFLAGS += $(SDL_CFLAGS)
96
97 VERSION_SH  = $(SRC_PATH_BARE)/version.sh
98 GIT_LOG     = $(SRC_PATH_BARE)/.git/logs/HEAD
99 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
100
101 .version: $(wildcard $(GIT_LOG) $(SVN_ENTRIES)) $(VERSION_SH) config.mak
102 .version: M=@
103
104 version.h .version:
105         $(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
106         $(Q)touch .version
107
108 # force version.sh to run whenever version might have changed
109 -include .version
110
111 alltools: $(TOOLS)
112
113 documentation: $(addprefix doc/, developer.html faq.html general.html libavfilter.html \
114                                  $(ALLHTMLPAGES) $(ALLMANPAGES))
115
116 $(HTMLPAGES) $(MANPAGES): doc/fftools-common-opts.texi
117
118 doc/ffmpeg.pod doc/ffmpeg-doc.html: doc/indevs.texi doc/filters.texi doc/outdevs.texi doc/protocols.texi
119 doc/ffplay.pod doc/ffplay-doc.html: doc/indevs.texi doc/filters.texi doc/outdevs.texi doc/protocols.texi
120 doc/ffprobe.pod doc/ffprobe-doc.html: doc/indevs.texi doc/protocols.texi
121
122 doc/%.html: TAG = HTML
123 doc/%.html: doc/%.texi
124         $(M)cd doc && texi2html -monolithic -number $(<:doc/%=%)
125
126 doc/%.pod: TAG = POD
127 doc/%.pod: doc/%-doc.texi
128         $(M)doc/texi2pod.pl $< $@
129
130 doc/%.1: TAG = MAN
131 doc/%.1: doc/%.pod
132         $(M)pod2man --section=1 --center=" " --release=" " $< > $@
133
134 install: $(INSTALL_TARGETS-yes)
135
136 install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
137         $(Q)mkdir -p "$(BINDIR)"
138         $(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
139
140 install-data: $(DATA_FILES)
141         $(Q)mkdir -p "$(DATADIR)"
142         $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
143
144 install-man: $(MANPAGES)
145         $(Q)mkdir -p "$(MANDIR)/man1"
146         $(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
147
148 uninstall: uninstall-progs uninstall-data uninstall-man
149
150 uninstall-progs:
151         $(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
152
153 uninstall-data:
154         $(RM) -r "$(DATADIR)"
155
156 uninstall-man:
157         $(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
158
159 testclean:
160         $(RM) -r tests/vsynth1 tests/vsynth2 tests/data
161         $(RM) $(addprefix tests/,$(CLEANSUFFIXES))
162         $(RM) tests/seek_test$(EXESUF) tests/seek_test.o
163         $(RM) $(addprefix tests/,$(addsuffix $(HOSTEXESUF),audiogen videogen rotozoom tiny_psnr base64))
164
165 clean:: testclean
166         $(RM) $(ALLPROGS) $(ALLPROGS_G)
167         $(RM) $(CLEANSUFFIXES)
168         $(RM) doc/*.html doc/*.pod doc/*.1
169         $(RM) $(TOOLS)
170
171 distclean::
172         $(RM) $(DISTCLEANSUFFIXES)
173         $(RM) version.h config.* libavutil/avconfig.h
174
175 config:
176         $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
177
178 # regression tests
179
180 check: test checkheaders
181
182 fulltest test: codectest lavftest lavfitest seektest
183
184 FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
185 SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref
186
187 codectest: fate-codec
188 lavftest:  fate-lavf
189 lavfitest: fate-lavfi
190 seektest:  fate-seek
191
192 AREF = tests/data/acodec.ref.wav
193 VREF = tests/data/vsynth1.ref.yuv
194 REFS = $(AREF) $(VREF)
195
196 $(REFS): TAG = GEN
197
198 $(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm
199         $(M)$(SRC_PATH)/tests/codec-regression.sh vref vsynth1 tests/vsynth1 "$(TARGET_EXEC)" "$(TARGET_PATH)"
200         $(Q)$(SRC_PATH)/tests/codec-regression.sh vref vsynth2 tests/vsynth2 "$(TARGET_EXEC)" "$(TARGET_PATH)"
201
202 $(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw
203         $(M)$(SRC_PATH)/tests/codec-regression.sh aref acodec tests/acodec "$(TARGET_EXEC)" "$(TARGET_PATH)"
204
205 ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw
206         @echo
207         @echo "Unfortunately ffserver is broken and therefore its regression"
208         @echo "test fails randomly. Treat the results accordingly."
209         @echo
210         $(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf
211
212 tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
213         @mkdir -p tests/vsynth1
214         $(M)$(BUILD_ROOT)/$< 'tests/vsynth1/'
215
216 tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
217         @mkdir -p tests/vsynth2
218         $(M)$(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
219
220 tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
221         @mkdir -p tests/data
222         $(M)$(BUILD_ROOT)/$< $@
223
224 tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN
225
226 tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
227         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
228
229 tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS)
230         $(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
231
232 include $(SRC_PATH_BARE)/tests/fate.mak
233 include $(SRC_PATH_BARE)/tests/fate2.mak
234
235 include $(SRC_PATH_BARE)/tests/fate/aac.mak
236 include $(SRC_PATH_BARE)/tests/fate/als.mak
237 include $(SRC_PATH_BARE)/tests/fate/fft.mak
238 include $(SRC_PATH_BARE)/tests/fate/h264.mak
239 include $(SRC_PATH_BARE)/tests/fate/vorbis.mak
240 include $(SRC_PATH_BARE)/tests/fate/vp8.mak
241
242 FATE_TESTS += $(FATE2_TESTS)
243
244 FATE_ACODEC  = $(ACODEC_TESTS:%=fate-acodec-%)
245 FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%)
246 FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%)
247 FATE_VCODEC  = $(FATE_VSYNTH1) $(FATE_VSYNTH2)
248 FATE_LAVF    = $(LAVF_TESTS:%=fate-lavf-%)
249 FATE_LAVFI   = $(LAVFI_TESTS:%=fate-lavfi-%)
250 FATE_SEEK    = $(SEEK_TESTS:seek_%=fate-seek-%)
251
252 FATE = $(FATE_ACODEC)                                                   \
253        $(FATE_VCODEC)                                                   \
254        $(FATE_LAVF)                                                     \
255        $(FATE_LAVFI)                                                    \
256        $(FATE_SEEK)                                                     \
257
258 $(FATE_ACODEC): $(AREF)
259 $(FATE_VCODEC): $(VREF)
260 $(FATE_LAVF):   $(REFS)
261 $(FATE_LAVFI):  $(REFS) tools/lavfi-showfiltfmts$(EXESUF)
262 $(FATE_SEEK):   fate-codec fate-lavf tests/seek_test$(EXESUF)
263
264 $(FATE_ACODEC):  CMD = codectest acodec
265 $(FATE_VSYNTH1): CMD = codectest vsynth1
266 $(FATE_VSYNTH2): CMD = codectest vsynth2
267 $(FATE_LAVF):    CMD = lavftest
268 $(FATE_LAVFI):   CMD = lavfitest
269 $(FATE_SEEK):    CMD = seektest
270
271 fate-codec:  fate-acodec fate-vcodec
272 fate-acodec: $(FATE_ACODEC)
273 fate-vcodec: $(FATE_VCODEC)
274 fate-lavf:   $(FATE_LAVF)
275 fate-lavfi:  $(FATE_LAVFI)
276 fate-seek:   $(FATE_SEEK)
277
278 ifdef SAMPLES
279 FATE += $(FATE_TESTS)
280 else
281 fate2 $(FATE_TESTS):
282         @echo "SAMPLES not specified, cannot run FATE"
283 endif
284
285 FATE_UTILS = base64 tiny_psnr
286
287 fate: $(FATE)
288 fate2: $(FATE2_TESTS)
289
290 $(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
291         @echo "TEST    $(@:fate-%=%)"
292         $(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)'
293
294 .PHONY: documentation *test regtest-* alltools check config