Rename the old function to test_cpp_condition and have the new
function set a variable if the test succeeds. Leverage the new
function to simplify some recurring patterns.
---
configure | 92 ++++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 53 insertions(+), 39 deletions(-)
diff --git a/configure b/configure
index 7247efd019..2008083617 100755
--- a/configure
+++ b/configure
@@ -987,8 +987,8 @@ check_func_headers(){
} | check_ld "$@" && enable $funcs && enable_sanitized $headers
}
-check_cpp_condition(){
- log check_cpp_condition "$@"
+test_cpp_condition(){
+ log test_cpp_condition "$@"
header=$1
condition=$2
shift 2
@@ -1000,6 +1000,14 @@ check_cpp_condition(){
EOF
}
+check_cpp_condition(){
+ log check_cpp_condition "$@"
+ name=$1
+ shift 1
+ disable $name
+ test_cpp_condition "$@" && enable $name
+}
+
test_cflags_cpp(){
log test_cflags_cpp "$@"
flags=$1
@@ -1146,7 +1154,7 @@ require_cpp_condition(){
header="$1"
condition="$2"
shift 2
- check_cpp_condition "$header" "$condition" "$@" || die "ERROR: $condition
not satisfied"
+ test_cpp_condition "$header" "$condition" "$@" || die "ERROR: $condition
not satisfied"
}
require_pkg_config(){
@@ -1192,8 +1200,8 @@ int x;
EOF
}
-check_host_cpp_condition(){
- log check_host_cpp_condition "$@"
+test_host_cpp_condition(){
+ log test_host_cpp_condition "$@"
header=$1
condition=$2
shift 2
@@ -1205,6 +1213,14 @@ check_host_cpp_condition(){
EOF
}
+check_host_cpp_condition(){
+ log check_host_cpp_condition "$@"
+ name=$1
+ shift 1
+ disable $name
+ test_host_cpp_condition "$@" && enable $name
+}
+
apply(){
file=$1
shift
@@ -3611,7 +3627,7 @@ elif enabled alpha; then
elif enabled arm; then
check_arm_arch() {
- check_cpp_condition stddef.h \
+ test_cpp_condition stddef.h \
"defined __ARM_ARCH_${1}__ || defined __TARGET_ARCH_${2:-$1}" \
$cpuflags
}
@@ -3820,7 +3836,7 @@ add_cppflags -D_ISOC99_SOURCE
# some compilers silently accept -std=c11, so we also need to check that the
# version macro is defined properly
-check_cpp_condition stdlib.h "__STDC_VERSION__ >= 201112L" -std=c11 &&
+test_cpp_condition stdlib.h "__STDC_VERSION__ >= 201112L" -std=c11 &&
add_cflags -std=c11 ||
check_cflags -std=c99
@@ -4090,38 +4106,38 @@ probe_libc(){
pfx=$1
pfx_no_=${pfx%_}
# uclibc defines __GLIBC__, so it needs to be checked before glibc.
- if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
+ if test_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
eval ${pfx}libc_type=uclibc
add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
- elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
+ elif test_${pfx}cpp_condition features.h "defined __GLIBC__"; then
eval ${pfx}libc_type=glibc
add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
# MinGW headers can be installed on Cygwin, so check for newlib first.
- elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
+ elif test_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
eval ${pfx}libc_type=newlib
add_${pfx}cppflags -U__STRICT_ANSI__ -D_XOPEN_SOURCE=600
# MinGW64 is backwards compatible with MinGW32, so check for it first.
- elif check_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR";
then
+ elif test_${pfx}cpp_condition _mingw.h "defined __MINGW64_VERSION_MAJOR";
then
eval ${pfx}libc_type=mingw64
add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
eval test \$${pfx_no_}cc_type = "gcc" &&
add_${pfx}cppflags -D__printf__=__gnu_printf__
- elif check_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION" ||
- check_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
+ elif test_${pfx}cpp_condition _mingw.h "defined __MINGW_VERSION" ||
+ test_${pfx}cpp_condition _mingw.h "defined __MINGW32_VERSION"; then
eval ${pfx}libc_type=mingw32
- check_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
+ test_${pfx}cpp_condition _mingw.h "__MINGW32_MAJOR_VERSION > 3 || \
(__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
die "ERROR: MinGW32 runtime version must be >= 3.15."
add_${pfx}cppflags -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1
- check_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" &&
+ test_${pfx}cpp_condition _mingw.h "__MSVCRT_VERSION__ < 0x0700" &&
add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
- check_${pfx}cpp_condition windows.h "defined(_WIN32_WINNT) &&
_WIN32_WINNT < 0x0502" &&
+ test_${pfx}cpp_condition windows.h "defined(_WIN32_WINNT) &&
_WIN32_WINNT < 0x0502" &&
add_${pfx}cppflags -D_WIN32_WINNT=0x0502
eval test \$${pfx_no_}cc_type = "gcc" &&
add_${pfx}cppflags -D__printf__=__gnu_printf__
- elif check_${pfx}cpp_condition crtversion.h "defined
_VC_CRT_MAJOR_VERSION"; then
+ elif test_${pfx}cpp_condition crtversion.h "defined
_VC_CRT_MAJOR_VERSION"; then
eval ${pfx}libc_type=msvcrt
- if check_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION <
14"; then
+ if test_${pfx}cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION < 14";
then
if [ "$pfx" = host_ ]; then
add_host_cppflags -Dsnprintf=_snprintf
else
@@ -4142,7 +4158,7 @@ probe_libc(){
# family. For these cases, configure is free to use any functions
# found in the SDK headers by default. (Alternatively, we could force
# _WIN32_WINNT to 0x0602 in that case.)
- check_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
+ test_${pfx}cpp_condition stdlib.h "defined(_WIN32_WINNT)" ||
{ check_${pfx}cpp <<EOF && add_${pfx}cppflags
-D_WIN32_WINNT=0x0502; }
#ifdef WINAPI_FAMILY
#include <winapifamily.h>
@@ -4154,11 +4170,11 @@ EOF
if [ "$pfx" = "" ]; then
check_func strtoll || add_cflags -Dstrtoll=_strtoi64
fi
- elif check_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
+ elif test_${pfx}cpp_condition stddef.h "defined __KLIBC__"; then
eval ${pfx}libc_type=klibc
- elif check_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
+ elif test_${pfx}cpp_condition sys/cdefs.h "defined __BIONIC__"; then
eval ${pfx}libc_type=bionic
- elif check_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME";
then
+ elif test_${pfx}cpp_condition sys/brand.h "defined LABELED_BRAND_NAME";
then
eval ${pfx}libc_type=solaris
add_${pfx}cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
else
@@ -4197,7 +4213,7 @@ esc(){
echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc
$LIBAV_CONFIGURATION)" > avbuild/config.fate
-check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) ||
defined(PIC)" && enable_weak pic
+test_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) ||
defined(PIC)" && enable_weak pic
set_default $PATHS_LIST
set_default nm
@@ -4306,15 +4322,15 @@ elif enabled alpha; then
elif enabled arm; then
- enabled msvc && check_cpp_condition stddef.h "defined _M_ARMT" && enable
thumb
- check_cpp_condition stddef.h "defined __thumb__" && enable_weak thumb
+ enabled msvc && test_cpp_condition thumb stddef.h "defined _M_ARMT"
+ test_cpp_condition stddef.h "defined __thumb__" && enable_weak thumb
enabled thumb && check_cflags -mthumb || check_cflags -marm
- if check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
- enable vfp_args
- elif check_cpp_condition stddef.h "defined _M_ARM_FP && _M_ARM_FP >= 30";
then
- enable vfp_args
- elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined
__SOFTFP__" && [ $target_os != darwin ]; then
+ if check_cpp_condition vfp_args stddef.h "defined __ARM_PCS_VFP"; then
+ :
+ elif check_cpp_condition vfp_args stddef.h "defined _M_ARM_FP && _M_ARM_FP
>= 30"; then
+ :
+ elif ! test_cpp_condition stddef.h "defined __ARM_PCS || defined
__SOFTFP__" && [ $target_os != darwin ]; then
case "${cross_prefix:-$cc}" in
*hardfloat*) enable vfp_args; fpabi=vfp ;;
*) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
@@ -4408,7 +4424,7 @@ elif enabled ppc; then
fi
if enabled power8; then
- check_cpp_condition "altivec.h" "defined(_ARCH_PWR8)" || disable power8
+ check_cpp_condition power8 altivec.h "defined(_ARCH_PWR8)"
fi
elif enabled x86; then
@@ -4548,7 +4564,7 @@ check_func_headers malloc.h _aligned_malloc && enable
aligned_malloc
check_func ${malloc_prefix}memalign && enable memalign
check_func ${malloc_prefix}posix_memalign && enable posix_memalign
-check_cpp_condition unistd.h "defined(_POSIX_MONOTONIC_CLOCK)" &&
+test_cpp_condition unistd.h "defined(_POSIX_MONOTONIC_CLOCK)" &&
{ check_lib clock_gettime time.h clock_gettime ||
check_lib clock_gettime time.h clock_gettime -lrt; }
@@ -4729,8 +4745,7 @@ enabled libwavpack && require libwavpack
wavpack/wavpack.h WavpackOpenFil
enabled libwebp && require_pkg_config libwebp libwebp webp/encode.h
WebPGetEncoderVersion
enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h"
x264_encoder_encode &&
require_cpp_condition x264.h "X264_BUILD >= 118"
&&
- { check_cpp_condition x264.h "X264_MPEG2" &&
- enable libx262; }
+ check_cpp_condition libx262 x264.h "X264_MPEG2"
enabled libx265 && require_pkg_config libx265 x265 x265.h
x265_api_get &&
require_cpp_condition x265.h "X265_BUILD >= 57"
enabled libxavs && require libxavs "stdint.h xavs.h"
xavs_encoder_encode -lxavs
@@ -4773,7 +4788,7 @@ check_lib user32 "windows.h winuser.h" GetShellWindow
-luser32
check_lib vfw32 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
# check that WM_CAP_DRIVER_CONNECT is defined to the proper value
# w32api 3.12 had it defined wrong
-check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable
vfwcap_defines
+check_cpp_condition vfwcap_defines vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER"
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
check_header "dev/bktr/ioctl_meteor.h dev/bktr/ioctl_bt848.h"
||
@@ -4834,8 +4849,7 @@ enabled vaapi &&
check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11
enabled vdpau &&
- check_cpp_condition vdpau/vdpau.h "defined
VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
- disable vdpau
+ check_cpp_condition vdpau vdpau/vdpau.h "defined
VDP_DECODER_PROFILE_MPEG4_PART2_ASP"
enabled vdpau &&
check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h"
vdp_device_create_x11 -lvdpau -lX11
@@ -5038,14 +5052,14 @@ elif enabled_any msvc icl; then
if enabled icl; then
# -Qansi-alias is basically -fstrict-aliasing, but does not work
# (correctly) on icl 13.x.
- check_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
+ test_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
add_cflags -Qansi-alias
# icl will pass the inline asm tests but inline asm is currently
# not supported (build will fail)
disable inline_asm
fi
# msvcrt10 x64 incorrectly enables log2, only msvcrt12 (MSVC 2013) onwards
actually has log2.
- check_cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION >= 12" || disable
log2
+ check_cpp_condition log2 crtversion.h "_VC_CRT_MAJOR_VERSION >= 12"
# The CRT headers contain __declspec(restrict) in a few places, but if
redefining
# restrict, this might break. MSVC 2010 and 2012 fail with
__declspec(__restrict)
# (as it ends up if the restrict redefine is done before including
stdlib.h), while
--
2.11.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel