check_lib $name "$@" || die "ERROR: $name_version not found"
}
+ require_cc(){
+ log require_cc "$@"
+ name="$1"
+ shift
+ test_code cc "$@" || die "ERROR: $name failed"
+ }
+
+require_cpp(){
+ name="$1"
+ headers="$2"
+ classes="$3"
+ shift 3
+ check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
+}
+
require_header(){
log require_header "$@"
headers="$1"
! disabled inline_asm && check_inline_asm inline_asm '"" ::'
for restrict_keyword in restrict __restrict__ __restrict ""; do
- test_cc <<EOF && break
- void foo(char * $restrict_keyword p);
- EOF
+ test_code cc "" "char * $restrict_keyword p" && break
done
- test_cc <<EOF && enable pragma_deprecated
- void foo(void) { _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") }
- EOF
+ check_cc pragma_deprecated "" '_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")'
-require_cc "endian test" "" "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E'"
+test_cc <<EOF || die "endian test failed"
+unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
+EOF
od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
- test_cc <<EOF && enable const_nan
- #include <math.h>
- void foo(void) { struct { double d; } static const bar[] = { { NAN } }; }
- EOF
++check_cc const_nan math.h "struct { double d; } static const bar[] = { { NAN } }"
+
+if ! enabled ppc64 || enabled bigendian; then
+ disable vsx
+fi
+
check_gas() {
log "check_gas using '$as' as AS"
# :vararg is used on aarch64, arm and ppc altivec
fi
- test_code cc arm_neon.h "int16x8_t test = vdupq_n_s16(0)" && enable intrinsics_neon
+ check_cc intrinsics_neon arm_neon.h "int16x8_t test = vdupq_n_s16(0)"
check_ldflags -Wl,--as-needed
+check_ldflags -Wl,-z,noexecstack
if ! disabled network; then
check_func getaddrinfo $network_extralibs
# check for some common methods of building with pthread support
# do this before the optional library checks as some of them require pthreads
-if ! disabled pthreads && ! enabled w32threads; then
- if check_lib pthreads pthread.h pthread_join -pthread; then
+if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
+ if check_lib pthreads pthread.h pthread_join -pthread &&
+ check_lib pthreads pthread.h pthread_create -pthread; then
add_cflags -pthread
- elif check_lib pthreads pthread.h pthread_join -pthreads; then
+ elif check_lib pthreads pthread.h pthread_join -pthreads &&
+ check_lib pthreads pthread.h pthread_create -pthreads; then
add_cflags -pthreads
- elif check_lib pthreads pthread.h pthread_join -lpthreadGC2; then
+ elif check_lib pthreads pthread.h pthread_join -ldl -pthread &&
+ check_lib pthreads pthread.h pthread_create -ldl -pthread; then
+ add_cflags -ldl -pthread
+ elif check_lib pthreads pthread.h pthread_join -lpthreadGC2 &&
+ check_lib pthreads pthread.h pthread_create -lpthreadGC2; then
:
- elif check_lib pthreads pthread.h pthread_join -lpthread; then
+ elif check_lib pthreads pthread.h pthread_join -lpthread &&
+ check_lib pthreads pthread.h pthread_create -lpthread; then
:
- elif check_func pthread_join; then
+ elif check_func pthread_join && check_func pthread_create; then
enable pthreads
fi
- test_code cc "pthread.h" "static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER" || disable pthreads
- enabled pthreads &&
++ check_cc pthreads "pthread.h" "static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER"
+
+ if enabled pthreads; then
check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); sem_timedwait(s,0); sem_destroy(s)" $pthreads_extralibs
+ check_func pthread_cancel $pthreads_extralibs
+ fi
fi
-disabled zlib || check_lib zlib zlib.h zlibVersion -lz
-disabled bzlib || check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2
+enabled zlib && check_lib zlib zlib.h zlibVersion -lz
+enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2
+enabled lzma && check_lib lzma lzma.h lzma_version_number -llzma
# On some systems dynamic loading requires no extra linker flags
-check_lib libdl dlfcn.h dlopen || check_lib libdl dlfcn.h dlopen -ldl
+check_lib libdl dlfcn.h "dlopen dlsym" || check_lib libdl dlfcn.h "dlopen dlsym" -ldl
check_lib libm math.h sin -lm
check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
die "ERROR: openssl not found"; }
+enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/rk_mpi.h mpp_create &&
+ require_pkg_config rockchip_mpp "rockchip_mpp >= 1.3.7" rockchip/rk_mpi.h mpp_create &&
+ { enabled libdrm ||
+ die "ERROR: rkmpp requires --enable-libdrm"; }
+ }
-# SDL adds some CFLAGS that should not be part of the general CFLAGS.
-enabled avplay &&
- test_pkg_config sdl "sdl >= 1.2.1 sdl < 1.3.0" SDL_events.h SDL_PollEvent
+if enabled gcrypt; then
+ GCRYPT_CONFIG="${cross_prefix}libgcrypt-config"
+ if "${GCRYPT_CONFIG}" --version > /dev/null 2>&1; then
+ gcrypt_cflags=$("${GCRYPT_CONFIG}" --cflags)
+ gcrypt_extralibs=$("${GCRYPT_CONFIG}" --libs)
+ check_func_headers gcrypt.h gcry_mpi_new $gcrypt_cflags $gcrypt_extralibs ||
+ die "ERROR: gcrypt not found"
+ add_cflags $gcrypt_cflags
+ else
+ require gcrypt gcrypt.h gcry_mpi_new -lgcrypt
+ fi
+fi
+
+if enabled sdl2; then
+ SDL2_CONFIG="${cross_prefix}sdl2-config"
+ test_pkg_config sdl2 "sdl2 >= 2.0.1 sdl2 < 2.1.0" SDL_events.h SDL_PollEvent
+ if disabled sdl2 && "${SDL2_CONFIG}" --version > /dev/null 2>&1; then
+ sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
+ sdl2_extralibs=$("${SDL2_CONFIG}" --libs)
+ test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags &&
+ test_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x020100" $sdl2_cflags &&
+ check_func_headers SDL_events.h SDL_PollEvent $sdl2_extralibs $sdl2_cflags &&
+ enable sdl2
+ fi
+ if test $target_os = "mingw32"; then
+ sdl2_extralibs=$(filter_out '-mwindows' $sdl2_extralibs)
+ fi
+fi
+if enabled decklink; then
+ case $target_os in
+ mingw32*|mingw64*|win32|win64)
+ decklink_outdev_extralibs="$decklink_outdev_extralibs -lole32 -loleaut32"
+ decklink_indev_extralibs="$decklink_indev_extralibs -lole32 -loleaut32"
+ ;;
+ esac
+fi
+
+enabled securetransport &&
+ check_func SecIdentityCreate "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
+ check_lib securetransport "Security/SecureTransport.h Security/Security.h" "SSLCreateContext" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" ||
+ disable securetransport
+
+enabled securetransport &&
+ check_func SecItemImport "-Wl,-framework,CoreFoundation -Wl,-framework,Security"
+
+enabled schannel &&
+ check_func_headers "windows.h security.h" InitializeSecurityContext -DSECURITY_WIN32 -lsecur32 &&
+ test_cpp_condition winerror.h "defined(SEC_I_CONTEXT_EXPIRED)" &&
+ schannel_extralibs="-lsecur32" ||
+ disable schannel
+
+makeinfo --version > /dev/null 2>&1 && enable makeinfo || disable makeinfo
+enabled makeinfo \
+ && [ 0$(makeinfo --version | grep "texinfo" | sed 's/.*texinfo[^0-9]*\([0-9]*\)\..*/\1/') -ge 5 ] \
+ && enable makeinfo_html || disable makeinfo_html
+disabled makeinfo_html && texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
+perl -v > /dev/null 2>&1 && enable perl || disable perl
+pod2man --help > /dev/null 2>&1 && enable pod2man || disable pod2man
+rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
+
+# check V4L2 codecs available in the API
check_header linux/fb.h
check_header linux/videodev2.h
-check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
-
-check_header AVFoundation/AVFoundation.h
+test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
- test_code cc linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;" || disable v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" && enable vc1_v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" && enable mpeg1_v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;" && enable mpeg2_v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;" && enable mpeg4_v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC;" && enable hevc_v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_H263;" && enable h263_v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_H264;" && enable h264_v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;" && enable vp8_v4l2_m2m
- test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" && enable vp9_v4l2_m2m
++check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;"
++check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;"
++check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;"
++check_cc mpeg2_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;"
++check_cc mpeg4_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;"
++check_cc hevc_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC;"
++check_cc h263_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_H263;"
++check_cc h264_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_H264;"
++check_cc vp8_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;"
++check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;"
check_header sys/videoio.h
+test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
check_lib user32 "windows.h winuser.h" GetShellWindow -luser32
check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
#endif
EOF
-enabled vaapi && require vaapi va/va.h vaInitialize -lva
+enabled vaapi &&
+ check_lib vaapi va/va.h vaInitialize -lva
+
+enabled vaapi &&
- test_code cc "va/va.h" "vaCreateSurfaces(0, 0, 0, 0, 0, 0, 0, 0)" ||
- disable vaapi
++ check_cc vaapi "va/va.h" "vaCreateSurfaces(0, 0, 0, 0, 0, 0, 0, 0)"
- enabled vaapi &&
+ if enabled vaapi; then
- require_cc vaapi "va/va.h" "vaCreateSurfaces(0, 0, 0, 0, 0, 0, 0, 0)"
- check_lib vaapi_drm "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm
- check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11
+ check_lib vaapi_drm "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm
-
- enabled vaapi &&
+ check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11
+ fi
enabled vaapi &&
- test_cpp_condition "va/va.h" "VA_CHECK_VERSION(1, 0, 0)" &&
- enable vaapi_1
+ check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"
+
+if enabled_all opencl libdrm ; then
+ check_type "CL/cl_intel.h" "clCreateImageFromFdINTEL_fn" &&
+ enable opencl_drm_beignet
+ check_func_headers "CL/cl_ext.h" clImportMemoryARM &&
+ enable opencl_drm_arm
+fi
+
+if enabled_all opencl vaapi ; then
+ enabled opencl_drm_beignet && enable opencl_vaapi_beignet
+ if enabled libmfx ; then
+ check_type "CL/cl.h CL/va_ext.h" "clCreateFromVA_APIMediaSurfaceINTEL_fn" &&
+ enable opencl_vaapi_intel_media
+ fi
+fi
+
+if enabled_all opencl dxva2 ; then
+ check_type "CL/cl_dx9_media_sharing.h" cl_dx9_surface_info_khr &&
+ enable opencl_dxva2
+fi
+
+if enabled_all opencl d3d11va ; then
+ check_type "CL/cl_d3d11.h" clGetDeviceIDsFromD3D11KHR_fn &&
+ enable opencl_d3d11
+fi
enabled vdpau &&
check_cpp_condition vdpau vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP"