Cleanup configure.in macros

This commit is contained in:
Behdad Esfahbod 2008-09-04 16:00:40 -04:00
parent 0e01534bf0
commit 44155f7e59
6 changed files with 144 additions and 123 deletions

View file

@ -124,18 +124,19 @@ dnl
AC_DEFUN([CAIRO_BIGENDIAN], [
case $host_os in
darwin*)
AH_VERBATIM([X_BYTE_ORDER],[
/* Deal with multiple architecture compiles on Mac OS X */
#ifdef __APPLE_CC__
#ifdef __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#define FLOAT_WORDS_BIGENDIAN 1
#else
#undef WORDS_BIGENDIAN
#undef FLOAT_WORDS_BIGENDIAN
#endif
#endif
])
AH_VERBATIM([X_BYTE_ORDER],
[
/* Deal with multiple architecture compiles on Mac OS X */
#ifdef __APPLE_CC__
#ifdef __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#define FLOAT_WORDS_BIGENDIAN 1
#else
#undef WORDS_BIGENDIAN
#undef FLOAT_WORDS_BIGENDIAN
#endif
#endif
])
;;
*)
AC_C_BIGENDIAN
@ -150,13 +151,13 @@ dnl Like AC_CHECK_FUNCS but with additional CFLAGS and LIBS
dnl --------------------------------------------------------------------
AC_DEFUN([CAIRO_CHECK_FUNCS_WITH_FLAGS],
[
_save_cflags="$CFLAGS"
_save_libs="$LIBS"
CFLAGS="$CFLAGS $2"
LIBS="$LIBS $3"
AC_CHECK_FUNCS($1, $4, $5)
CFLAGS="$_save_cflags"
LIBS="$_save_libs"
_save_cflags="$CFLAGS"
_save_libs="$LIBS"
CFLAGS="$CFLAGS $2"
LIBS="$LIBS $3"
AC_CHECK_FUNCS($1, $4, $5)
CFLAGS="$_save_cflags"
LIBS="$_save_libs"
])
dnl CAIRO_CONFIG_COMMANDS is like AC_CONFIG_COMMANDS, except that:
@ -164,7 +165,8 @@ dnl
dnl 1) It redirects the stdout of the command to the file.
dnl 2) It does not recreate the file if contents didn't change.
dnl
AC_DEFUN([CAIRO_CONFIG_COMMANDS], [
AC_DEFUN([CAIRO_CONFIG_COMMANDS],
[
AC_CONFIG_COMMANDS($1,
[
_config_file=$1
@ -172,7 +174,9 @@ AC_DEFUN([CAIRO_CONFIG_COMMANDS], [
AC_MSG_NOTICE([creating $_config_file])
{
$2
} >> "$_tmp_file"
} >> "$_tmp_file" ||
AC_MSG_ERROR([failed to write to $_tmp_file])
if cmp -s "$_tmp_file" "$_config_file"; then
AC_MSG_NOTICE([$_config_file is unchanged])
rm -f "$_tmp_file"
@ -184,21 +188,58 @@ AC_DEFUN([CAIRO_CONFIG_COMMANDS], [
])
dnl check compiler flags
AC_DEFUN([CAIRO_CC_TRY_FLAG], [
AC_MSG_CHECKING([whether $CC supports $1])
AC_DEFUN([CAIRO_CC_TRY_FLAG],
[
AC_MSG_CHECKING([whether $CC supports $1])
_save_cflags="$CFLAGS"
CFLAGS="$CFLAGS -Werror $1"
_save_cflags="$CFLAGS"
CFLAGS="$CFLAGS -Werror $1"
AC_COMPILE_IFELSE([ ], [cairo_cc_flag=yes], [cairo_cc_flag=no])
CFLAGS="$_save_cflags"
AC_COMPILE_IFELSE([ ], [cairo_cc_flag=yes], [cairo_cc_flag=no])
CFLAGS="$_save_cflags"
if test "x$cairo_cc_flag" = "xyes"; then
ifelse([$2], , :, [$2])
else
ifelse([$3], , :, [$3])
fi
AC_MSG_RESULT([$cairo_cc_flag])
])
if test "x$cairo_cc_flag" = "xyes"; then
ifelse([$2], , :, [$2])
else
ifelse([$3], , :, [$3])
fi
AC_MSG_RESULT([$cairo_cc_flag])
dnl Usage:
dnl CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES
AC_DEFUN([CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES],
[
AC_CACHE_CHECK([for native atomic primitives], cairo_cv_atomic_primitives,
[
cairo_cv_atomic_primitives="none"
AC_TRY_LINK([int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }], [],
cairo_cv_atomic_primitives="Intel"
)
])
if test "x$cairo_cv_atomic_primitives" = xIntel; then
AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1,
[Enable if your compiler supports the Intel __sync_* atomic primitives])
fi
])
dnl Usage:
dnl CAIRO_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER
AC_DEFUN([CAIRO_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER],
[
AC_CACHE_CHECK([whether atomic ops require a memory barrier], cairo_cv_atomic_op_needs_memory_barrier,
[
case $host_cpu in
i?86) cairo_cv_atomic_op_needs_memory_barrier="no" ;;
x86_64) cairo_cv_atomic_op_needs_memory_barrier="no" ;;
arm*) cairo_cv_atomic_op_needs_memory_barrier="no" ;;
*) cairo_cv_atomic_op_needs_memory_barrier="yes" ;;
esac
])
if test "x$cairo_cv_atomic_op_needs_memory_barrier" = "xyes"; then
AC_DEFINE_UNQUOTED(ATOMIC_OP_NEEDS_MEMORY_BARRIER, 1,
[whether memory barriers are needed around atomic operations])
fi
])
dnl Parse Version.mk and declare m4 variables out of it

View file

@ -1,5 +1,9 @@
AC_CHECK_LIBM
LIBS="$LIBS $LIBM"
dnl
dnl These are the facilities for enable/disabling various backends/features,
dnl and for collecting CFLAGS/LIBS and generating per backend/feature .pc
dnl files, assembling list of source files to compile, and creating
dnl cairo-features.h and other generated files.
dnl
dnl ===========================================================================
dnl
@ -189,7 +193,7 @@ CAIRO_NO_FEATURES=""
CAIRO_SUPPORTED_FEATURES=""
CAIRO_REQUIRES=""
CAIRO_NONPKGCONFIG_CFLAGS=""
CAIRO_NONPKGCONFIG_LIBS="$LIBM"
CAIRO_NONPKGCONFIG_LIBS="$LIBS"
CAIRO_LDADD=""
CAIRO_CFLAGS=$CAIRO_NONPKGCONFIG_CFLAGS
CAIRO_LIBS=$CAIRO_NONPKGCONFIG_LIBS
@ -218,7 +222,6 @@ AC_SUBST(CAIRO_NONPKGCONFIG_LIBS)
AC_SUBST(CAIRO_CFLAGS)
AC_SUBST(CAIRO_LDADD)
AC_SUBST(CAIRO_LIBS)
AC_SUBST(CAIROPERF_LIBS)
CAIRO_CONFIG_COMMANDS([$srcdir/src/Config.mk],
[echo "$CAIRO_CONFIG_AMAKE"],

View file

@ -1,86 +1,15 @@
dnl
dnl Check for functions, headers, libraries, etc go here
dnl Non-failing checks for functions, headers, libraries, etc go here
dnl
dnl ====================================================================
dnl Feature checks
dnl ====================================================================
AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = "xyes")
CAIRO_BIGENDIAN
AC_STDC_HEADERS
dnl Checks for precise integer types
AC_CHECK_HEADERS([stdint.h signal.h setjmp.h inttypes.h sys/int_types.h])
AC_CHECK_TYPES([uint64_t, uint128_t])
dnl Check for socket support for any2ppm daemon
AC_CHECK_HEADERS([fcntl.h unistd.h signal.h sys/stat.h sys/socket.h sys/poll.h sys/un.h])
dnl Checks for misc headers
AC_CHECK_HEADERS([libgen.h byteswap.h])
dnl check for CPU affinity support
AC_CHECK_HEADERS([sched.h], [
AC_CHECK_FUNCS([sched_getaffinity], [
AC_DEFINE([HAVE_SCHED_GETAFFINITY], [1],
[Define to 1 if you have Linux compatible sched_getaffinity])
])
])
AC_CHECK_FUNCS(vasnprintf link ctime_r drand48 flockfile)
AC_CHECK_LIB(rt, sched_yield, [RT_LIBS=-lrt], [RT_LIBS=])
CAIROPERF_LIBS=$RT_LIBS
# check for GNU-extensions to fenv
AC_CHECK_HEADER(fenv.h, [AC_CHECK_FUNCS(feenableexcept fedisableexcept)])
AC_MSG_CHECKING([for Sun Solaris (non-POSIX ctime_r)])
case "$host" in
*-*-solaris*)
CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
solaris_posix_pthread=yes
;;
*)
solaris_posix_pthread=no
;;
esac
AC_MSG_RESULT([$solaris_posix_pthread])
dnl ===========================================================================
dnl
dnl Test for native atomic operations.
dnl
AC_CACHE_CHECK([for native atomic primitives], cairo_cv_atomic_primitives, [
cairo_cv_atomic_primitives="none"
AC_TRY_LINK([int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }], [],
cairo_cv_atomic_primitives="Intel"
)
])
if test "x$cairo_cv_atomic_primitives" = xIntel; then
AC_DEFINE(CAIRO_HAS_INTEL_ATOMIC_PRIMITIVES, 1, [Enable if your compiler supports the Intel __sync_* atomic primitives])
fi
AC_CACHE_CHECK([whether atomic ops require a memory barrier], cairo_cv_atomic_op_needs_memory_barrier, [
case $host_cpu in
i?86)
cairo_cv_atomic_op_needs_memory_barrier="no"
;;
x86_64)
cairo_cv_atomic_op_needs_memory_barrier="no"
;;
arm*)
cairo_cv_atomic_op_needs_memory_barrier="no"
;;
*)
cairo_cv_atomic_op_needs_memory_barrier="yes"
;;
esac
])
if test "x$cairo_cv_atomic_op_needs_memory_barrier" = "xyes"; then
AC_DEFINE_UNQUOTED(CAIRO_ATOMIC_OP_NEEDS_MEMORY_BARRIER, 1,
[whether Cairo needs memory barriers around atomic ops])
fi
CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES
CAIRO_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER
AC_MSG_CHECKING([for native Win32])
case "$host" in
@ -94,5 +23,52 @@ esac
AC_MSG_RESULT([$cairo_os_win32])
AM_CONDITIONAL(OS_WIN32, test "$cairo_os_win32" = "yes")
AC_MSG_CHECKING([for Sun Solaris (non-POSIX ctime_r)])
case "$host" in
*-*-solaris*)
CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
solaris_posix_pthread=yes
;;
*)
solaris_posix_pthread=no
;;
esac
AC_MSG_RESULT([$solaris_posix_pthread])
dnl ====================================================================
dnl Library checks
dnl ====================================================================
AC_CHECK_LIBM
LIBS="$LIBS $LIBM"
AC_CHECK_LIB(rt, sched_yield, [RT_LIBS=-lrt], [RT_LIBS=])
CAIROPERF_LIBS=$RT_LIBS
AC_SUBST(CAIROPERF_LIBS)
dnl ====================================================================
dnl Header/function checks
dnl ====================================================================
dnl Checks for precise integer types
AC_CHECK_HEADERS([stdint.h inttypes.h sys/int_types.h])
AC_CHECK_TYPES([uint64_t, uint128_t])
dnl Check for socket support for any2ppm daemon
AC_CHECK_HEADERS([fcntl.h unistd.h signal.h sys/stat.h sys/socket.h sys/poll.h sys/un.h])
dnl check for CPU affinity support
AC_CHECK_HEADERS([sched.h],
[AC_CHECK_FUNCS([sched_getaffinity])])
dnl check for GNU-extensions to fenv
AC_CHECK_HEADER(fenv.h,
[AC_CHECK_FUNCS(feenableexcept fedisableexcept)])
dnl check for misc headers and functions
AC_CHECK_HEADERS([libgen.h byteswap.h signal.h setjmp.h])
AC_CHECK_FUNCS([vasnprintf link ctime_r drand48 flockfile])
dnl check for win32 headers (this detects mingw as well)
AC_CHECK_HEADERS([windows.h], have_windows=yes, have_windows=no)

View file

@ -41,11 +41,13 @@
#include "config.h"
#endif
# include "cairo-compiler-private.h"
CAIRO_BEGIN_DECLS
#define CAIRO_HAS_ATOMIC_OPS 1
#if HAVE_INTEL_ATOMIC_PRIMITIVES
#if CAIRO_HAS_INTEL_ATOMIC_PRIMITIVES
#define CAIRO_HAS_ATOMIC_OPS 1
typedef int cairo_atomic_int_t;
@ -53,11 +55,10 @@ typedef int cairo_atomic_int_t;
# define _cairo_atomic_int_dec_and_test(x) (__sync_fetch_and_add(x, -1) == 1)
# define _cairo_atomic_int_cmpxchg(x, oldv, newv) __sync_val_compare_and_swap (x, oldv, newv)
#else
#endif
# include "cairo-compiler-private.h"
# undef CAIRO_HAS_ATOMIC_OPS
#ifndef CAIRO_HAS_ATOMIC_OPS
typedef int cairo_atomic_int_t;
@ -73,7 +74,7 @@ _cairo_atomic_int_cmpxchg (int *x, int oldv, int newv);
#endif
#ifdef CAIRO_ATOMIC_OP_NEEDS_MEMORY_BARRIER
#ifdef ATOMIC_OP_NEEDS_MEMORY_BARRIER
# include "cairo-compiler-private.h"

View file

@ -73,7 +73,7 @@ _cairo_atomic_int_cmpxchg (int *x, int oldv, int newv)
#endif
#ifdef CAIRO_ATOMIC_OP_NEEDS_MEMORY_BARRIER
#ifdef ATOMIC_OP_NEEDS_MEMORY_BARRIER
int
_cairo_atomic_int_get (int *x)
{

View file

@ -47,7 +47,7 @@ CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_font_map_mutex);
CAIRO_MUTEX_DECLARE (_cairo_xlib_display_mutex);
#endif
#if !defined (CAIRO_HAS_ATOMIC_OPS) || defined (CAIRO_ATOMIC_OP_NEEDS_MEMORY_BARRIER)
#if !defined (CAIRO_HAS_ATOMIC_OPS) || defined (ATOMIC_OP_NEEDS_MEMORY_BARRIER)
CAIRO_MUTEX_DECLARE (_cairo_atomic_mutex);
#endif