Makefile 8.43 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
PROGS      := $(PROGS-yes:%=%$(EXESUF))
OBJS        = $(PROGS-yes:%=%.o) cmdutils.o
MANPAGES    = $(PROGS-yes:%=doc/%.1)
PODPAGES    = $(PROGS-yes:%=doc/%.pod)
HTMLPAGES   = $(PROGS-yes:%=doc/%.html)
17
TOOLS       = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws graph2dot lavfi-showfiltfmts pktdumper probetest qt-faststart trasher))
18 19
TESTTOOLS   = audiogen videogen rotozoom tiny_psnr base64
HOSTPROGS  := $(TESTTOOLS:%=tests/%)
20

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

25
FFLIBS-$(CONFIG_AVDEVICE) += avdevice
26
FFLIBS-$(CONFIG_AVFILTER) += avfilter
27
FFLIBS-$(CONFIG_AVFORMAT) += avformat
Måns Rullgård's avatar
Måns Rullgård committed
28
FFLIBS-$(CONFIG_AVCODEC)  += avcodec
29
FFLIBS-$(CONFIG_POSTPROC) += postproc
30
FFLIBS-$(CONFIG_SWSCALE)  += swscale
31

32
FFLIBS := avutil
33

34 35
DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)

36 37
SKIPHEADERS = cmdutils_common_opts.h

38 39 40 41 42 43
include common.mak

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

44
ALL_TARGETS-$(CONFIG_DOC)       += documentation
45

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

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

54 55
config.h: .config
.config: $(wildcard $(FFLIBS:%=$(SRC_DIR)/lib%/all*.c))
56 57 58
	@-tput bold 2>/dev/null
	@-printf '\nWARNING: $(?F) newer than config.h, rerun configure\n\n'
	@-tput sgr0 2>/dev/null
59

60
SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES SKIPHEADERS \
61
               ALTIVEC-OBJS MMX-OBJS NEON-OBJS X86-OBJS YASM-OBJS-FFT YASM-OBJS \
62
               HOSTPROGS BUILT_HEADERS TESTOBJS ARCH_HEADERS ARMV6-OBJS
63 64 65 66 67 68 69 70 71 72 73 74 75 76

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))))

77 78
ffplay$(EXESUF): FF_EXTRALIBS += $(SDL_LIBS)
ffserver$(EXESUF): FF_LDFLAGS += $(FFSERVERLDFLAGS)
79

80
%$(EXESUF): %.o cmdutils.o $(FF_DEP_LIBS)
81
	$(LD) $(FF_LDFLAGS) -o $@ $< cmdutils.o $(FF_EXTRALIBS)
82

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

86
tools/%.o: tools/%.c
87
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $(CC_O) $<
88 89

-include $(wildcard tools/*.d)
90
-include $(wildcard tests/*.d)
91

92
ffplay.o: CFLAGS += $(SDL_CFLAGS)
93

Måns Rullgård's avatar
Måns Rullgård committed
94
VERSION_SH  = $(SRC_PATH_BARE)/version.sh
95
GIT_LOG     = $(SRC_PATH_BARE)/.git/logs/HEAD
Måns Rullgård's avatar
Måns Rullgård committed
96

97
.version: $(wildcard $(GIT_LOG)) $(VERSION_SH) config.mak
Måns Rullgård's avatar
Måns Rullgård committed
98 99 100
.version: M=@

version.h .version:
101
	$(M)$(VERSION_SH) $(SRC_PATH) version.h $(EXTRA_VERSION)
Måns Rullgård's avatar
Måns Rullgård committed
102 103 104 105
	$(Q)touch .version

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

107
alltools: $(TOOLS)
108

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

111
documentation: $(DOCS)
112

113 114 115
-include $(wildcard $(DOCS:%=%.d))

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

117
doc/%.html: TAG = HTML
118
doc/%.html: doc/%.texi $(SRC_PATH_BARE)/doc/t2h.init
119
	$(Q)$(TEXIDEP)
120
	$(M)cd doc && texi2html -monolithic --init-file $(SRC_PATH_BARE)/doc/t2h.init $(<:doc/%=%)
121

122
doc/%.pod: TAG = POD
123
doc/%.pod: doc/%.texi
124
	$(Q)$(TEXIDEP)
125
	$(M)doc/texi2pod.pl $< $@
126

127
doc/%.1: TAG = MAN
128
doc/%.1: doc/%.pod
129
	$(M)pod2man --section=1 --center=" " --release=" " $< > $@
130 131 132 133

install: $(INSTALL_TARGETS-yes)

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

137
install-data: $(DATA_FILES)
Måns Rullgård's avatar
Måns Rullgård committed
138
	$(Q)mkdir -p "$(DATADIR)"
139
	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
140

141
install-man: $(MANPAGES)
Måns Rullgård's avatar
Måns Rullgård committed
142
	$(Q)mkdir -p "$(MANDIR)/man1"
143
	$(INSTALL) -m 644 $(MANPAGES) "$(MANDIR)/man1"
144

Ramiro Polla's avatar
Ramiro Polla committed
145 146 147
uninstall: uninstall-progs uninstall-data uninstall-man

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

uninstall-data:
Måns Rullgård's avatar
Måns Rullgård committed
151
	$(RM) -r "$(DATADIR)"
Ramiro Polla's avatar
Ramiro Polla committed
152 153

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

156
testclean:
Måns Rullgård's avatar
Måns Rullgård committed
157 158 159
	$(RM) -r tests/vsynth1 tests/vsynth2 tests/data
	$(RM) $(addprefix tests/,$(CLEANSUFFIXES))
	$(RM) tests/seek_test$(EXESUF) tests/seek_test.o
160
	$(RM) $(TESTTOOLS:%=tests/%$(HOSTEXESUF))
161 162

clean:: testclean
163
	$(RM) $(ALLPROGS)
Måns Rullgård's avatar
Måns Rullgård committed
164 165 166
	$(RM) $(CLEANSUFFIXES)
	$(RM) doc/*.html doc/*.pod doc/*.1
	$(RM) $(TOOLS)
167
	$(RM) $(CLEANSUFFIXES:%=tools/%)
168 169

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

173
config:
174
	$(SRC_PATH)/configure $(value LIBAV_CONFIGURATION)
175

176 177
# regression tests

178 179
check: test checkheaders

180
fulltest test: codectest lavftest lavfitest seektest
181 182 183 184

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

185 186 187 188
codectest: fate-codec
lavftest:  fate-lavf
lavfitest: fate-lavfi
seektest:  fate-seek
189

190 191 192 193
AREF = tests/data/acodec.ref.wav
VREF = tests/data/vsynth1.ref.yuv
REFS = $(AREF) $(VREF)

194
$(REFS): TAG = GEN
195

196
$(VREF): ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm
197 198
	$(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)"
199

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

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

210
tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
211 212
	@mkdir -p tests/vsynth1
	$(M)$(BUILD_ROOT)/$< 'tests/vsynth1/'
213

214
tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
215 216
	@mkdir -p tests/vsynth2
	$(M)$(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
217

218
tests/data/asynth1.sw: tests/audiogen$(HOSTEXESUF)
219 220 221 222
	@mkdir -p tests/data
	$(M)$(BUILD_ROOT)/$< $@

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

224 225
tests/seek_test$(EXESUF): tests/seek_test.o $(FF_DEP_LIBS)
	$(LD) $(FF_LDFLAGS) -o $@ $< $(FF_EXTRALIBS)
226

227 228 229
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
230
include $(SRC_PATH_BARE)/tests/fate.mak
231 232
include $(SRC_PATH_BARE)/tests/fate2.mak

233 234 235 236
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
237
include $(SRC_PATH_BARE)/tests/fate/mp3.mak
238 239 240
include $(SRC_PATH_BARE)/tests/fate/vorbis.mak
include $(SRC_PATH_BARE)/tests/fate/vp8.mak

241 242 243
FATE_ACODEC  = $(ACODEC_TESTS:%=fate-acodec-%)
FATE_VSYNTH1 = $(VCODEC_TESTS:%=fate-vsynth1-%)
FATE_VSYNTH2 = $(VCODEC_TESTS:%=fate-vsynth2-%)
244
FATE_VCODEC  = $(FATE_VSYNTH1) $(FATE_VSYNTH2)
245 246
FATE_LAVF    = $(LAVF_TESTS:%=fate-lavf-%)
FATE_LAVFI   = $(LAVFI_TESTS:%=fate-lavfi-%)
247 248 249 250 251 252 253 254 255 256 257
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)
258
$(FATE_LAVFI):  $(REFS) tools/lavfi-showfiltfmts$(EXESUF)
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
$(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)

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

Måns Rullgård's avatar
Måns Rullgård committed
282 283
FATE_UTILS = base64 tiny_psnr

284 285
fate: $(FATE)

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

290 291 292
fate-list:
	@printf '%s\n' $(sort $(FATE))

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