1 dnl ==========================================================================
3 dnl Cairo-specific macros
6 dnl ==========================================================================
11 AC_DEFUN([CAIRO_BIGENDIAN],
15 AH_VERBATIM([X_BYTE_ORDER],
17 /* Deal with multiple architecture compiles on Mac OS X */
20 #define WORDS_BIGENDIAN 1
21 #define FLOAT_WORDS_BIGENDIAN 1
23 #undef WORDS_BIGENDIAN
24 #undef FLOAT_WORDS_BIGENDIAN
31 AX_C_FLOAT_WORDS_BIGENDIAN
36 dnl CAIRO_CHECK_FUNCS_WITH_FLAGS(FUNCTION..., CFLAGS, LIBS
37 dnl [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
38 dnl Like AC_CHECK_FUNCS but with additional CFLAGS and LIBS
39 dnl --------------------------------------------------------------------
40 AC_DEFUN([CAIRO_CHECK_FUNCS_WITH_FLAGS],
42 _save_cflags="$CFLAGS"
46 AC_CHECK_FUNCS($1, $4, $5)
47 CFLAGS="$_save_cflags"
51 dnl CAIRO_CONFIG_COMMANDS is like AC_CONFIG_COMMANDS, except that:
53 dnl 1) It redirects the stdout of the command to the file.
54 dnl 2) It does not recreate the file if contents didn't change.
56 AC_DEFUN([CAIRO_CONFIG_COMMANDS],
58 AC_CONFIG_COMMANDS($1,
61 _tmp_file=cairoconf.tmp
62 AC_MSG_NOTICE([creating $_config_file])
66 AC_MSG_ERROR([failed to write to $_tmp_file])
68 if cmp -s "$_tmp_file" "$_config_file"; then
69 AC_MSG_NOTICE([$_config_file is unchanged])
72 mv "$_tmp_file" "$_config_file" ||
73 AC_MSG_ERROR([failed to update $_config_file])
78 dnl check compiler flags
79 AC_DEFUN([CAIRO_CC_TRY_FLAG],
81 AC_MSG_CHECKING([whether $CC supports $1])
83 _save_cflags="$CFLAGS"
84 CFLAGS="$CFLAGS -Werror $1"
85 AC_COMPILE_IFELSE([ ], [cairo_cc_flag=yes], [cairo_cc_flag=no])
86 CFLAGS="$_save_cflags"
88 if test "x$cairo_cc_flag" = "xyes"; then
89 ifelse([$2], , :, [$2])
91 ifelse([$3], , :, [$3])
93 AC_MSG_RESULT([$cairo_cc_flag])
96 dnl check compiler/ld flags
97 AC_DEFUN([CAIRO_CC_TRY_LINK_FLAG],
99 AC_MSG_CHECKING([whether $CC supports $1])
101 _save_cflags="$CFLAGS"
102 CFLAGS="$CFLAGS -Werror $1"
103 AC_LINK_IFELSE([int main(void){ return 0;} ],
106 CFLAGS="$_save_cflags"
108 if test "x$cairo_cc_flag" = "xyes"; then
109 ifelse([$2], , :, [$2])
111 ifelse([$3], , :, [$3])
113 AC_MSG_RESULT([$cairo_cc_flag])
117 dnl CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES
118 AC_DEFUN([CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES],
120 AC_CACHE_CHECK([for native atomic primitives], cairo_cv_atomic_primitives,
122 cairo_cv_atomic_primitives="none"
125 int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }
126 int atomic_cmpxchg(int i, int j, int k) { return __sync_val_compare_and_swap (&i, j, k); }
128 cairo_cv_atomic_primitives="Intel"
131 if test "x$cairo_cv_atomic_primitives" = xIntel; then
132 AC_DEFINE(HAVE_INTEL_ATOMIC_PRIMITIVES, 1,
133 [Enable if your compiler supports the Intel __sync_* atomic primitives])
138 dnl CAIRO_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER
139 AC_DEFUN([CAIRO_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER],
141 AC_CACHE_CHECK([whether atomic ops require a memory barrier], cairo_cv_atomic_op_needs_memory_barrier,
144 i?86) cairo_cv_atomic_op_needs_memory_barrier="no" ;;
145 x86_64) cairo_cv_atomic_op_needs_memory_barrier="no" ;;
146 arm*) cairo_cv_atomic_op_needs_memory_barrier="no" ;;
147 *) cairo_cv_atomic_op_needs_memory_barrier="yes" ;;
150 if test "x$cairo_cv_atomic_op_needs_memory_barrier" = "xyes"; then
151 AC_DEFINE_UNQUOTED(ATOMIC_OP_NEEDS_MEMORY_BARRIER, 1,
152 [whether memory barriers are needed around atomic operations])
156 AC_DEFUN([CAIRO_TEXT_WRAP], [m4_text_wrap([$1], [$2],, 78)])