contrib: ffmpeg: Fix NaCL build
[vlc.git] / contrib / src / ffmpeg / rules.mak
blob434e4d3e901c44c54c95af7ccff7265bfcd75458
1 # FFmpeg
3 #Uncomment the one you want
4 #USE_LIBAV ?= 1
5 #USE_FFMPEG ?= 1
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
20 FFMPEG_BASENAME := $(subst .,_,$(subst \,_,$(subst /,_,$(FFMPEG_HASH))))
22 # bsf=vp9_superframe is needed to mux VP9 inside webm/mkv
23 FFMPEGCONF = \
24 --cc="$(CC)" \
25 --pkg-config="$(PKG_CONFIG)" \
26 --disable-doc \
27 --disable-encoder=vorbis \
28 --disable-decoder=opus \
29 --enable-libgsm \
30 --disable-debug \
31 --disable-avdevice \
32 --disable-devices \
33 --disable-avfilter \
34 --disable-filters \
35 --disable-protocol=concat \
36 --disable-bsfs \
37 --disable-bzlib \
38 --disable-avresample \
39 --enable-bsf=vp9_superframe
41 ifdef USE_FFMPEG
42 FFMPEGCONF += \
43 --disable-swresample \
44 --disable-iconv \
45 --disable-avisynth \
46 --disable-nvenc \
47 --disable-linux-perf
48 ifdef HAVE_DARWIN_OS
49 FFMPEGCONF += \
50 --disable-videotoolbox \
51 --disable-securetransport
52 endif
53 endif
55 DEPS_ffmpeg = zlib gsm
57 ifndef USE_LIBAV
58 FFMPEGCONF += \
59 --enable-libopenjpeg
60 DEPS_ffmpeg += openjpeg
61 endif
63 # Optional dependencies
64 ifndef BUILD_NETWORK
65 FFMPEGCONF += --disable-network
66 endif
67 ifdef BUILD_ENCODERS
68 FFMPEGCONF += --enable-libmp3lame --enable-libvpx --disable-decoder=libvpx_vp8 --disable-decoder=libvpx_vp9
69 ifndef USE_FFMPEG
70 FFMPEGCONF += --disable-decoder=libvpx
71 endif
72 DEPS_ffmpeg += lame $(DEPS_lame) vpx $(DEPS_vpx)
73 else
74 FFMPEGCONF += --disable-encoders --disable-muxers
75 endif
77 # Small size
78 ifdef WITH_OPTIMIZATION
79 ifdef ENABLE_SMALL
80 FFMPEGCONF += --enable-small
81 endif
82 ifeq ($(ARCH),arm)
83 ifdef HAVE_ARMV7A
84 FFMPEGCONF += --enable-thumb
85 endif
86 endif
87 else
88 FFMPEGCONF += --optflags=-O0
89 endif
91 ifdef HAVE_CROSS_COMPILE
92 FFMPEGCONF += --enable-cross-compile --disable-programs
93 ifndef HAVE_DARWIN_OS
94 FFMPEGCONF += --cross-prefix=$(HOST)-
95 endif
96 endif
98 # ARM stuff
99 ifeq ($(ARCH),arm)
100 FFMPEGCONF += --arch=arm
101 ifdef HAVE_NEON
102 FFMPEGCONF += --enable-neon
103 endif
104 ifdef HAVE_ARMV7A
105 FFMPEGCONF += --cpu=cortex-a8
106 endif
107 ifdef HAVE_ARMV6
108 FFMPEGCONF += --cpu=armv6 --disable-neon
109 endif
110 endif
112 # ARM64 stuff
113 ifeq ($(ARCH),aarch64)
114 FFMPEGCONF += --arch=aarch64
115 endif
117 # MIPS stuff
118 ifeq ($(ARCH),mipsel)
119 FFMPEGCONF += --arch=mips
120 endif
121 ifeq ($(ARCH),mips64el)
122 FFMPEGCONF += --arch=mips64
123 endif
125 # x86 stuff
126 ifeq ($(ARCH),i386)
127 ifndef HAVE_DARWIN_OS
128 FFMPEGCONF += --arch=x86
129 endif
130 endif
132 # x86_64 stuff
133 ifeq ($(ARCH),x86_64)
134 ifndef HAVE_DARWIN_OS
135 FFMPEGCONF += --arch=x86_64
136 endif
137 endif
139 # Darwin
140 ifdef HAVE_DARWIN_OS
141 FFMPEGCONF += --arch=$(ARCH) --target-os=darwin
142 ifdef USE_FFMPEG
143 FFMPEGCONF += --disable-lzma
144 endif
145 ifeq ($(ARCH),x86_64)
146 FFMPEGCONF += --cpu=core2
147 endif
148 ifdef HAVE_IOS
149 FFMPEGCONF += --enable-pic --extra-ldflags="$(EXTRA_CFLAGS)"
150 ifdef HAVE_NEON
151 FFMPEGCONF += --as="$(AS)"
152 endif
153 endif
154 endif
156 # Linux
157 ifdef HAVE_LINUX
158 FFMPEGCONF += --target-os=linux --enable-pic --extra-libs="-lm"
160 endif
162 ifdef HAVE_ANDROID
163 # broken text relocations
164 ifeq ($(ANDROID_ABI), x86)
165 FFMPEGCONF += --disable-mmx --disable-mmxext --disable-inline-asm
166 endif
167 ifeq ($(ANDROID_ABI), x86_64)
168 FFMPEGCONF += --disable-mmx --disable-mmxext --disable-inline-asm
169 endif
170 ifdef HAVE_NEON
171 ifeq ($(ANDROID_ABI), armeabi-v7a)
172 FFMPEGCONF += --as='gas-preprocessor.pl -as-type clang -arch arm $(CC)'
173 endif
174 endif
175 endif
177 # Windows
178 ifdef HAVE_WIN32
179 ifndef HAVE_VISUALSTUDIO
180 DEPS_ffmpeg += d3d11
181 ifndef HAVE_MINGW_W64
182 DEPS_ffmpeg += directx
183 endif
184 endif
185 FFMPEGCONF += --target-os=mingw32
186 FFMPEGCONF += --enable-w32threads
187 ifndef HAVE_WINSTORE
188 FFMPEGCONF += --enable-dxva2
189 else
190 FFMPEGCONF += --disable-dxva2
191 endif
193 ifeq ($(ARCH),x86_64)
194 FFMPEGCONF += --cpu=athlon64 --arch=x86_64
195 else
196 ifeq ($(ARCH),i386) # 32bits intel
197 FFMPEGCONF+= --cpu=i686 --arch=x86
198 else
199 ifdef HAVE_ARMV7A
200 FFMPEGCONF+= --arch=arm
201 endif
202 endif
203 endif
205 else # !Windows
206 FFMPEGCONF += --enable-pthreads
207 endif
209 # Solaris
210 ifdef HAVE_SOLARIS
211 ifeq ($(ARCH),x86_64)
212 FFMPEGCONF += --cpu=core2
213 endif
214 FFMPEGCONF += --target-os=sunos --enable-pic
215 endif
217 ifdef HAVE_NACL
218 FFMPEGCONF+=--disable-inline-asm --disable-asm --target-os=linux
219 endif
221 # Build
222 PKGS += ffmpeg
223 ifeq ($(call need_pkg,"libavcodec >= $(FFMPEG_LAVC_MIN) libavformat >= 53.21.0 libswscale"),)
224 PKGS_FOUND += ffmpeg
225 endif
227 FFMPEGCONF += --nm="$(NM)" --ar="$(AR)"
229 $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz:
230 $(call download_git,$(FFMPEG_GITURL),,$(FFMPEG_HASH))
232 .sum-ffmpeg: $(TARBALLS)/ffmpeg-$(FFMPEG_BASENAME).tar.xz
233 $(call check_githash,$(FFMPEG_HASH))
234 touch $@
236 ffmpeg: ffmpeg-$(FFMPEG_BASENAME).tar.xz .sum-ffmpeg
237 rm -Rf $@ $@-$(FFMPEG_BASENAME)
238 mkdir -p $@-$(FFMPEG_BASENAME)
239 tar xvJf "$<" --strip-components=1 -C $@-$(FFMPEG_BASENAME)
240 ifdef USE_FFMPEG
241 $(APPLY) $(SRC)/ffmpeg/armv7_fixup.patch
242 $(APPLY) $(SRC)/ffmpeg/dxva_vc1_crash.patch
243 $(APPLY) $(SRC)/ffmpeg/h264_early_SAR.patch
244 endif
245 ifdef USE_LIBAV
246 $(APPLY) $(SRC)/ffmpeg/libav_gsm.patch
247 endif
248 $(MOVE)
250 .ffmpeg: ffmpeg
251 cd $< && $(HOSTVARS) ./configure \
252 --extra-ldflags="$(LDFLAGS)" $(FFMPEGCONF) \
253 --prefix="$(PREFIX)" --enable-static --disable-shared
254 cd $< && $(MAKE) install-libs install-headers
255 touch $@