2009-11-18 Chris Toshok <toshok@ximian.com>
[moon.git] / cairo / build / aclocal.cairo.m4
blobefe56aae051dc25bd6afd4323d356352c4a806bd
1 dnl ==========================================================================
2 dnl
3 dnl Cairo-specific macros
4 dnl
6 dnl ==========================================================================
8 dnl Usage:
9 dnl   CAIRO_BIGENDIAN
10 dnl
11 AC_DEFUN([CAIRO_BIGENDIAN],
12 [dnl
13         case $host_os in
14                 darwin*)
15         AH_VERBATIM([X_BYTE_ORDER],
17 /* Deal with multiple architecture compiles on Mac OS X */
18 #ifdef __APPLE_CC__
19 #ifdef __BIG_ENDIAN__
20 #define WORDS_BIGENDIAN 1
21 #define FLOAT_WORDS_BIGENDIAN 1
22 #else
23 #undef WORDS_BIGENDIAN
24 #undef FLOAT_WORDS_BIGENDIAN
25 #endif
26 #endif
28                 ;;
29                 *)
30         AC_C_BIGENDIAN
31         AX_C_FLOAT_WORDS_BIGENDIAN
32                 ;;
33         esac
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],
41 [dnl
42         _save_cflags="$CFLAGS"
43         _save_libs="$LIBS"
44         CFLAGS="$CFLAGS $2"
45         LIBS="$LIBS $3"
46         AC_CHECK_FUNCS($1, $4, $5)
47         CFLAGS="$_save_cflags"
48         LIBS="$_save_libs"
51 dnl CAIRO_CONFIG_COMMANDS is like AC_CONFIG_COMMANDS, except that:
52 dnl
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.
55 dnl
56 AC_DEFUN([CAIRO_CONFIG_COMMANDS],
57 [dnl
58         AC_CONFIG_COMMANDS($1,
59         [
60                 _config_file=$1
61                 _tmp_file=cairoconf.tmp
62                 AC_MSG_NOTICE([creating $_config_file])
63                 {
64                         $2
65                 } >> "$_tmp_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])
70                   rm -f "$_tmp_file"
71                 else
72                   mv "$_tmp_file" "$_config_file" ||
73                   AC_MSG_ERROR([failed to update $_config_file])
74                 fi
75         ], $3)
78 dnl check compiler flags
79 AC_DEFUN([CAIRO_CC_TRY_FLAG],
80 [dnl
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])
90         else
91                 ifelse([$3], , :, [$3])
92         fi
93         AC_MSG_RESULT([$cairo_cc_flag])
96 dnl check compiler/ld flags
97 AC_DEFUN([CAIRO_CC_TRY_LINK_FLAG],
98 [dnl
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;} ],
104                        [cairo_cc_flag=yes],
105                        [cairo_cc_flag=no])
106         CFLAGS="$_save_cflags"
108         if test "x$cairo_cc_flag" = "xyes"; then
109                 ifelse([$2], , :, [$2])
110         else
111                 ifelse([$3], , :, [$3])
112         fi
113         AC_MSG_RESULT([$cairo_cc_flag])
116 dnl Usage:
117 dnl   CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES
118 AC_DEFUN([CAIRO_CHECK_NATIVE_ATOMIC_PRIMITIVES],
119 [dnl
120         AC_CACHE_CHECK([for native atomic primitives], cairo_cv_atomic_primitives,
121         [
122                 cairo_cv_atomic_primitives="none"
124                 AC_TRY_LINK([
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); }
127 ], [],
128                   cairo_cv_atomic_primitives="Intel"
129                   )
130         ])
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])
134         fi
137 dnl Usage:
138 dnl   CAIRO_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER
139 AC_DEFUN([CAIRO_CHECK_ATOMIC_OP_NEEDS_MEMORY_BARRIER],
140 [dnl
141         AC_CACHE_CHECK([whether atomic ops require a memory barrier], cairo_cv_atomic_op_needs_memory_barrier,
142         [
143                 case $host_cpu in
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" ;;
148                 esac
149         ])
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])
153         fi
156 AC_DEFUN([CAIRO_TEXT_WRAP], [m4_text_wrap([$1], [$2],, 78)])