Merge commit '9c37d765ef28b027414f86b0088b0c282a3c46d8'

* commit '9c37d765ef28b027414f86b0088b0c282a3c46d8':
  configure: Add check_cc/require_cc helper functions to simplify some expressions

Merged-by: James Almer <jamrial@gmail.com>
pull/283/head
James Almer 7 years ago
commit 67e8f476b7
  1. 72
      configure

72
configure vendored

@ -1398,6 +1398,14 @@ check_compile_assert(){
test_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name" test_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
} }
check_cc(){
log check_cc "$@"
name=$1
shift
disable "$name"
test_code cc "$@" && enable "$name"
}
require(){ require(){
log require "$@" log require "$@"
name_version="$1" name_version="$1"
@ -1406,6 +1414,13 @@ require(){
check_lib $name "$@" || die "ERROR: $name_version not found" 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(){ require_cpp(){
name="$1" name="$1"
headers="$2" headers="$2"
@ -5360,24 +5375,17 @@ extern_prefix=${sym%%ff_extern*}
! disabled inline_asm && check_inline_asm inline_asm '"" ::' ! disabled inline_asm && check_inline_asm inline_asm '"" ::'
for restrict_keyword in restrict __restrict__ __restrict ""; do for restrict_keyword in restrict __restrict__ __restrict ""; do
test_cc <<EOF && break test_code cc "" "char * $restrict_keyword p" && break
void foo(char * $restrict_keyword p);
EOF
done done
test_cc <<EOF && enable pragma_deprecated check_cc pragma_deprecated "" '_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")'
void foo(void) { _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") }
EOF
test_cc <<EOF || die "endian test failed" test_cc <<EOF || die "endian test failed"
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E'; unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
EOF EOF
od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
test_cc <<EOF && enable const_nan check_cc const_nan math.h "struct { double d; } static const bar[] = { { NAN } }"
#include <math.h>
void foo(void) { struct { double d; } static const bar[] = { { NAN } }; }
EOF
if ! enabled ppc64 || enabled bigendian; then if ! enabled ppc64 || enabled bigendian; then
disable vsx disable vsx
@ -5548,19 +5556,17 @@ elif enabled ppc; then
check_cflags -maltivec -mabi=altivec check_cflags -maltivec -mabi=altivec
# check if our compiler supports Motorola AltiVec C API # check if our compiler supports Motorola AltiVec C API
test_code cc altivec.h "vector signed int v1 = (vector signed int) { 0 }; check_cc altivec altivec.h "vector signed int v1 = (vector signed int) { 0 };
vector signed int v2 = (vector signed int) { 1 }; vector signed int v2 = (vector signed int) { 1 };
v1 = vec_add(v1, v2);" || v1 = vec_add(v1, v2);"
disable altivec
enabled altivec || warn "Altivec disabled, possibly missing --cpu flag" enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
fi fi
if enabled vsx; then if enabled vsx; then
check_cflags -mvsx && check_cflags -mvsx &&
test_code cc altivec.h "int v[4] = { 0 }; check_cc vsx altivec.h "int v[4] = { 0 };
vector signed int v1 = vec_vsx_ld(0, v);" || vector signed int v1 = vec_vsx_ld(0, v);"
disable vsx
fi fi
if enabled power8; then if enabled power8; then
@ -5644,7 +5650,7 @@ EOF
fi 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,--as-needed
check_ldflags -Wl,-z,noexecstack check_ldflags -Wl,-z,noexecstack
@ -5873,7 +5879,7 @@ if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
elif check_func pthread_join && check_func pthread_create; then elif check_func pthread_join && check_func pthread_create; then
enable pthreads enable pthreads
fi fi
test_code cc "pthread.h" "static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER" || disable pthreads check_cc pthreads "pthread.h" "static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER"
if enabled pthreads; then 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_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); sem_timedwait(s,0); sem_destroy(s)" $pthreads_extralibs
@ -6148,16 +6154,16 @@ rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || d
check_header linux/fb.h check_header linux/fb.h
check_header linux/videodev2.h check_header linux/videodev2.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 "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 check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;" && enable vc1_v4l2_m2m check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;" && enable mpeg1_v4l2_m2m check_cc mpeg1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG1;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;" && enable mpeg2_v4l2_m2m check_cc mpeg2_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG2;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;" && enable mpeg4_v4l2_m2m check_cc mpeg4_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_MPEG4;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC;" && enable hevc_v4l2_m2m check_cc hevc_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_HEVC;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_H263;" && enable h263_v4l2_m2m check_cc h263_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_H263;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_H264;" && enable h264_v4l2_m2m check_cc h264_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_H264;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;" && enable vp8_v4l2_m2m check_cc vp8_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;"
test_code cc linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;" && enable vp9_v4l2_m2m check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;"
check_header sys/videoio.h 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 test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
@ -6231,14 +6237,12 @@ enabled vaapi &&
check_lib vaapi va/va.h vaInitialize -lva check_lib vaapi va/va.h vaInitialize -lva
enabled vaapi && enabled vaapi &&
test_code cc "va/va.h" "vaCreateSurfaces(0, 0, 0, 0, 0, 0, 0, 0)" || check_cc vaapi "va/va.h" "vaCreateSurfaces(0, 0, 0, 0, 0, 0, 0, 0)"
disable vaapi
enabled vaapi && if enabled vaapi; then
check_lib vaapi_drm "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm 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 check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11
fi
enabled vaapi && enabled vaapi &&
check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)" check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"

Loading…
Cancel
Save