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