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