contribs: ffmpeg, fix compilation for ARMv7 on Android
[vlc.git] / contrib / src / ffmpeg / rules.mak
blobb31c1e38ce49e6f337539ddcc0b12488be166d15
1 # FFmpeg
3 #Uncomment the one you want
4 #USE_LIBAV ?= 1
5 #USE_FFMPEG ?= 1
7 ifndef USE_LIBAV
8 FFMPEG_HASH=5a93a85fd0ad62c6c9cdf69415959f116c015f0e
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 else
12 FFMPEG_HASH=e171022c24c42b1e88a51bb3b4c27f13c87c85cb
13 FFMPEG_SNAPURL := http://git.libav.org/?p=libav.git;a=snapshot;h=$(FFMPEG_HASH);sf=tgz
14 FFMPEG_GITURL := git://git.libav.org/libav.git
15 endif
17 FFMPEG_BASENAME := $(subst .,_,$(subst \,_,$(subst /,_,$(FFMPEG_HASH))))
19 FFMPEGCONF = \
20 --cc="$(CC)" \
21 --pkg-config="$(PKG_CONFIG)" \
22 --disable-doc \
23 --disable-encoder=vorbis \
24 --disable-decoder=opus \
25 --enable-libgsm \
26 --enable-libopenjpeg \
27 --disable-debug \
28 --disable-avdevice \
29 --disable-devices \
30 --disable-avfilter \
31 --disable-filters \
32 --disable-protocol=concat \
33 --disable-bsfs \
34 --disable-bzlib \
35 --disable-avresample
37 ifdef USE_FFMPEG
38 FFMPEGCONF += \
39 --disable-swresample \
40 --disable-iconv \
41 --disable-avisynth \
42 --disable-nvenc \
43 --disable-linux-perf
44 ifdef HAVE_DARWIN_OS
45 FFMPEGCONF += \
46 --disable-videotoolbox
47 endif
48 endif
50 DEPS_ffmpeg = zlib gsm openjpeg
52 # Optional dependencies
53 ifndef BUILD_NETWORK
54 FFMPEGCONF += --disable-network
55 endif
56 ifdef BUILD_ENCODERS
57 FFMPEGCONF += --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx_vp8 --disable-decoder=libvpx_vp9
58 ifndef USE_FFMPEG
59 FFMPEGCONF += --disable-decoder=libvpx
60 endif
61 DEPS_ffmpeg += lame $(DEPS_lame) vpx $(DEPS_vpx)
62 else
63 FFMPEGCONF += --disable-encoders --disable-muxers
64 endif
66 # Small size
67 ifdef WITH_OPTIMIZATION
68 ifdef ENABLE_SMALL
69 FFMPEGCONF += --enable-small
70 endif
71 ifeq ($(ARCH),arm)
72 ifdef HAVE_ARMV7A
73 FFMPEGCONF += --enable-thumb
74 endif
75 endif
76 else
77 FFMPEGCONF += --optflags=-O0
78 endif
80 ifdef HAVE_CROSS_COMPILE
81 FFMPEGCONF += --enable-cross-compile --disable-programs
82 ifndef HAVE_DARWIN_OS
83 FFMPEGCONF += --cross-prefix=$(HOST)-
84 endif
85 endif
87 # ARM stuff
88 ifeq ($(ARCH),arm)
89 FFMPEGCONF += --arch=arm
90 ifdef HAVE_NEON
91 FFMPEGCONF += --enable-neon
92 endif
93 ifdef HAVE_ARMV7A
94 FFMPEGCONF += --cpu=cortex-a8
95 endif
96 ifdef HAVE_ARMV6
97 FFMPEGCONF += --cpu=armv6 --disable-neon
98 endif
99 endif
101 # ARM64 stuff
102 ifeq ($(ARCH),aarch64)
103 FFMPEGCONF += --arch=aarch64
104 endif
106 # MIPS stuff
107 ifeq ($(ARCH),mipsel)
108 FFMPEGCONF += --arch=mips
109 endif
110 ifeq ($(ARCH),mips64el)
111 FFMPEGCONF += --arch=mips64
112 endif
114 # x86 stuff
115 ifeq ($(ARCH),i386)
116 ifndef HAVE_DARWIN_OS
117 FFMPEGCONF += --arch=x86
118 endif
119 endif
121 # x86_64 stuff
122 ifeq ($(ARCH),x86_64)
123 ifndef HAVE_DARWIN_OS
124 FFMPEGCONF += --arch=x86_64
125 endif
126 endif
128 # Darwin
129 ifdef HAVE_DARWIN_OS
130 FFMPEGCONF += --arch=$(ARCH) --target-os=darwin
131 ifdef USE_FFMPEG
132 FFMPEGCONF += --disable-lzma
133 endif
134 ifeq ($(ARCH),x86_64)
135 FFMPEGCONF += --cpu=core2
136 endif
137 ifdef HAVE_IOS
138 FFMPEGCONF += --enable-pic --extra-ldflags="$(EXTRA_CFLAGS)"
139 ifdef HAVE_NEON
140 FFMPEGCONF += --as="$(AS)"
141 endif
142 endif
143 endif
145 # Linux
146 ifdef HAVE_LINUX
147 FFMPEGCONF += --target-os=linux --enable-pic
149 endif
151 ifdef HAVE_ANDROID
152 # broken text relocations
153 ifeq ($(ANDROID_ABI), x86)
154 FFMPEGCONF += --disable-mmx --disable-mmxext --disable-inline-asm
155 endif
156 ifeq ($(ANDROID_ABI), x86_64)
157 FFMPEGCONF += --disable-mmx --disable-mmxext --disable-inline-asm
158 endif
159 ifdef HAVE_NEON
160 ifeq ($(ANDROID_ABI), armeabi-v7a)
161 FFMPEGCONF += --as='gas-preprocessor.pl -as-type clang -arch arm $(CC)'
162 endif
163 endif
164 endif
166 # Windows
167 ifdef HAVE_WIN32
168 ifndef HAVE_VISUALSTUDIO
169 DEPS_ffmpeg += d3d11
170 ifndef HAVE_MINGW_W64
171 DEPS_ffmpeg += directx
172 endif
173 endif
174 FFMPEGCONF += --target-os=mingw32
175 FFMPEGCONF += --enable-w32threads
176 ifndef HAVE_WINSTORE
177 FFMPEGCONF += --enable-dxva2
178 else
179 FFMPEGCONF += --disable-dxva2
180 endif
182 ifdef HAVE_WIN64
183 FFMPEGCONF += --cpu=athlon64 --arch=x86_64
184 else
185 ifeq ($(ARCH),i386) # 32bits intel
186 FFMPEGCONF+= --cpu=i686 --arch=x86
187 else
188 ifdef HAVE_ARMV7A
189 FFMPEGCONF+= --arch=arm
190 endif
191 endif
192 endif
194 else # !Windows
195 FFMPEGCONF += --enable-pthreads
196 endif
198 # Solaris
199 ifdef HAVE_SOLARIS
200 ifeq ($(ARCH),x86_64)
201 FFMPEGCONF += --cpu=core2
202 endif
203 FFMPEGCONF += --target-os=sunos --enable-pic
204 endif
206 # Build
207 PKGS += ffmpeg
208 ifeq ($(call need_pkg,"libavcodec >= 55.0.0 libavformat >= 53.21.0 libswscale"),)
209 PKGS_FOUND += ffmpeg
210 endif
212 FFMPEGCONF += --nm="$(NM)" --ar="$(AR)"
214 $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz:
215 $(call download_git,$(FFMPEG_GITURL),,$(FFMPEG_HASH))
217 .sum-ffmpeg: $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz
218 $(call check_githash,$(FFMPEG_HASH))
219 touch $@
221 ffmpeg: ffmpeg-$(FFMPEG_BASENAME).tar.xz .sum-ffmpeg
222 rm -Rf $@ $@-$(FFMPEG_BASENAME)
223 mkdir -p $@-$(FFMPEG_BASENAME)
224 tar xvJf "$<" --strip-components=1 -C $@-$(FFMPEG_BASENAME)
225 $(APPLY) $(SRC)/ffmpeg/armv7_fixup.patch
226 $(MOVE)
228 .ffmpeg: ffmpeg
229 cd $< && $(HOSTVARS) ./configure \
230 --extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
231 --prefix="$(PREFIX)" --enable-static --disable-shared
232 cd $< && $(MAKE) install-libs install-headers
233 touch $@