Replace some manual build tests with AC_CACHE_CHECK and AC_COMPILE_IFELSE.

Instead of compiling the build tests manually, use autoconf
facilities, so that the results are cached between runs. Also avoid
linking when a simple compile test is enough.
This commit is contained in:
Diego 'Flameeyes' Pettenò 2008-08-08 14:43:37 +02:00
parent daf3e8b97d
commit 89f492a7df

View file

@ -142,17 +142,18 @@ esac
# If everything else fails use libatomic_ops # If everything else fails use libatomic_ops
need_libatomic_ops=yes need_libatomic_ops=yes
AC_MSG_CHECKING([whether $CC knows __sync_bool_compare_and_swap()]) AC_CACHE_CHECK([whether $CC knows __sync_bool_compare_and_swap()],
AC_LANG_CONFTEST([int main() { int a = 4; __sync_bool_compare_and_swap(&a, 4, 5); }]) pulseaudio_cv_sync_bool_compare_and_swap,
$CC conftest.c $CFLAGS -o conftest > /dev/null 2> /dev/null [AC_LINK_IFELSE(
ret=$? AC_LANG_PROGRAM([], [[int a = 4; __sync_bool_compare_and_swap(&a, 4, 5);]]),
rm -f conftest.o conftest [pulseaudio_cv_sync_bool_compare_and_swap=yes],
if test $ret -eq 0 ; then [pulseaudio_cv_sync_bool_compare_and_swap=no])
])
if test "$pulseaudio_cv_sync_bool_compare_and_swap" = "yes" ; then
AC_DEFINE([HAVE_ATOMIC_BUILTINS], 1, [Have __sync_bool_compare_and_swap() and friends.]) AC_DEFINE([HAVE_ATOMIC_BUILTINS], 1, [Have __sync_bool_compare_and_swap() and friends.])
AC_MSG_RESULT([yes])
need_libatomic_ops=no need_libatomic_ops=no
else else
AC_MSG_RESULT([no])
# HW specific atomic ops stuff # HW specific atomic ops stuff
AC_MSG_CHECKING([architecture for native atomic operations]) AC_MSG_CHECKING([architecture for native atomic operations])
case $host_cpu in case $host_cpu in
@ -168,10 +169,11 @@ else
need_libatomic_ops=no need_libatomic_ops=no
else else
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
AC_MSG_CHECKING([compiler support for arm inline asm atomic operations]) AC_CACHE_CHECK([compiler support for arm inline asm atomic operations],
AC_LANG_CONFTEST([[int main() pulseaudio_cv_support_arm_atomic_ops,
{ [AC_COMPILE_IFELSE(
volatile int a=0; AC_LANG_PROGRAM([],
[[volatile int a=0;
int o=0, n=1, r; int o=0, n=1, r;
asm volatile ("ldrex %0, [%1]\n" asm volatile ("ldrex %0, [%1]\n"
"subs %0, %0, %2\n" "subs %0, %0, %2\n"
@ -180,17 +182,14 @@ else
: "r" (&a), "Ir" (o), "r" (n) : "r" (&a), "Ir" (o), "r" (n)
: "cc"); : "cc");
return (a==1 ? 0 : -1); return (a==1 ? 0 : -1);
}]]) ]]),
$CC conftest.c $CFLAGS -o conftest > /dev/null 2>&1 [pulseaudio_cv_support_arm_atomic_ops=yes],
ret=$? [pulseaudio_cv_support_arm_atomic_ops=no])
rm -f conftest.o conftest ])
if test $ret -eq 0 ; then AS_IF([test "$pulseaudio_cv_support_arm_atomic_ops" = "yes"], [
AC_DEFINE([ATOMIC_ARM_INLINE_ASM], 1, [Have ARMv6 instructions.]) AC_DEFINE([ATOMIC_ARM_INLINE_ASM], 1, [Have ARMv6 instructions.])
AC_MSG_RESULT([yes])
need_libatomic_ops=no need_libatomic_ops=no
else ])
AC_MSG_RESULT([no])
fi
fi fi
;; ;;
*) *)
@ -201,17 +200,17 @@ fi
CC_CHECK_TLS CC_CHECK_TLS
AC_MSG_CHECKING([whether $CC knows _Bool]) AC_CACHE_CHECK([whether $CC knows _Bool],
AC_LANG_CONFTEST([int main() { _Bool b; }]) pulseaudio_cv__Bool,
$CC conftest.c $CFLAGS -o conftest > /dev/null 2> /dev/null [AC_COMPILE_IFELSE(
ret=$? AC_LANG_PROGRAM([], [[_Bool b;]]),
rm -f conftest.o conftest [pulseaudio_cv__Bool=yes],
if test $ret -eq 0 ; then [pulseaudio_cv__Bool=no])
])
AS_IF([test "$pulseaudio_cv__Bool" = "yes"], [
AC_DEFINE([HAVE_STD_BOOL], 1, [Have _Bool.]) AC_DEFINE([HAVE_STD_BOOL], 1, [Have _Bool.])
AC_MSG_RESULT([yes]) ])
else
AC_MSG_RESULT([no])
fi
#### libtool stuff #### #### libtool stuff ####
@ -385,20 +384,27 @@ AC_CHECK_FUNCS([setresuid setresgid setreuid setregid seteuid setegid ppoll strs
AC_FUNC_ALLOCA AC_FUNC_ALLOCA
AC_MSG_CHECKING([for PTHREAD_PRIO_INHERIT]) AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
AC_LANG_CONFTEST([AC_LANG_SOURCE([[ pulseaudio_cv_PTHREAD_PRIO_INHERIT,
#include <pthread.h> [save_CC=$CC; CC=$PTHREAD_CC
int main() { int i = PTHREAD_PRIO_INHERIT; }]])]) save_CFLAGS=$CFLAGS; CFLAGS=$PTHREAD_CFLAGS
$PTHREAD_CC conftest.c $PTHREAD_CFLAGS $CFLAGS $PTHREAD_LIBS -o conftest > /dev/null 2> /dev/null save_LIBS=$LIBS; LIBS=$PTHREAD_LIBS
ret=$? AC_LINK_IFELSE(
rm -f conftest.o conftest AC_LANG_PROGRAM(
[[
#include <pthread.h>
]],
[[int i = PTHREAD_PRIO_INHERIT;]]),
[pulseaudio_cv_PTHREAD_PRIO_INHERIT=yes],
[pulseaudio_cv_PTHREAD_PRIO_INHERIT=no])
CC=$save_CC
CFLAGS=$save_CFLAGS
LIBS=$save_LIBS
])
if test $ret -eq 0 ; then AS_IF([test "$pulseaudio_cv_PTHREAD_PRIO_INHERIT" = "yes"], [
AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]) AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])
AC_MSG_RESULT([yes]) ])
else
AC_MSG_RESULT([no])
fi
#### Large File-Support (LFS) #### #### Large File-Support (LFS) ####