summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2010-06-27 01:11:13 +0300
committerM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2010-07-11 21:40:25 +0300
commitd2f5592e0e0d316cfc40ec676ee6e7f4e2a699fb (patch)
treef235311898deee001850034fe1b5a29ea629f300 /build
parent120b78ada7eed6424f07a688854657d0c3ad68f8 (diff)
build: Factor out a more pliable CAIRO_CC_TRY_LINK_WITH_ENV_SILENT.
Introduce a new CAIRO_CC_TRY_LINK_WITH_ENV_SILENT macro for running generic link tests with arbitrary CFLAGS/LIBS/LDFLAGS and no muttering of autoconf messages. Rewrite the previous CAIRO_CC_TRY_FLAG in terms of it.
Diffstat (limited to 'build')
-rw-r--r--build/aclocal.cairo.m431
1 files changed, 25 insertions, 6 deletions
diff --git a/build/aclocal.cairo.m4 b/build/aclocal.cairo.m4
index f271ccf9..0b686775 100644
--- a/build/aclocal.cairo.m4
+++ b/build/aclocal.cairo.m4
@@ -75,10 +75,18 @@ AC_DEFUN([CAIRO_CONFIG_COMMANDS],
], $3)
])
-dnl check compiler flags with a program and no muttering.
-AC_DEFUN([CAIRO_CC_TRY_FLAG_SILENT],
-[dnl (flags..., optional program, true-action, false-action)
-
+dnl CAIRO_CC_TRY_LINK_WITH_ENV_SILENT(env-setup, program,
+dnl true-action, false-action)
+dnl
+dnl Compile and link the program with the given environment setup.
+dnl The global cairo_cc_flag is set to "yes" or "no" according as
+dnl the link succeeded or not. The link step must complete without
+dnl warnings or errors to stderr.
+dnl
+dnl Perform true-action on success and false-action on failure.
+dnl The values of CFLAGS, LIBS, LDFLAGS are saved before env-setup
+dnl is executed and restored right before the end of the macro.
+AC_DEFUN([CAIRO_CC_TRY_LINK_WITH_ENV_SILENT],[dnl
# AC_LANG_PROGRAM() produces a main() w/o args,
# but -Wold-style-definition doesn't like that.
# We need _some_ program so that we don't get
@@ -88,14 +96,15 @@ AC_DEFUN([CAIRO_CC_TRY_FLAG_SILENT],
int main(int c, char **v) { (void)c; (void)v; return 0; }'
_save_cflags="$CFLAGS"
- CFLAGS="$CFLAGS $1"
+ _save_ldflags="$LDFLAGS"
+ _save_libs="$LIBS"
+ $1
AC_LINK_IFELSE(
[$_compile_program],
[cairo_cc_stderr=`test -f conftest.err && cat conftest.err`
cairo_cc_flag=yes],
[cairo_cc_stderr=`test -f conftest.err && cat conftest.err`
cairo_cc_flag=no])
- CFLAGS="$_save_cflags"
if test "x$cairo_cc_stderr" != "x"; then
cairo_cc_flag=no
@@ -106,6 +115,16 @@ AC_DEFUN([CAIRO_CC_TRY_FLAG_SILENT],
else
ifelse([$4], , :, [$4])
fi
+ CFLAGS="$_save_cflags"
+ LDFLAGS="$_save_ldflags"
+ LIBS="$_save_libs"
+])
+
+dnl check compiler flags with a program and no muttering.
+AC_DEFUN([CAIRO_CC_TRY_FLAG_SILENT],
+[dnl (flags..., optional program, true-action, false-action)
+ CAIRO_CC_TRY_LINK_WITH_ENV_SILENT([CFLAGS="$CFLAGS $1"],
+ [$2], [$3], [$4])
])
dnl find a -Werror equivalent