Makefile 8.54 KB
Newer Older
1 2 3 4 5 6 7 8
include config.mak

SRC_DIR = $(SRC_PATH_BARE)

vpath %.texi $(SRC_PATH_BARE)

PROGS-$(CONFIG_FFMPEG)   += ffmpeg
PROGS-$(CONFIG_FFPLAY)   += ffplay
Stefano Sabatini's avatar
Stefano Sabatini committed
9
PROGS-$(CONFIG_FFPROBE)  += ffprobe
10 11
PROGS-$(CONFIG_FFSERVER) += ffserver

12 13 14 15 16 17
PROGS      := $(PROGS-yes:%=%$(EXESUF))
PROGS_G     = $(PROGS-yes:%=%_g$(EXESUF))
OBJS        = $(PROGS-yes:%=%.o) cmdutils.o
MANPAGES    = $(PROGS-yes:%=doc/%.1)
PODPAGES    = $(PROGS-yes:%=doc/%.pod)
HTMLPAGES   = $(PROGS-yes:%=doc/%.html)
Diego Biurrun's avatar
Diego Biurrun committed
18
TOOLS       = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws pktdumper probetest qt-faststart trasher))
19 20
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS  := $(TESTTOOLS:%=tests/%)
21

Stefano Sabatini's avatar
Stefano Sabatini committed
22
BASENAMES   = ffmpeg ffplay ffprobe ffserver
23
ALLPROGS    = $(BASENAMES:%=%$(EXESUF))
24
ALLPROGS_G  = $(BASENAMES:%=%_g$(EXESUF))
25
ALLMANPAGES = $(BASENAMES:%=%.1)
26

27
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
28
FFLIBS-$(CONFIG_AVFILTER) += avfilter
29
FFLIBS-$(CONFIG_AVFORMAT) += avformat
Måns Rullgård's avatar
Måns Rullgård committed
30
FFLIBS-$(CONFIG_AVCODEC)  += avcodec
31
FFLIBS-$(CONFIG_POSTPROC) += postproc
32
FFLIBS-$(CONFIG_SWSCALE)  += swscale
Stefano Sabatini's avatar
Stefano Sabatini committed
33
FFLIBS-$(CONFIG_AVCORE)   += avcore
34

35
FFLIBS := avutil
36

37 38
DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)

39 40
SKIPHEADERS = cmdutils_common_opts.h

41 42 43 44 45 46
include common.mak

FF_LDFLAGS   := $(FFLDFLAGS)
FF_EXTRALIBS := $(FFEXTRALIBS)
FF_DEP_LIBS  := $(DEP_LIBS)

47
ALL_TARGETS-$(CONFIG_DOC)       += documentation
48

Måns Rullgård's avatar
Måns Rullgård committed
49
ifdef PROGS
50
INSTALL_TARGETS-yes             += install-progs install-data
51
INSTALL_TARGETS-$(CONFIG_DOC)   += install-man
52
endif
53
INSTALL_PROGS_TARGETS-$(CONFIG_SHARED) = install-libs
54 55 56 57

all: $(FF_DEP_LIBS) $(PROGS) $(ALL_TARGETS-yes)

$(PROGS): %$(EXESUF): %_g$(EXESUF)
Måns Rullgård's avatar
Måns Rullgård committed
58
	$(CP) $< $@
59 60
	$(STRIP) $@

61 62
config.h: .config
.config: $(wildcard $(FFLIBS:%=$(SRC_DIR)/lib%/all*.c))
63 64 65
	@-tput bold 2>/dev/null
	@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
	@-tput sgr0 2>/dev/null
66

67
SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
68
               ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
69
               HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

define RESET
$(1) :=
$(1)-yes :=
endef

define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/
include $(1)/Makefile
endef

$(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))

ffplay_g$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
ffserver_g$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)

%_g$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
88
	$(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
89

Måns Rullgård's avatar
Måns Rullgård committed
90 91 92
tools/%$(EXESUF): tools/%.o
	$(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)

93
tools/%.o: tools/%.c
94
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
95

96
ffplay.o: CFLAGS += $(SDL_CFLAGS)
97

Måns Rullgård's avatar
Måns Rullgård committed
98
VERSION_SH  = $(SRC_PATH_BARE)/version.sh
99
GIT_LOG     = $(SRC_PATH_BARE)/.git/logs/HEAD
Måns Rullgård's avatar
Måns Rullgård committed
100 101
SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries

102
.version: $(wildcard $(GIT_LOG) $(SVN_ENTRIES)) $(VERSION_SH) config.mak
Måns Rullgård's avatar
Måns Rullgård committed
103 104 105
.version: M=@

version.h .version:
106
	$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
Måns Rullgård's avatar
Måns Rullgård committed
107 108 109 110
	$(Q)touch .version

# force version.sh to run whenever version might have changed
-include .version
111

112
alltools: $(TOOLS)
113

114
DOCS = $(addprefix doc/, developer.html faq.html general.html libavfilter.html) $(HTMLPAGES) $(MANPAGES) $(PODPAGES)
115

116
documentation: $(DOCS)
117

118 119 120
-include $(wildcard $(DOCS:%=%.d))

TEXIDEP = awk '/^@include/ { printf "$@: $(@D)/%s\n", $$2 }' <$< >$(@:%=%.d)
121

122
doc/%.html: TAG = HTML
123
doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init
124
	$(Q)$(TEXIDEP)
125
	$(M)cd doc && texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init $(<:doc/%=%)
126

127
doc/%.pod: TAG = POD
128
doc/%.pod: doc/%.texi
129
	$(Q)$(TEXIDEP)
130
	$(M)doc/texi2pod.pl $< $@
131

132
doc/%.1: TAG = MAN
133
doc/%.1: doc/%.pod
134
	$(M)pod2man --section=1 --center=" " --release=" " $< > $@
135 136 137 138

install: $(INSTALL_TARGETS-yes)

install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
Måns Rullgård's avatar
Måns Rullgård committed
139
	$(Q)mkdir -p "$(BINDIR)"
140
	$(INSTALL) -c -m 755 $(PROGS) "$(BINDIR)"
141

142
install-data: $(DATA_FILES)
Måns Rullgård's avatar
Måns Rullgård committed
143
	$(Q)mkdir -p "$(DATADIR)"
144
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
145

146
install-man: $(MANPAGES)
Måns Rullgård's avatar
Måns Rullgård committed
147
	$(Q)mkdir -p "$(MANDIR)/man1"
148
	$(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
149

Ramiro Polla's avatar
Ramiro Polla committed
150 151 152
uninstall: uninstall-progs uninstall-data uninstall-man

uninstall-progs:
Måns Rullgård's avatar
Måns Rullgård committed
153
	$(RM) $(addprefix "$(BINDIR)/", $(ALLPROGS))
Ramiro Polla's avatar
Ramiro Polla committed
154 155

uninstall-data:
Måns Rullgård's avatar
Måns Rullgård committed
156
	$(RM) -r "$(DATADIR)"
Ramiro Polla's avatar
Ramiro Polla committed
157 158

uninstall-man:
Måns Rullgård's avatar
Måns Rullgård committed
159
	$(RM) $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
160

161
testclean:
Måns Rullgård's avatar
Måns Rullgård committed
162 163 164
	$(RM) -r tests/vsynth1 tests/vsynth2 tests/data
	$(RM) $(addprefix tests/,$(CLEANSUFFIXES))
	$(RM) tests/seek_test$(EXESUF) tests/seek_test.o
165
	$(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF))
166 167

clean:: testclean
Måns Rullgård's avatar
Måns Rullgård committed
168 169 170 171
	$(RM) $(ALLPROGS) $(ALLPROGS_G)
	$(RM) $(CLEANSUFFIXES)
	$(RM) doc/*.html doc/*.pod doc/*.1
	$(RM) $(TOOLS)
172 173

distclean::
Måns Rullgård's avatar
Måns Rullgård committed
174 175
	$(RM) $(DISTCLEANSUFFIXES)
	$(RM) version.h config.* libavutil/avconfig.h
176

177
config:
178 179
	$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)

180 181
# regression tests

182 183
check: test checkheaders

184
fulltest test: codectest lavftest lavfitest seektest
185 186 187 188

FFSERVER_REFFILE = $(SRC_PATH)/tests/ffserver.regression.ref
SEEK_REFFILE     = $(SRC_PATH)/tests/seek.regression.ref

189 190 191 192
codectest: fate-codec
lavftest:  fate-lavf
lavfitest: fate-lavfi
seektest:  fate-seek
193

194 195 196 197
AREF = tests/data/acodec.ref.wav
VREF = tests/data/vsynth1.ref.yuv
REFS = $(AREF) $(VREF)

198
$(REFS): TAG = GEN
199

200
$(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm
201 202
	$(M)$(SRC_PATH)/tests/codec-regression.sh vref vsynth1 tests/vsynth1 "$(TARGET_EXEC)" "$(TARGET_PATH)"
	$(Q)$(SRC_PATH)/tests/codec-regression.sh vref vsynth2 tests/vsynth2 "$(TARGET_EXEC)" "$(TARGET_PATH)"
203

204
$(AREF): ffmpeg$(EXESUF) tests/data/asynth1.sw
205
	$(M)$(SRC_PATH)/tests/codec-regression.sh aref acodec tests/acodec "$(TARGET_EXEC)" "$(TARGET_PATH)"
206

207
ffservertest: ffserver$(EXESUF) tests/vsynth1/00.pgm tests/data/asynth1.sw
208 209 210 211
	@echo
	@echo "Unfortunately ffserver is broken and therefore its regression"
	@echo "test fails randomly. Treat the results accordingly."
	@echo
212
	$(SRC_PATH)/tests/ffserver-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/ffserver.conf
213

214
tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
215 216
	@mkdir -p tests/vsynth1
	$(M)$(BUILD_ROOT)/$< 'tests/vsynth1/'
217

218
tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
219 220
	@mkdir -p tests/vsynth2
	$(M)$(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
221

222
tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
223 224 225 226
	@mkdir -p tests/data
	$(M)$(BUILD_ROOT)/$< $@

tests/data/asynth1.sw tests/vsynth%/00.pgm: TAG = GEN
227

228 229
tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
	$(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
230

231 232 233
tools/lavfi-showfiltfmts$(EXESUF): tools/lavfi-showfiltfmts.o $(FF_DEP_LIBS)
	$(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)

Måns Rullgård's avatar
Måns Rullgård committed
234
include $(SRC_PATH_BARE)/tests/fate.mak
235 236
include $(SRC_PATH_BARE)/tests/fate2.mak

237 238 239 240
include $(SRC_PATH_BARE)/tests/fate/aac.mak
include $(SRC_PATH_BARE)/tests/fate/als.mak
include $(SRC_PATH_BARE)/tests/fate/fft.mak
include $(SRC_PATH_BARE)/tests/fate/h264.mak
Vitor Sessak's avatar
Vitor Sessak committed
241
include $(SRC_PATH_BARE)/tests/fate/mp3.mak
242 243 244
include $(SRC_PATH_BARE)/tests/fate/vorbis.mak
include $(SRC_PATH_BARE)/tests/fate/vp8.mak

245 246 247
FATE_ACODEC  = $(ACODEC_TESTS:%=fate-acodec-%)
FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%)
FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%)
248
FATE_VCODEC  = $(FATE_VSYNTH1) $(FATE_VSYNTH2)
249 250
FATE_LAVF    = $(LAVF_TESTS:%=fate-lavf-%)
FATE_LAVFI   = $(LAVFI_TESTS:%=fate-lavfi-%)
251 252 253 254 255 256 257 258 259 260 261
FATE_SEEK    = $(SEEK_TESTS:seek_%=fate-seek-%)

FATE = $(FATE_ACODEC)                                                   \
       $(FATE_VCODEC)                                                   \
       $(FATE_LAVF)                                                     \
       $(FATE_LAVFI)                                                    \
       $(FATE_SEEK)                                                     \

$(FATE_ACODEC): $(AREF)
$(FATE_VCODEC): $(VREF)
$(FATE_LAVF):   $(REFS)
262
$(FATE_LAVFI):  $(REFS) tools/lavfi-showfiltfmts$(EXESUF)
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
$(FATE_SEEK):   fate-codec fate-lavf tests/seek_test$(EXESUF)

$(FATE_ACODEC):  CMD = codectest acodec
$(FATE_VSYNTH1): CMD = codectest vsynth1
$(FATE_VSYNTH2): CMD = codectest vsynth2
$(FATE_LAVF):    CMD = lavftest
$(FATE_LAVFI):   CMD = lavfitest
$(FATE_SEEK):    CMD = seektest

fate-codec:  fate-acodec fate-vcodec
fate-acodec: $(FATE_ACODEC)
fate-vcodec: $(FATE_VCODEC)
fate-lavf:   $(FATE_LAVF)
fate-lavfi:  $(FATE_LAVFI)
fate-seek:   $(FATE_SEEK)

279
ifdef SAMPLES
280
FATE += $(FATE_TESTS)
Måns Rullgård's avatar
Måns Rullgård committed
281
else
282
$(FATE_TESTS):
Måns Rullgård's avatar
Måns Rullgård committed
283 284
	@echo "SAMPLES not specified, cannot run FATE"
endif
285

Måns Rullgård's avatar
Måns Rullgård committed
286 287
FATE_UTILS = base64 tiny_psnr

288 289
fate: $(FATE)

Måns Rullgård's avatar
Måns Rullgård committed
290
$(FATE): ffmpeg$(EXESUF) $(FATE_UTILS:%=tests/%$(HOSTEXESUF))
291
	@echo "TEST    $(@:fate-%=%)"
292 293
	$(Q)$(SRC_PATH)/tests/fate-run.sh $@ "$(SAMPLES)" "$(TARGET_EXEC)" "$(TARGET_PATH)" '$(CMD)' '$(CMP)' '$(REF)' '$(FUZZ)'

294 295 296
fate-list:
	@printf '%s\n' $(sort $(FATE))

297
.PHONY: documentation *test regtest-* alltools check config