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