autoconf-archive-maintainers | |
[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/7] ax_cflags_*_option.m4: Use AX_CHECK_COMPILE_FLAG macro to do
From: |
Maarten Bosmans |
Subject: |
[PATCH 4/7] ax_cflags_*_option.m4: Use AX_CHECK_COMPILE_FLAG macro to do most of the work |
Date: |
Mon, 20 Jun 2011 11:24:07 +0200 |
This gets rid of the for loop and the string splitting using sed. For
gcc_option the logic is now contained in a much easier to follow if statement.
---
m4/ax_cflags_aix_option.m4 | 18 +++---------------
m4/ax_cflags_gcc_option.m4 | 22 +++++-----------------
m4/ax_cflags_hpux_option.m4 | 18 +++---------------
m4/ax_cflags_irix_option.m4 | 18 +++---------------
m4/ax_cflags_sun_option.m4 | 19 +++----------------
5 files changed, 17 insertions(+), 78 deletions(-)
diff --git a/m4/ax_cflags_aix_option.m4 b/m4/ax_cflags_aix_option.m4
index 96d2253..36219f1 100644
--- a/m4/ax_cflags_aix_option.m4
+++ b/m4/ax_cflags_aix_option.m4
@@ -66,31 +66,19 @@
#serial 9
AC_DEFUN([AX_FLAGS_AIX_OPTION_PRIVATE], [dnl
+AX_CHECK_COMPILE_FLAG([$1], [flag_ok="yes"], [flag_ok="no"], [-qlanglvl=ansi
-qsrcmsg])
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_[]_AC_LANG_ABBREV[]flags_aix_option_$1])dnl
-AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for aix/cc m4_ifval($1,$1,-option)],
-VAR,[VAR="no, unknown"
- ac_save_[]FLAGS="$[]FLAGS"
-for ac_arg dnl
-in "-qlanglvl=ansi -qsrcmsg % m4_ifval($1,$1,-option)" dnl AIX
- #
-do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
- AC_TRY_COMPILE([],[return 0;],
- [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
-done
- FLAGS="$ac_save_[]FLAGS"
-])
-case ".$VAR" in
+case ".$flag_ok" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_ifvaln($4,$4) ;;
*) m4_ifvaln($3,$3,[
+ VAR="$1"
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
fi ]) ;;
esac
-AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
])
diff --git a/m4/ax_cflags_gcc_option.m4 b/m4/ax_cflags_gcc_option.m4
index 2f16a9c..58b4564 100644
--- a/m4/ax_cflags_gcc_option.m4
+++ b/m4/ax_cflags_gcc_option.m4
@@ -75,33 +75,21 @@
#serial 14
AC_DEFUN([AX_FLAGS_GCC_OPTION_PRIVATE], [dnl
+AX_CHECK_COMPILE_FLAG([$1], [flag_ok="yes"], [flag_ok="no"], [-pedantic
-Werror])
+AS_IF([test "x$flag_ok" == "xno"],
+ [AX_CHECK_COMPILE_FLAG([$1], [flag_ok="no, obsolete"], [flag_ok="no"],
[-pedantic])])
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_[]_AC_LANG_ABBREV[]flags_gcc_option_$1])dnl
-AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
-VAR,[AS_VAR_SET([VAR],["no, unknown"])
- ac_save_[]FLAGS="$[]FLAGS"
-for ac_arg dnl
-in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC
- "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC
- #
-do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
- AC_TRY_COMPILE([],[return 0;],
- [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break])
-done
- FLAGS="$ac_save_[]FLAGS"
-])
-m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])])
-case ".$var" in
+case ".$flag_ok" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_ifvaln($4,$4) ;;
*) m4_ifvaln($3,$3,[
+ var="$1"
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $var " 2>&1 >/dev/null
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $var])
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var"])
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var"
fi ]) ;;
esac
-AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
])
diff --git a/m4/ax_cflags_hpux_option.m4 b/m4/ax_cflags_hpux_option.m4
index 04191e5..2b0594b 100644
--- a/m4/ax_cflags_hpux_option.m4
+++ b/m4/ax_cflags_hpux_option.m4
@@ -66,31 +66,19 @@
#serial 9
AC_DEFUN([AX_FLAGS_HPUX_OPTION_PRIVATE], [dnl
+AX_CHECK_COMPILE_FLAG([$1], [flag_ok="yes"], [flag_ok="no"], [+ESlit +w1 -Aa])
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_[]_AC_LANG_ABBREV[]flags_hpux_option_$1])dnl
-AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for hpux/cc m4_ifval($1,$1,-option)],
-VAR,[VAR="no, unknown"
- ac_save_[]FLAGS="$[]FLAGS"
-for ac_arg dnl
-in "+ESlit +w1 -Aa % m4_ifval($1,$1,-option)" dnl HP-UX C
- #
-do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
- AC_TRY_COMPILE([],[return 0;],
- [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
-done
- FLAGS="$ac_save_[]FLAGS"
-])
-case ".$VAR" in
+case ".$flag_ok" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_ifvaln($4,$4) ;;
*) m4_ifvaln($3,$3,[
+ VAR="$1"
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
fi ]) ;;
esac
-AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
])
diff --git a/m4/ax_cflags_irix_option.m4 b/m4/ax_cflags_irix_option.m4
index 024f601..d6fb783 100644
--- a/m4/ax_cflags_irix_option.m4
+++ b/m4/ax_cflags_irix_option.m4
@@ -66,31 +66,19 @@
#serial 9
AC_DEFUN([AX_FLAGS_IRIX_OPTION_PRIVATE], [dnl
+AX_CHECK_COMPILE_FLAG([$1], [flag_ok="yes"], [flag_ok="no"], [-fullwarn
-use_readonly_const])
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_[]_AC_LANG_ABBREV[]flags_irix_option_$1])dnl
-AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for irix/cc m4_ifval($1,$1,-option)],
-VAR,[VAR="no, unknown"
- ac_save_[]FLAGS="$[]FLAGS"
-for ac_arg dnl
-in "-fullwarn -use_readonly_const % m4_ifval($1,$1,-option)" dnl IRIX C
- #
-do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
- AC_TRY_COMPILE([],[return 0;],
- [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
-done
- FLAGS="$ac_save_[]FLAGS"
-])
-case ".$VAR" in
+case ".$flag_ok" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_ifvaln($4,$4) ;;
*) m4_ifvaln($3,$3,[
+ VAR="$1"
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
fi ]) ;;
esac
-AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
])
diff --git a/m4/ax_cflags_sun_option.m4 b/m4/ax_cflags_sun_option.m4
index 98212a1..d25cf28 100644
--- a/m4/ax_cflags_sun_option.m4
+++ b/m4/ax_cflags_sun_option.m4
@@ -66,32 +66,19 @@
#serial 10
AC_DEFUN([AX_FLAGS_SUN_OPTION_PRIVATE], [dnl
+AX_CHECK_COMPILE_FLAG([$1], [flag_ok="yes"], [flag_ok="no"], [+xstrconst -Xc])
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_[]_AC_LANG_ABBREV[]flags_sun_option_$1])dnl
-AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for sun/cc m4_ifval($1,$1,-option)],
-VAR,[AS_VAR_SET([VAR],["no, unknown"])
- ac_save_[]FLAGS="$[]FLAGS"
-for ac_arg dnl
-in "+xstrconst -Xc % m4_ifval($1,$1,-option)" dnl Solaris C
- #
-do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
- AC_TRY_COMPILE([],[return 0;],
- [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break])
-done
- FLAGS="$ac_save_[]FLAGS"
-])
-m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])])
-case ".$var" in
+case ".$flag_ok" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_ifvaln($4,$4) ;;
*) m4_ifvaln($3,$3,[
+ var="$1"
if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $var " 2>&1 >/dev/null
then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $var])
else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var"])
m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var"
fi ]) ;;
esac
-AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
])
--
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 <=
- [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, 2011/06/20
- 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