Tweak configure.ac to support cross-compiling.

Submitted by Andreas Vinsander.
This commit is contained in:
Jason Evans 2012-03-05 12:15:36 -08:00
parent c71b9946ce
commit 6684cacfa8

View File

@ -14,7 +14,7 @@ if test "x${CFLAGS}" = "x" ; then
else else
CFLAGS="${CFLAGS} $1" CFLAGS="${CFLAGS} $1"
fi fi
AC_RUN_IFELSE([AC_LANG_PROGRAM( AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[ [[
]], [[ ]], [[
return 0; return 0;
@ -28,14 +28,12 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM(
dnl JE_COMPILABLE(label, hcode, mcode, rvar) dnl JE_COMPILABLE(label, hcode, mcode, rvar)
AC_DEFUN([JE_COMPILABLE], AC_DEFUN([JE_COMPILABLE],
[ [
AC_MSG_CHECKING([whether $1 is compilable]) AC_CACHE_CHECK([whether $1 is compilable],
AC_RUN_IFELSE([AC_LANG_PROGRAM( [$4],
[$2], [$3])], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2],
AC_MSG_RESULT([yes]) [$3])],
[$4="yes"], [$4=yes],
AC_MSG_RESULT([no]) [$4=no])])
[$4="no"]
)
]) ])
dnl ============================================================================ dnl ============================================================================
@ -154,15 +152,15 @@ case "${host_cpu}" in
;; ;;
i686) i686)
JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]],
[asm]) [je_cv_asm])
if test "x${asm}" = "xyes" ; then if test "x${je_cv_asm}" = "xyes" ; then
CPU_SPINWAIT='__asm__ volatile("pause")' CPU_SPINWAIT='__asm__ volatile("pause")'
fi fi
;; ;;
x86_64) x86_64)
JE_COMPILABLE([__asm__ syntax], [], JE_COMPILABLE([__asm__ syntax], [],
[[__asm__ volatile("pause"); return 0;]], [asm]) [[__asm__ volatile("pause"); return 0;]], [je_cv_asm])
if test "x${asm}" = "xyes" ; then if test "x${je_cv_asm}" = "xyes" ; then
CPU_SPINWAIT='__asm__ volatile("pause")' CPU_SPINWAIT='__asm__ volatile("pause")'
fi fi
;; ;;
@ -254,8 +252,8 @@ AC_SUBST([so])
JE_COMPILABLE([__attribute__ syntax], JE_COMPILABLE([__attribute__ syntax],
[static __attribute__((unused)) void foo(void){}], [static __attribute__((unused)) void foo(void){}],
[], [],
[attribute]) [je_cv_attribute])
if test "x${attribute}" = "xyes" ; then if test "x${je_cv_attribute}" = "xyes" ; then
AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
JE_CFLAGS_APPEND([-fvisibility=hidden]) JE_CFLAGS_APPEND([-fvisibility=hidden])
@ -267,8 +265,8 @@ JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
#include <sys/mman.h> #include <sys/mman.h>
], [ ], [
void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0); void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
], [mremap_fixed]) ], [je_cv_mremap_fixed])
if test "x${mremap_fixed}" = "xyes" ; then if test "x${je_cv_mremap_fixed}" = "xyes" ; then
AC_DEFINE([JEMALLOC_MREMAP_FIXED]) AC_DEFINE([JEMALLOC_MREMAP_FIXED])
fi fi
@ -672,12 +670,14 @@ if test "x$enable_xmalloc" = "x1" ; then
fi fi
AC_SUBST([enable_xmalloc]) AC_SUBST([enable_xmalloc])
AC_MSG_CHECKING([STATIC_PAGE_SHIFT]) AC_CACHE_CHECK([STATIC_PAGE_SHIFT],
[je_cv_static_page_shift],
AC_RUN_IFELSE([AC_LANG_PROGRAM( AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[#include <stdio.h> [[#include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <strings.h> #include <strings.h>
]], [[ ]],
[[
long result; long result;
FILE *f; FILE *f;
@ -694,10 +694,14 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM(
return 0; return 0;
]])], ]])],
[STATIC_PAGE_SHIFT=`cat conftest.out`] [je_cv_static_page_shift=`cat conftest.out`],
AC_MSG_RESULT([$STATIC_PAGE_SHIFT]) [je_cv_static_page_shift=undefined]))
AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$STATIC_PAGE_SHIFT]),
AC_MSG_RESULT([error])) if test "x$je_cv_static_page_shift" != "xundefined"; then
AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift])
else
AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT])
fi
dnl ============================================================================ dnl ============================================================================
dnl jemalloc configuration. dnl jemalloc configuration.
@ -761,7 +765,7 @@ enable_tls="1"
) )
if test "x${enable_tls}" = "x1" ; then if test "x${enable_tls}" = "x1" ; then
AC_MSG_CHECKING([for TLS]) AC_MSG_CHECKING([for TLS])
AC_RUN_IFELSE([AC_LANG_PROGRAM( AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[ [[
__thread int x; __thread int x;
]], [[ ]], [[
@ -782,9 +786,19 @@ dnl ============================================================================
dnl Check for ffsl(3), and fail if not found. This function exists on all dnl Check for ffsl(3), and fail if not found. This function exists on all
dnl platforms that jemalloc currently has a chance of functioning on without dnl platforms that jemalloc currently has a chance of functioning on without
dnl modification. dnl modification.
JE_COMPILABLE([a program using ffsl],
AC_CHECK_FUNC([ffsl], [], [
[AC_MSG_ERROR([Cannot build without ffsl(3)])]) #include <string.h>
],
[
{
int rv = ffsl(0x08);
}
],
[je_cv_function_ffsl])
if test "x${je_cv_function_ffsl}" != "xyes" ; then
AC_MSG_ERROR([Cannot build without ffsl(3)])
fi
dnl ============================================================================ dnl ============================================================================
dnl Check for atomic(3) operations as provided on Darwin. dnl Check for atomic(3) operations as provided on Darwin.
@ -803,8 +817,8 @@ JE_COMPILABLE([Darwin OSAtomic*()], [
volatile int64_t *x64p = &x64; volatile int64_t *x64p = &x64;
OSAtomicAdd64(1, x64p); OSAtomicAdd64(1, x64p);
} }
], [osatomic]) ], [je_cv_osatomic])
if test "x${osatomic}" = "xyes" ; then if test "x${je_cv_osatomic}" = "xyes" ; then
AC_DEFINE([JEMALLOC_OSATOMIC]) AC_DEFINE([JEMALLOC_OSATOMIC])
fi fi
@ -818,8 +832,8 @@ JE_COMPILABLE([Darwin OSSpin*()], [
OSSpinLock lock = 0; OSSpinLock lock = 0;
OSSpinLockLock(&lock); OSSpinLockLock(&lock);
OSSpinLockUnlock(&lock); OSSpinLockUnlock(&lock);
], [osspin]) ], [je_cv_osspin])
if test "x${osspin}" = "xyes" ; then if test "x${je_cv_osspin}" = "xyes" ; then
AC_DEFINE([JEMALLOC_OSSPIN]) AC_DEFINE([JEMALLOC_OSSPIN])
fi fi