package/vlc: backport upstream patches to fix compat function for static_assert
[buildroot-gz.git] / package / ffmpeg / ffmpeg.mk
blob52a39dee0e4abf9394053e4b9ea12b7e893eeff9
1 ################################################################################
3 # ffmpeg
5 ################################################################################
7 FFMPEG_VERSION = 3.1.4
8 FFMPEG_SOURCE = ffmpeg-$(FFMPEG_VERSION).tar.xz
9 FFMPEG_SITE = http://ffmpeg.org/releases
10 FFMPEG_INSTALL_STAGING = YES
12 FFMPEG_LICENSE = LGPLv2.1+, libjpeg license
13 FFMPEG_LICENSE_FILES = LICENSE.md COPYING.LGPLv2.1
14 ifeq ($(BR2_PACKAGE_FFMPEG_GPL),y)
15 FFMPEG_LICENSE += and GPLv2+
16 FFMPEG_LICENSE_FILES += COPYING.GPLv2
17 endif
19 FFMPEG_CONF_OPTS = \
20 --prefix=/usr \
21 --enable-avfilter \
22 --disable-version3 \
23 --enable-logging \
24 --enable-optimizations \
25 --disable-extra-warnings \
26 --enable-avdevice \
27 --enable-avcodec \
28 --enable-avformat \
29 --disable-x11grab \
30 --enable-network \
31 --disable-gray \
32 --enable-swscale-alpha \
33 --disable-small \
34 --enable-dct \
35 --enable-fft \
36 --enable-mdct \
37 --enable-rdft \
38 --disable-crystalhd \
39 --disable-dxva2 \
40 --enable-runtime-cpudetect \
41 --disable-hardcoded-tables \
42 --disable-memalign-hack \
43 --disable-mipsdsp \
44 --disable-mipsdspr2 \
45 --disable-msa \
46 --enable-hwaccels \
47 --disable-avisynth \
48 --disable-frei0r \
49 --disable-libopencore-amrnb \
50 --disable-libopencore-amrwb \
51 --disable-libcdio \
52 --disable-libdc1394 \
53 --disable-libfaac \
54 --disable-libgsm \
55 --disable-libilbc \
56 --disable-libnut \
57 --disable-libopenjpeg \
58 --disable-libschroedinger \
59 --disable-libvo-amrwbenc \
60 --disable-symver \
61 --disable-doc
63 FFMPEG_DEPENDENCIES += $(if $(BR2_PACKAGE_LIBICONV),libiconv) host-pkgconf
65 ifeq ($(BR2_PACKAGE_FFMPEG_GPL),y)
66 FFMPEG_CONF_OPTS += --enable-gpl
67 else
68 FFMPEG_CONF_OPTS += --disable-gpl
69 endif
71 ifeq ($(BR2_PACKAGE_FFMPEG_NONFREE),y)
72 FFMPEG_CONF_OPTS += --enable-nonfree
73 else
74 FFMPEG_CONF_OPTS += --disable-nonfree
75 endif
77 ifeq ($(BR2_PACKAGE_FFMPEG_FFMPEG),y)
78 FFMPEG_CONF_OPTS += --enable-ffmpeg
79 else
80 FFMPEG_CONF_OPTS += --disable-ffmpeg
81 endif
83 ifeq ($(BR2_PACKAGE_FFMPEG_FFPLAY),y)
84 FFMPEG_DEPENDENCIES += sdl
85 FFMPEG_CONF_OPTS += --enable-ffplay
86 FFMPEG_CONF_ENV += SDL_CONFIG=$(STAGING_DIR)/usr/bin/sdl-config
87 else
88 FFMPEG_CONF_OPTS += --disable-ffplay
89 endif
91 ifeq ($(BR2_PACKAGE_FFMPEG_FFSERVER),y)
92 FFMPEG_CONF_OPTS += --enable-ffserver
93 else
94 FFMPEG_CONF_OPTS += --disable-ffserver
95 endif
97 ifeq ($(BR2_PACKAGE_FFMPEG_AVRESAMPLE),y)
98 FFMPEG_CONF_OPTS += --enable-avresample
99 else
100 FFMPEG_CONF_OPTS += --disable-avresample
101 endif
103 ifeq ($(BR2_PACKAGE_FFMPEG_FFPROBE),y)
104 FFMPEG_CONF_OPTS += --enable-ffprobe
105 else
106 FFMPEG_CONF_OPTS += --disable-ffprobe
107 endif
109 ifeq ($(BR2_PACKAGE_FFMPEG_POSTPROC),y)
110 FFMPEG_CONF_OPTS += --enable-postproc
111 else
112 FFMPEG_CONF_OPTS += --disable-postproc
113 endif
115 ifeq ($(BR2_PACKAGE_FFMPEG_SWSCALE),y)
116 FFMPEG_CONF_OPTS += --enable-swscale
117 else
118 FFMPEG_CONF_OPTS += --disable-swscale
119 endif
121 ifneq ($(call qstrip,$(BR2_PACKAGE_FFMPEG_ENCODERS)),all)
122 FFMPEG_CONF_OPTS += --disable-encoders \
123 $(foreach x,$(call qstrip,$(BR2_PACKAGE_FFMPEG_ENCODERS)),--enable-encoder=$(x))
124 endif
126 ifneq ($(call qstrip,$(BR2_PACKAGE_FFMPEG_DECODERS)),all)
127 FFMPEG_CONF_OPTS += --disable-decoders \
128 $(foreach x,$(call qstrip,$(BR2_PACKAGE_FFMPEG_DECODERS)),--enable-decoder=$(x))
129 endif
131 ifneq ($(call qstrip,$(BR2_PACKAGE_FFMPEG_MUXERS)),all)
132 FFMPEG_CONF_OPTS += --disable-muxers \
133 $(foreach x,$(call qstrip,$(BR2_PACKAGE_FFMPEG_MUXERS)),--enable-muxer=$(x))
134 endif
136 ifneq ($(call qstrip,$(BR2_PACKAGE_FFMPEG_DEMUXERS)),all)
137 FFMPEG_CONF_OPTS += --disable-demuxers \
138 $(foreach x,$(call qstrip,$(BR2_PACKAGE_FFMPEG_DEMUXERS)),--enable-demuxer=$(x))
139 endif
141 ifneq ($(call qstrip,$(BR2_PACKAGE_FFMPEG_PARSERS)),all)
142 FFMPEG_CONF_OPTS += --disable-parsers \
143 $(foreach x,$(call qstrip,$(BR2_PACKAGE_FFMPEG_PARSERS)),--enable-parser=$(x))
144 endif
146 ifneq ($(call qstrip,$(BR2_PACKAGE_FFMPEG_BSFS)),all)
147 FFMPEG_CONF_OPTS += --disable-bsfs \
148 $(foreach x,$(call qstrip,$(BR2_PACKAGE_FFMPEG_BSFS)),--enable-bsfs=$(x))
149 endif
151 ifneq ($(call qstrip,$(BR2_PACKAGE_FFMPEG_PROTOCOLS)),all)
152 FFMPEG_CONF_OPTS += --disable-protocols \
153 $(foreach x,$(call qstrip,$(BR2_PACKAGE_FFMPEG_PROTOCOLS)),--enable-protocol=$(x))
154 endif
156 ifneq ($(call qstrip,$(BR2_PACKAGE_FFMPEG_FILTERS)),all)
157 FFMPEG_CONF_OPTS += --disable-filters \
158 $(foreach x,$(call qstrip,$(BR2_PACKAGE_FFMPEG_FILTERS)),--enable-filter=$(x))
159 endif
161 ifeq ($(BR2_PACKAGE_FFMPEG_INDEVS),y)
162 FFMPEG_CONF_OPTS += --enable-indevs
163 else
164 FFMPEG_CONF_OPTS += --disable-indevs
165 endif
167 ifeq ($(BR2_PACKAGE_FFMPEG_OUTDEVS),y)
168 FFMPEG_CONF_OPTS += --enable-outdevs
169 else
170 FFMPEG_CONF_OPTS += --disable-outdevs
171 endif
173 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
174 FFMPEG_CONF_OPTS += --enable-pthreads
175 else
176 FFMPEG_CONF_OPTS += --disable-pthreads
177 endif
179 ifeq ($(BR2_PACKAGE_ZLIB),y)
180 FFMPEG_CONF_OPTS += --enable-zlib
181 FFMPEG_DEPENDENCIES += zlib
182 else
183 FFMPEG_CONF_OPTS += --disable-zlib
184 endif
186 ifeq ($(BR2_PACKAGE_BZIP2),y)
187 FFMPEG_CONF_OPTS += --enable-bzlib
188 FFMPEG_DEPENDENCIES += bzip2
189 else
190 FFMPEG_CONF_OPTS += --disable-bzlib
191 endif
193 ifeq ($(BR2_PACKAGE_FDK_AAC)$(BR2_PACKAGE_FFMPEG_NONFREE),yy)
194 FFMPEG_CONF_OPTS += --enable-libfdk-aac
195 FFMPEG_DEPENDENCIES += fdk-aac
196 else
197 FFMPEG_CONF_OPTS += --disable-libfdk-aac
198 endif
200 ifeq ($(BR2_PACKAGE_GNUTLS),y)
201 FFMPEG_CONF_OPTS += --enable-gnutls --disable-openssl
202 FFMPEG_DEPENDENCIES += gnutls
203 else
204 FFMPEG_CONF_OPTS += --disable-gnutls
205 ifeq ($(BR2_PACKAGE_OPENSSL),y)
206 # openssl isn't license compatible with GPL
207 ifeq ($(BR2_PACKAGE_FFMPEG_GPL)x$(BR2_PACKAGE_FFMPEG_NONFREE),yx)
208 FFMPEG_CONF_OPTS += --disable-openssl
209 else
210 FFMPEG_CONF_OPTS += --enable-openssl
211 FFMPEG_DEPENDENCIES += openssl
212 endif
213 else
214 FFMPEG_CONF_OPTS += --disable-openssl
215 endif
216 endif
218 ifeq ($(BR2_PACKAGE_FFMPEG_GPL)$(BR2_PACKAGE_LIBEBUR128),yy)
219 FFMPEG_DEPENDENCIES += libebur128
220 endif
222 ifeq ($(BR2_PACKAGE_LIBOPENH264),y)
223 FFMPEG_CONF_OPTS += --enable-libopenh264
224 FFMPEG_DEPENDENCIES += libopenh264
225 else
226 FFMPEG_CONF_OPTS += --disable-libopenh264
227 endif
229 ifeq ($(BR2_PACKAGE_LIBVORBIS),y)
230 FFMPEG_DEPENDENCIES += libvorbis
231 FFMPEG_CONF_OPTS += \
232 --enable-libvorbis \
233 --enable-muxer=ogg \
234 --enable-encoder=libvorbis
235 endif
237 ifeq ($(BR2_PACKAGE_LIBVA),y)
238 FFMPEG_CONF_OPTS += --enable-vaapi
239 FFMPEG_DEPENDENCIES += libva
240 else
241 FFMPEG_CONF_OPTS += --disable-vaapi
242 endif
244 ifeq ($(BR2_PACKAGE_LIBVDPAU),y)
245 FFMPEG_CONF_OPTS += --enable-vdpau
246 FFMPEG_DEPENDENCIES += libvdpau
247 else
248 FFMPEG_CONF_OPTS += --disable-vdpau
249 endif
251 # To avoid a circular dependency only use opencv if opencv itself does
252 # not depend on ffmpeg.
253 ifeq ($(BR2_PACKAGE_OPENCV_LIB_IMGPROC)x$(BR2_PACKAGE_OPENCV_WITH_FFMPEG),yx)
254 FFMPEG_CONF_OPTS += --enable-libopencv
255 FFMPEG_DEPENDENCIES += opencv
256 else ifeq ($(BR2_PACKAGE_OPENCV3_LIB_IMGPROC)x$(BR2_PACKAGE_OPENCV3_WITH_FFMPEG),yx)
257 FFMPEG_CONF_OPTS += --enable-libopencv
258 FFMPEG_DEPENDENCIES += opencv3
259 else
260 FFMPEG_CONF_OPTS += --disable-libopencv
261 endif
263 ifeq ($(BR2_PACKAGE_OPUS),y)
264 FFMPEG_CONF_OPTS += --enable-libopus
265 FFMPEG_DEPENDENCIES += opus
266 else
267 FFMPEG_CONF_OPTS += --disable-libopus
268 endif
270 ifeq ($(BR2_PACKAGE_LIBVPX),y)
271 FFMPEG_CONF_OPTS += --enable-libvpx
272 FFMPEG_DEPENDENCIES += libvpx
273 else
274 FFMPEG_CONF_OPTS += --disable-libvpx
275 endif
277 ifeq ($(BR2_PACKAGE_LIBASS),y)
278 FFMPEG_CONF_OPTS += --enable-libass
279 FFMPEG_DEPENDENCIES += libass
280 else
281 FFMPEG_CONF_OPTS += --disable-libass
282 endif
284 ifeq ($(BR2_PACKAGE_LIBBLURAY),y)
285 FFMPEG_CONF_OPTS += --enable-libbluray
286 FFMPEG_DEPENDENCIES += libbluray
287 else
288 FFMPEG_CONF_OPTS += --disable-libbluray
289 endif
291 ifeq ($(BR2_PACKAGE_RTMPDUMP),y)
292 FFMPEG_CONF_OPTS += --enable-librtmp
293 FFMPEG_DEPENDENCIES += rtmpdump
294 else
295 FFMPEG_CONF_OPTS += --disable-librtmp
296 endif
298 ifeq ($(BR2_PACKAGE_LAME),y)
299 FFMPEG_CONF_OPTS += --enable-libmp3lame
300 FFMPEG_DEPENDENCIES += lame
301 else
302 FFMPEG_CONF_OPTS += --disable-libmp3lame
303 endif
305 ifeq ($(BR2_PACKAGE_LIBMODPLUG),y)
306 FFMPEG_CONF_OPTS += --enable-libmodplug
307 FFMPEG_DEPENDENCIES += libmodplug
308 else
309 FFMPEG_CONF_OPTS += --disable-libmodplug
310 endif
312 ifeq ($(BR2_PACKAGE_SPEEX),y)
313 FFMPEG_CONF_OPTS += --enable-libspeex
314 FFMPEG_DEPENDENCIES += speex
315 else
316 FFMPEG_CONF_OPTS += --disable-libspeex
317 endif
319 ifeq ($(BR2_PACKAGE_LIBTHEORA),y)
320 FFMPEG_CONF_OPTS += --enable-libtheora
321 FFMPEG_DEPENDENCIES += libtheora
322 else
323 FFMPEG_CONF_OPTS += --disable-libtheora
324 endif
326 ifeq ($(BR2_PACKAGE_WAVPACK),y)
327 FFMPEG_CONF_OPTS += --enable-libwavpack
328 FFMPEG_DEPENDENCIES += wavpack
329 else
330 FFMPEG_CONF_OPTS += --disable-libwavpack
331 endif
333 # ffmpeg freetype support require fenv.h which is only
334 # available/working on glibc.
335 # The microblaze variant doesn't provide the needed exceptions
336 ifeq ($(BR2_PACKAGE_FREETYPE)$(BR2_TOOLCHAIN_USES_GLIBC)x$(BR2_microblaze),yyx)
337 FFMPEG_CONF_OPTS += --enable-libfreetype
338 FFMPEG_DEPENDENCIES += freetype
339 else
340 FFMPEG_CONF_OPTS += --disable-libfreetype
341 endif
343 ifeq ($(BR2_PACKAGE_FONTCONFIG),y)
344 FFMPEG_CONF_OPTS += --enable-fontconfig
345 FFMPEG_DEPENDENCIES += fontconfig
346 else
347 FFMPEG_CONF_OPTS += --disable-fontconfig
348 endif
350 ifeq ($(BR2_PACKAGE_X264)$(BR2_PACKAGE_FFMPEG_GPL),yy)
351 FFMPEG_CONF_OPTS += --enable-libx264
352 FFMPEG_DEPENDENCIES += x264
353 else
354 FFMPEG_CONF_OPTS += --disable-libx264
355 endif
357 ifeq ($(BR2_PACKAGE_X265)$(BR2_PACKAGE_FFMPEG_GPL),yy)
358 FFMPEG_CONF_OPTS += --enable-libx265
359 FFMPEG_DEPENDENCIES += x265
360 else
361 FFMPEG_CONF_OPTS += --disable-libx265
362 endif
364 ifeq ($(BR2_X86_CPU_HAS_MMX),y)
365 FFMPEG_CONF_OPTS += --enable-yasm
366 FFMPEG_DEPENDENCIES += host-yasm
367 else
368 ifeq ($(BR2_x86_i586),y)
369 # Needed to work around a bug with gcc 5.x:
370 # error: 'asm' operand has impossible constraints
371 FFMPEG_CONF_OPTS += --disable-inline-asm
372 endif
373 FFMPEG_CONF_OPTS += --disable-yasm
374 FFMPEG_CONF_OPTS += --disable-mmx
375 endif
377 ifeq ($(BR2_X86_CPU_HAS_SSE),y)
378 FFMPEG_CONF_OPTS += --enable-sse
379 else
380 FFMPEG_CONF_OPTS += --disable-sse
381 endif
383 ifeq ($(BR2_X86_CPU_HAS_SSE2),y)
384 FFMPEG_CONF_OPTS += --enable-sse2
385 else
386 FFMPEG_CONF_OPTS += --disable-sse2
387 endif
389 ifeq ($(BR2_X86_CPU_HAS_SSE3),y)
390 FFMPEG_CONF_OPTS += --enable-sse3
391 else
392 FFMPEG_CONF_OPTS += --disable-sse3
393 endif
395 ifeq ($(BR2_X86_CPU_HAS_SSSE3),y)
396 FFMPEG_CONF_OPTS += --enable-ssse3
397 else
398 FFMPEG_CONF_OPTS += --disable-ssse3
399 endif
401 ifeq ($(BR2_X86_CPU_HAS_SSE4),y)
402 FFMPEG_CONF_OPTS += --enable-sse4
403 else
404 FFMPEG_CONF_OPTS += --disable-sse4
405 endif
407 ifeq ($(BR2_X86_CPU_HAS_SSE42),y)
408 FFMPEG_CONF_OPTS += --enable-sse42
409 else
410 FFMPEG_CONF_OPTS += --disable-sse42
411 endif
413 ifeq ($(BR2_X86_CPU_HAS_AVX),y)
414 FFMPEG_CONF_OPTS += --enable-avx
415 else
416 FFMPEG_CONF_OPTS += --disable-avx
417 endif
419 ifeq ($(BR2_X86_CPU_HAS_AVX2),y)
420 FFMPEG_CONF_OPTS += --enable-avx2
421 else
422 FFMPEG_CONF_OPTS += --disable-avx2
423 endif
425 # Explicitly disable everything that doesn't match for ARM
426 # FFMPEG "autodetects" by compiling an extended instruction via AS
427 # This works on compilers that aren't built for generic by default
428 ifeq ($(BR2_ARM_CPU_ARMV4),y)
429 FFMPEG_CONF_OPTS += --disable-armv5te
430 endif
431 ifeq ($(BR2_ARM_CPU_ARMV6)$(BR2_ARM_CPU_ARMV7A),y)
432 FFMPEG_CONF_OPTS += --enable-armv6
433 else
434 FFMPEG_CONF_OPTS += --disable-armv6 --disable-armv6t2
435 endif
436 ifeq ($(BR2_ARM_CPU_HAS_VFPV2),y)
437 FFMPEG_CONF_OPTS += --enable-vfp
438 else
439 FFMPEG_CONF_OPTS += --disable-vfp
440 endif
441 ifeq ($(BR2_ARM_CPU_HAS_NEON),y)
442 FFMPEG_CONF_OPTS += --enable-neon
443 else
444 FFMPEG_CONF_OPTS += --disable-neon
445 endif
447 ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y)
448 ifeq ($(BR2_MIPS_SOFT_FLOAT),y)
449 FFMPEG_CONF_OPTS += --disable-mipsfpu
450 else
451 FFMPEG_CONF_OPTS += --enable-mipsfpu
452 endif
453 endif # MIPS
455 ifeq ($(BR2_POWERPC_CPU_HAS_ALTIVEC),y)
456 FFMPEG_CONF_OPTS += --enable-altivec
457 else
458 FFMPEG_CONF_OPTS += --disable-altivec
459 endif
461 ifeq ($(BR2_STATIC_LIBS),)
462 FFMPEG_CONF_OPTS += --enable-pic
463 else
464 FFMPEG_CONF_OPTS += --disable-pic
465 endif
467 # Default to --cpu=generic for MIPS architecture, in order to avoid a
468 # warning from ffmpeg's configure script.
469 ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y)
470 FFMPEG_CONF_OPTS += --cpu=generic
471 else ifneq ($(call qstrip,$(BR2_GCC_TARGET_CPU)),)
472 FFMPEG_CONF_OPTS += --cpu=$(BR2_GCC_TARGET_CPU)
473 else ifneq ($(call qstrip,$(BR2_GCC_TARGET_ARCH)),)
474 FFMPEG_CONF_OPTS += --cpu=$(BR2_GCC_TARGET_ARCH)
475 endif
478 FFMPEG_CONF_OPTS += $(call qstrip,$(BR2_PACKAGE_FFMPEG_EXTRACONF))
480 # Override FFMPEG_CONFIGURE_CMDS: FFmpeg does not support --target and others
481 define FFMPEG_CONFIGURE_CMDS
482 (cd $(FFMPEG_SRCDIR) && rm -rf config.cache && \
483 $(TARGET_CONFIGURE_OPTS) \
484 $(TARGET_CONFIGURE_ARGS) \
485 $(FFMPEG_CONF_ENV) \
486 ./configure \
487 --enable-cross-compile \
488 --cross-prefix=$(TARGET_CROSS) \
489 --sysroot=$(STAGING_DIR) \
490 --host-cc="$(HOSTCC)" \
491 --arch=$(BR2_ARCH) \
492 --target-os="linux" \
493 --disable-stripping \
494 --pkg-config="$(PKG_CONFIG_HOST_BINARY)" \
495 $(SHARED_STATIC_LIBS_OPTS) \
496 $(FFMPEG_CONF_OPTS) \
498 endef
500 $(eval $(autotools-package))