rules.mak 5.01 KB
Newer Older
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
1
2
# FFmpeg

3
4
5
#Uncomment the one you want
#USE_LIBAV ?= 1
#USE_FFMPEG ?= 1
6

7
ifndef USE_LIBAV
8
FFMPEG_HASH=eaff5fcb7cde8d1614755269773d471d3a3d1bfc
9
FFMPEG_SNAPURL := http://git.videolan.org/?p=ffmpeg.git;a=snapshot;h=$(FFMPEG_HASH);sf=tgz
10
FFMPEG_GITURL := http://git.videolan.org/git/ffmpeg.git
11
FFMPEG_LAVC_MIN := 57.37.100
12
USE_FFMPEG := 1
13
else
14
FFMPEG_HASH=e171022c24c42b1e88a51bb3b4c27f13c87c85cb
15
FFMPEG_SNAPURL := http://git.libav.org/?p=libav.git;a=snapshot;h=$(FFMPEG_HASH);sf=tgz
16
FFMPEG_GITURL := git://git.libav.org/libav.git
17
FFMPEG_LAVC_MIN := 57.16.0
18
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
19

20
21
FFMPEG_BASENAME := $(subst .,_,$(subst \,_,$(subst /,_,$(FFMPEG_HASH))))

22
23
FFMPEGCONF = \
	--cc="$(CC)" \
24
	--pkg-config="$(PKG_CONFIG)" \
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
25
	--disable-doc \
26
	--disable-encoder=vorbis \
27
	--disable-decoder=opus \
28
	--enable-libgsm \
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
29
	--disable-debug \
30
	--disable-avdevice \
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
31
	--disable-devices \
32
	--disable-avfilter \
33
	--disable-filters \
34
	--disable-protocol=concat \
35
	--disable-bsfs \
36
	--disable-bzlib \
37
	--disable-avresample
38
39
40
41

ifdef USE_FFMPEG
FFMPEGCONF += \
	--disable-swresample \
42
	--disable-iconv \
43
	--disable-avisynth \
44
45
	--disable-nvenc \
	--disable-linux-perf
46
47
48
49
ifdef HAVE_DARWIN_OS
FFMPEGCONF += \
	--disable-videotoolbox
endif
50
endif
51

52
53
54
55
56
57
58
DEPS_ffmpeg = zlib gsm

ifndef USE_LIBAV
FFMPEGCONF += \
	--enable-libopenjpeg
DEPS_ffmpeg += openjpeg
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
59
60

# Optional dependencies
61
62
63
ifndef BUILD_NETWORK
FFMPEGCONF += --disable-network
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
64
ifdef BUILD_ENCODERS
65
66
67
68
FFMPEGCONF += --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx_vp8 --disable-decoder=libvpx_vp9
ifndef USE_FFMPEG
FFMPEGCONF += --disable-decoder=libvpx
endif
69
DEPS_ffmpeg += lame $(DEPS_lame) vpx $(DEPS_vpx)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
70
71
else
FFMPEGCONF += --disable-encoders --disable-muxers
72
73
endif

74
# Small size
75
ifdef WITH_OPTIMIZATION
76
ifdef ENABLE_SMALL
77
FFMPEGCONF += --enable-small
78
endif
Rafaël Carré's avatar
Rafaël Carré committed
79
ifeq ($(ARCH),arm)
80
ifdef HAVE_ARMV7A
Rafaël Carré's avatar
Rafaël Carré committed
81
82
83
FFMPEGCONF += --enable-thumb
endif
endif
84
85
86
else
FFMPEGCONF += --optflags=-O0
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
87

88
ifdef HAVE_CROSS_COMPILE
89
FFMPEGCONF += --enable-cross-compile --disable-programs
90
ifndef HAVE_DARWIN_OS
91
92
FFMPEGCONF += --cross-prefix=$(HOST)-
endif
93
94
endif

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
95
96
# ARM stuff
ifeq ($(ARCH),arm)
97
FFMPEGCONF += --arch=arm
98
99
100
ifdef HAVE_NEON
FFMPEGCONF += --enable-neon
endif
101
ifdef HAVE_ARMV7A
102
FFMPEGCONF += --cpu=cortex-a8
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
103
endif
104
105
106
ifdef HAVE_ARMV6
FFMPEGCONF += --cpu=armv6 --disable-neon
endif
107
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
108

109
110
111
112
113
# ARM64 stuff
ifeq ($(ARCH),aarch64)
FFMPEGCONF += --arch=aarch64
endif

114
115
116
117
# MIPS stuff
ifeq ($(ARCH),mipsel)
FFMPEGCONF += --arch=mips
endif
118
119
120
ifeq ($(ARCH),mips64el)
FFMPEGCONF += --arch=mips64
endif
121

122
123
# x86 stuff
ifeq ($(ARCH),i386)
124
ifndef HAVE_DARWIN_OS
125
126
FFMPEGCONF += --arch=x86
endif
127
endif
128

129
130
131
132
133
134
135
# x86_64 stuff
ifeq ($(ARCH),x86_64)
ifndef HAVE_DARWIN_OS
FFMPEGCONF += --arch=x86_64
endif
endif

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
136
137
138
# Darwin
ifdef HAVE_DARWIN_OS
FFMPEGCONF += --arch=$(ARCH) --target-os=darwin
139
140
141
ifdef USE_FFMPEG
FFMPEGCONF += --disable-lzma
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
142
143
144
ifeq ($(ARCH),x86_64)
FFMPEGCONF += --cpu=core2
endif
145
ifdef HAVE_IOS
146
FFMPEGCONF += --enable-pic --extra-ldflags="$(EXTRA_CFLAGS)"
147
148
ifdef HAVE_NEON
FFMPEGCONF += --as="$(AS)"
149
endif
150
endif
151
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
152
153
154

# Linux
ifdef HAVE_LINUX
155
FFMPEGCONF += --target-os=linux --enable-pic --extra-libs="-lm"
156

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
157
158
endif

159
ifdef HAVE_ANDROID
160
# broken text relocations
161
ifeq ($(ANDROID_ABI), x86)
162
FFMPEGCONF +=  --disable-mmx --disable-mmxext --disable-inline-asm
163
endif
164
165
166
ifeq ($(ANDROID_ABI), x86_64)
FFMPEGCONF +=  --disable-mmx --disable-mmxext --disable-inline-asm
endif
167
168
169
170
171
ifdef HAVE_NEON
ifeq ($(ANDROID_ABI), armeabi-v7a)
FFMPEGCONF += --as='gas-preprocessor.pl -as-type clang -arch arm $(CC)'
endif
endif
172
173
endif

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
174
175
# Windows
ifdef HAVE_WIN32
176
177
ifndef HAVE_VISUALSTUDIO
DEPS_ffmpeg += d3d11
178
ifndef HAVE_MINGW_W64
179
DEPS_ffmpeg += directx
180
endif
181
endif
182
FFMPEGCONF += --target-os=mingw32
183
184
185
186
187
188
FFMPEGCONF += --enable-w32threads
ifndef HAVE_WINSTORE
FFMPEGCONF += --enable-dxva2
else
FFMPEGCONF += --disable-dxva2
endif
189

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
190
191
ifdef HAVE_WIN64
FFMPEGCONF += --cpu=athlon64 --arch=x86_64
192
193
else
ifeq ($(ARCH),i386) # 32bits intel
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
194
FFMPEGCONF+= --cpu=i686 --arch=x86
195
196
197
198
else
ifdef HAVE_ARMV7A
FFMPEGCONF+= --arch=arm
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
199
endif
200
endif
201
202

else # !Windows
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
203
204
205
FFMPEGCONF += --enable-pthreads
endif

206
# Solaris
Sean McGovern's avatar
Sean McGovern committed
207
ifdef HAVE_SOLARIS
208
209
210
ifeq ($(ARCH),x86_64)
FFMPEGCONF += --cpu=core2
endif
211
FFMPEGCONF += --target-os=sunos --enable-pic
Sean McGovern's avatar
Sean McGovern committed
212
213
endif

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
214
# Build
215
PKGS += ffmpeg
216
ifeq ($(call need_pkg,"libavcodec >= $(FFMPEG_LAVC_MIN) libavformat >= 53.21.0 libswscale"),)
217
218
PKGS_FOUND += ffmpeg
endif
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
219

220
FFMPEGCONF += --nm="$(NM)" --ar="$(AR)"
221

222
$(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz:
223
	$(call download_git,$(FFMPEG_GITURL),,$(FFMPEG_HASH))
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
224

225
.sum-ffmpeg: $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz
226
	$(call check_githash,$(FFMPEG_HASH))
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
227
228
	touch $@

229
230
231
ffmpeg: ffmpeg-$(FFMPEG_BASENAME).tar.xz .sum-ffmpeg
	rm -Rf $@ $@-$(FFMPEG_BASENAME)
	mkdir -p $@-$(FFMPEG_BASENAME)
232
	tar xvJf "$<" --strip-components=1 -C $@-$(FFMPEG_BASENAME)
233
ifdef USE_FFMPEG
234
	$(APPLY) $(SRC)/ffmpeg/armv7_fixup.patch
235
	$(APPLY) $(SRC)/ffmpeg/dxva_vc1_crash.patch
236
237
238
endif
ifdef USE_LIBAV
	$(APPLY) $(SRC)/ffmpeg/libav_gsm.patch
239
endif
240
	$(MOVE)
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
241
242
243
244
245
246
247

.ffmpeg: ffmpeg
	cd $< && $(HOSTVARS) ./configure \
		--extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
		--prefix="$(PREFIX)" --enable-static --disable-shared
	cd $< && $(MAKE) install-libs install-headers
	touch $@