autoconf-archive-maintainers | |
[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/7] Implement AX_CHECK_*_FLAGS on top of ax_check_flag.m4 macros
From: |
Maarten Bosmans |
Subject: |
[PATCH 6/7] Implement AX_CHECK_*_FLAGS on top of ax_check_flag.m4 macros |
Date: |
Mon, 20 Jun 2011 11:24:09 +0200 |
The implementation takes care to empty the CFLAGS, to mimic previous behaviour,
but the new behaviour of AX_CHECK_COMPILE_FLAG should be better for most
situations.
---
m4/ax_check_compiler_flags.m4 | 43 ++++++++++++++++------------------------
m4/ax_check_linker_flags.m4 | 40 ++++++++++++++-----------------------
2 files changed, 32 insertions(+), 51 deletions(-)
diff --git a/m4/ax_check_compiler_flags.m4 b/m4/ax_check_compiler_flags.m4
index 35bfd2a..ab9fd70 100644
--- a/m4/ax_check_compiler_flags.m4
+++ b/m4/ax_check_compiler_flags.m4
@@ -15,6 +15,11 @@
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
+# This macro is obsolete. Use AX_CHECK_COMPILE_FLAG from ax_check_flags.m4.
+# The only difference is that AX_CHECK_COMPILE_FLAG checks for a FLAG in
+# addition to the standard CFLAGS, while this macro uses FLAGS instead of
+# CFLAGS.
+#
# LICENSE
#
# Copyright (c) 2009 Steven G. Johnson <address@hidden>
@@ -46,31 +51,17 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 9
+#serial 10
-AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
+AU_DEFUN([AX_CHECK_COMPILER_FLAGS],
[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
-AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
-dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
-AS_LITERAL_IF([$1],
- [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]), [
- ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
- _AC_LANG_PREFIX[]FLAGS="$1"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
- AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
- AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
- _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
- [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
- _AC_LANG_PREFIX[]FLAGS="$1"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
- eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
- eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
- _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
-eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])
-AC_MSG_RESULT($ax_check_compiler_flags)
-if test "x$ax_check_compiler_flags" = xyes; then
- m4_default([$2], :)
-else
- m4_default([$3], :)
-fi
-])dnl AX_CHECK_COMPILER_FLAGS
+# AX_CHECK_COMPILER_FLAGS start
+ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
+_AC_LANG_PREFIX[]FLAGS=
+AX_CHECK_COMPILE_FLAG([$1], [ax_check_compiler_flags=yes],
[ax_check_compiler_flags=no])
+_AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS
+AS_IF([test "x$ax_check_compiler_flags" == "xyes"],
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+# AX_CHECK_COMPILER_FLAGS end
+],[You might want to replace AX_CHECK_COMPILER_FLAGS from start to end with
AX_CHECK_COMPILE_FLAG([$1], [$2], [$3])])dnl AX_CHECK_COMPILER_FLAGS
diff --git a/m4/ax_check_linker_flags.m4 b/m4/ax_check_linker_flags.m4
index 894713c..4818230 100644
--- a/m4/ax_check_linker_flags.m4
+++ b/m4/ax_check_linker_flags.m4
@@ -16,6 +16,10 @@
#
# NOTE: Based on AX_CHECK_COMPILER_FLAGS.
#
+# This macro is obsolete. Use AX_CHECK_LINK_FLAG from ax_check_flags.m4.
+# The only difference is that AX_CHECK_LINK_FLAG checks for a FLAG in
addition
+# to the standard LDFLAGS, while this macro uses FLAGS instead of LDFLAGS.
+#
# LICENSE
#
# Copyright (c) 2009 Mike Frysinger <address@hidden>
@@ -50,28 +54,14 @@
#serial 6
-AC_DEFUN([AX_CHECK_LINKER_FLAGS],
-[AC_MSG_CHECKING([whether the linker accepts $1])
-dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
-AS_LITERAL_IF([$1],
- [AC_CACHE_VAL(AS_TR_SH(ax_cv_linker_flags_[$1]), [
- ax_save_FLAGS=$LDFLAGS
- LDFLAGS="$1"
- AC_LINK_IFELSE([AC_LANG_PROGRAM()],
- AS_TR_SH(ax_cv_linker_flags_[$1])=yes,
- AS_TR_SH(ax_cv_linker_flags_[$1])=no)
- LDFLAGS=$ax_save_FLAGS])],
- [ax_save_FLAGS=$LDFLAGS
- LDFLAGS="$1"
- AC_LINK_IFELSE([AC_LANG_PROGRAM()],
- eval AS_TR_SH(ax_cv_linker_flags_[$1])=yes,
- eval AS_TR_SH(ax_cv_linker_flags_[$1])=no)
- LDFLAGS=$ax_save_FLAGS])
-eval ax_check_linker_flags=$AS_TR_SH(ax_cv_linker_flags_[$1])
-AC_MSG_RESULT($ax_check_linker_flags)
-if test "x$ax_check_linker_flags" = xyes; then
- m4_default([$2], :)
-else
- m4_default([$3], :)
-fi
-])dnl AX_CHECK_LINKER_FLAGS
+AU_DEFUN([AX_CHECK_LINKER_FLAGS],
+[# AX_CHECK_LINKER_FLAGS start
+ax_save_FLAGS=$LDFLAGS
+LDFLAGS=
+AX_CHECK_LINK_FLAG([$1], [ax_check_linker_flags=yes],
[ax_check_linker_flags=no])
+LDFLAGS=$ax_save_FLAGS
+AS_IF([test "x$ax_check_linker_flags" == "xyes"],
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+# AX_CHECK_LINKER_FLAGS end
+],[You might want to replace AX_CHECK_LINKER_FLAGS from start to end with
AX_CHECK_LINK_FLAG([$1], [$2], [$3])])dnl AX_CHECK_LINKER_FLAGS
--
1.7.4.1
- Patches for implementing checking for valid CFLAGS, LDFLAGS, etc., Maarten Bosmans, 2011/06/20
- [PATCH 1/7] ax_cflags_*_option.m4: Consolidate _OLD and _NEW macros, Maarten Bosmans, 2011/06/20
- [PATCH 2/7] ax_cflags_*_option.m4: Consolidate CFLAGS and CXXFLAGS macros, Maarten Bosmans, 2011/06/20
- [PATCH 4/7] ax_cflags_*_option.m4: Use AX_CHECK_COMPILE_FLAG macro to do most of the work, Maarten Bosmans, 2011/06/20
- [PATCH 5/7] ax_cflags_*_option.m4: Use AX_APPEND_FLAG macro to append the flag, Maarten Bosmans, 2011/06/20
- [PATCH 3/7] Add ax_check_flag.m4, Maarten Bosmans, 2011/06/20
- [PATCH 7/7] Implement AX_*_CHECK_FLAG on top of ax_check_flag.m4 macros, Maarten Bosmans, 2011/06/20
- [PATCH 6/7] Implement AX_CHECK_*_FLAGS on top of ax_check_flag.m4 macros,
Maarten Bosmans <=
- Re: Patches for implementing checking for valid CFLAGS, LDFLAGS, etc., Peter Simons, 2011/06/25
- Re: Patches for implementing checking for valid CFLAGS, LDFLAGS, etc., Maarten Bosmans, 2011/06/25
- Re: Patches for implementing checking for valid CFLAGS, LDFLAGS, etc., Peter Simons, 2011/06/28
- Re: Patches for implementing checking for valid CFLAGS, LDFLAGS, etc., Maarten Bosmans, 2011/06/28
- Re: Patches for implementing checking for valid CFLAGS, LDFLAGS, etc., Peter Simons, 2011/06/30