autoconf-archive-maintainers | |
[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] Use one implementation for C/C++ in ax_cflags_*.m4
From: |
Maarten Bosmans |
Subject: |
[PATCH 3/4] Use one implementation for C/C++ in ax_cflags_*.m4 |
Date: |
Sat, 2 Jul 2011 12:06:33 +0200 |
---
m4/ax_cflags_no_writable_strings.m4 | 85 +++++--------------------
m4/ax_cflags_strict_prototypes.m4 | 82 +++++-------------------
m4/ax_cflags_warn_all.m4 | 117 +++++++---------------------------
3 files changed, 59 insertions(+), 225 deletions(-)
diff --git a/m4/ax_cflags_no_writable_strings.m4
b/m4/ax_cflags_no_writable_strings.m4
index 8406741..e1bf0ba 100644
--- a/m4/ax_cflags_no_writable_strings.m4
+++ b/m4/ax_cflags_no_writable_strings.m4
@@ -56,22 +56,21 @@
#serial 9
-AC_DEFUN([AX_CFLAGS_NO_WRITABLE_STRINGS],[dnl
-AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_no_writable_strings])dnl
+AC_DEFUN([AX_FLAGS_NO_WRITABLE_STRINGS],[dnl
+AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ax_cv_[]_AC_LANG_ABBREV[]flags_no_writable_strings])dnl
AC_CACHE_CHECK([m4_ifval([$1],[$1],FLAGS) making strings readonly],
VAR,[VAR="no, unknown"
- AC_LANG_SAVE
- AC_LANG_C
- ac_save_[]FLAGS="$[]FLAGS"
+ac_save_[]FLAGS="$[]FLAGS"
# IRIX C compiler:
# -use_readonly_const is the default for IRIX C,
# puts them into .rodata, but they are copied later.
# need to be "-G0 -rdatashared" for strictmode but
# I am not sure what effect that has really. - guidod
for ac_arg dnl
-in "-pedantic % -fno-writable-strings -Wwrite-strings" dnl GCC
- "-pedantic % -fconst-strings -Wwrite-strings" dnl newer GCC
+in "-pedantic -Werror % -fno-writable-strings -Wwrite-strings" dnl GCC
+ "-pedantic -Werror % -fconst-strings -Wwrite-strings" dnl newer GCC
+ "-pedantic % -fconst-strings %% no, const-strings is default" dnl newer GCC
"-v -Xc % -xstrconst" dnl Solaris C - strings go into readonly segment
"+w1 -Aa % +ESlit" dnl HP-UX C - strings go into readonly segment
"-w0 -std1 % -readonly_strings" dnl Digital Unix - again readonly segment
@@ -95,8 +94,7 @@ case ".$VAR" in
rm config.tmp
;;
esac
- FLAGS="$ac_save_[]FLAGS"
- AC_LANG_RESTORE
+FLAGS="$ac_save_[]FLAGS"
])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
@@ -112,65 +110,16 @@ case ".$VAR" in
esac
AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
-])
+])dnl AX_FLAGS_NO_WRITABLE_STRINGS
-dnl the only difference - the LANG selection... and the default FLAGS
+AC_DEFUN([AX_CFLAGS_NO_WRITABLE_STRINGS],[dnl
+AC_LANG_PUSH([C])
+AX_FLAGS_NO_WRITABLE_STRINGS([$1], [$2], [$3], [$4])
+AC_LANG_POP([C])
+])
AC_DEFUN([AX_CXXFLAGS_NO_WRITABLE_STRINGS],[dnl
-AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_no_writable_strings])dnl
-AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) making strings readonly],
-VAR,[VAR="no, unknown"
- AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- ac_save_[]FLAGS="$[]FLAGS"
-# IRIX C compiler:
-# -use_readonly_const is the default for IRIX C,
-# puts them into .rodata, but they are copied later.
-# need to be "-G0 -rdatashared" for strictmode but
-# I am not sure what effect that has really. - guidod
-for ac_arg dnl
-in "-pedantic -Werror % -fno-writable-strings -Wwrite-strings" dnl GCC
- "-pedantic -Werror % -fconst-strings -Wwrite-strings" dnl newer GCC
- "-pedantic % -fconst-strings %% no, const-strings is default" dnl newer GCC
- "-v -Xc % -xstrconst" dnl Solaris C - strings go into readonly segment
- "+w1 -Aa % +ESlit" dnl HP-UX C - strings go into readonly segment
- "-w0 -std1 % -readonly_strings" dnl Digital Unix - again readonly segment
- "-fullwarn -use_readonly_const %% ok, its the default" 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
-case ".$VAR" in
- .|.no|.no,*) ;;
- *) # sanity check - testing strcpy() from string.h
- cp config.log config.tmp
- AC_TRY_COMPILE([#include <string.h>],[
- char test[16];
- if (strcpy (test, "test")) return 1;],
- dnl the original did use test -n `$CC testprogram.c`
- [if test `diff config.log config.tmp | grep -i warning | wc -l` != 0
- then VAR="no, suppressed, string.h," ; fi],
- [VAR="no, suppressed, string.h"])
- rm config.tmp
- ;;
-esac
- FLAGS="$ac_save_[]FLAGS"
- AC_LANG_RESTORE
-])
-case ".$VAR" in
- .ok|.ok,*) m4_ifvaln($3,$3) ;;
- .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
- AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
- m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
- *) m4_ifvaln($3,$3,[
- if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
- then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
- else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
- m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
- fi ]) ;;
-esac
-AS_VAR_POPDEF([VAR])dnl
-AS_VAR_POPDEF([FLAGS])dnl
+AC_LANG_PUSH([C++])
+AX_FLAGS_NO_WRITABLE_STRINGS([$1], [$2], [$3], [$4])
+AC_LANG_POP([C++])
])
diff --git a/m4/ax_cflags_strict_prototypes.m4
b/m4/ax_cflags_strict_prototypes.m4
index 21abd6c..4d0fa0c 100644
--- a/m4/ax_cflags_strict_prototypes.m4
+++ b/m4/ax_cflags_strict_prototypes.m4
@@ -58,76 +58,19 @@
#serial 8
-AC_DEFUN([AX_CFLAGS_STRICT_PROTOTYPES],[dnl
-AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_strict_prototypes])dnl
-AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for strict prototypes],
-VAR,[VAR="no, unknown"
- AC_LANG_SAVE
- AC_LANG_C
- ac_save_[]FLAGS="$[]FLAGS"
-for ac_arg dnl
-in "-pedantic % -fstrict-prototypes -Wstrict-prototypes" dnl GCC
- "-pedantic % -Wstrict-prototypes" dnl try to warn atleast
- "-pedantic % -Wmissing-prototypes" dnl or another warning
- "-pedantic % -Werror-implicit-function-declaration" dnl
- "-pedantic % -Wimplicit-function-declaration" dnl
- #
-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
-case ".$VAR" in
- .|.no|.no,*) ;;
- *) # sanity check with signal() from sys/signal.h
- cp config.log config.tmp
- AC_TRY_COMPILE([#include <signal.h>],[
- if (signal (SIGINT, SIG_IGN) == SIG_DFL) return 1;
- if (signal (SIGINT, SIG_IGN) != SIG_DFL) return 2;],
- dnl the original did use test -n `$CC testprogram.c`
- [if test `diff config.log config.tmp | grep -i warning | wc -l` != 0
-then if test `diff config.log config.tmp | grep -i warning | wc -l` != 1
-then VAR="no, suppressed, signal.h," ; fi ; fi],
- [VAR="no, suppressed, signal.h"])
- rm config.tmp
- ;;
-esac
- FLAGS="$ac_save_[]FLAGS"
- AC_LANG_RESTORE
-])
-case ".$VAR" in
- .ok|.ok,*) m4_ifvaln($3,$3) ;;
- .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
- AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
- m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
- *) m4_ifvaln($3,$3,[
- if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
- then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
- else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
- m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
- fi ]) ;;
-esac
-AS_VAR_POPDEF([VAR])dnl
-AS_VAR_POPDEF([FLAGS])dnl
-])
-
-dnl the only difference - the LANG selection... and the default FLAGS
-
-AC_DEFUN([AX_CXXFLAGS_STRICT_PROTOTYPES],[dnl
-AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_strict_prototypes])dnl
+AC_DEFUN([AX_FLAGS_STRICT_PROTOTYPES],[dnl
+AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_strict_prototypes])dnl
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for strict prototypes],
VAR,[VAR="no, unknown"
- AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- ac_save_[]FLAGS="$[]FLAGS"
+ac_save_[]FLAGS="$[]FLAGS"
for ac_arg dnl
in "-pedantic -Werror % -fstrict-prototypes -Wstrict-prototypes" dnl GCC
"-pedantic -Werror % -Wstrict-prototypes" dnl try to warn atleast
"-pedantic -Werror % -Wmissing-prototypes" dnl try to warn atleast
"-pedantic -Werror % -Werror-implicit-function-declaration" dnl
"-pedantic -Werror % -Wimplicit-function-declaration" dnl
- "-pedantic % -Wstrict-prototypes %% no, unsupported in C++" dnl oops
+ "-pedantic % -Wstrict-prototypes %% no, unsupported" dnl oops
#
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
AC_TRY_COMPILE([],[return 0;],
@@ -148,8 +91,7 @@ then VAR="no, suppressed, signal.h," ; fi ; fi],
rm config.tmp
;;
esac
- FLAGS="$ac_save_[]FLAGS"
- AC_LANG_RESTORE
+FLAGS="$ac_save_[]FLAGS"
])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
@@ -165,4 +107,16 @@ case ".$VAR" in
esac
AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
+])dnl AX_FLAGS_STRICT_PROTOTYPES
+
+AC_DEFUN([AX_CFLAGS_STRICT_PROTOTYPES],[dnl
+AC_LANG_PUSH([C])
+AX_FLAGS_STRICT_PROTOTYPES([$1], [$2], [$3], [$4])
+AC_LANG_POP([C])
+])
+
+AC_DEFUN([AX_CXXFLAGS_STRICT_PROTOTYPES],[dnl
+AC_LANG_PUSH([C++])
+AX_FLAGS_STRICT_PROTOTYPES([$1], [$2], [$3], [$4])
+AC_LANG_POP([C++])
])
diff --git a/m4/ax_cflags_warn_all.m4 b/m4/ax_cflags_warn_all.m4
index 7625580..e411d04 100644
--- a/m4/ax_cflags_warn_all.m4
+++ b/m4/ax_cflags_warn_all.m4
@@ -58,97 +58,12 @@
#serial 10
-AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
-AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl
-AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
-VAR,[VAR="no, unknown"
- AC_LANG_PUSH([C])
- ac_save_[]FLAGS="$[]FLAGS"
-for ac_arg dnl
-in "-pedantic % -Wall" dnl GCC
- "-xstrconst % -v" dnl Solaris C
- "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
- "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
- "-ansi -ansiE % -fullwarn" dnl IRIX
- "+ESlit % +w1" dnl HP-UX C
- "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
- "-h conform % -h msglevel 2" dnl Cray C (Unicos)
- #
-do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
- [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
-done
- FLAGS="$ac_save_[]FLAGS"
- AC_LANG_POP([C])
-])
-case ".$VAR" in
- .ok|.ok,*) m4_ifvaln($3,$3) ;;
- .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
- AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
- m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
- *) m4_ifvaln($3,$3,[
- if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
- then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
- else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
- m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
- fi ]) ;;
-esac
-AS_VAR_POPDEF([VAR])dnl
-AS_VAR_POPDEF([FLAGS])dnl
-])
-
-dnl the only difference - the LANG selection... and the default FLAGS
-
-AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
-AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl
-AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
-VAR,[VAR="no, unknown"
- AC_LANG_PUSH([C++])
- ac_save_[]FLAGS="$[]FLAGS"
-for ac_arg dnl
-in "-pedantic % -Wall" dnl GCC
- "-xstrconst % -v" dnl Solaris C
- "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
- "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
- "-ansi -ansiE % -fullwarn" dnl IRIX
- "+ESlit % +w1" dnl HP-UX C
- "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
- "-h conform % -h msglevel 2" dnl Cray C (Unicos)
- #
-do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
- [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
-done
- FLAGS="$ac_save_[]FLAGS"
- AC_LANG_POP([C++])
-])
-case ".$VAR" in
- .ok|.ok,*) m4_ifvaln($3,$3) ;;
- .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
- AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
- m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
- *) m4_ifvaln($3,$3,[
- if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
- then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
- else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
- m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
- fi ]) ;;
-esac
-AS_VAR_POPDEF([VAR])dnl
-AS_VAR_POPDEF([FLAGS])dnl
-])
-
-dnl the only difference - the LANG selection... and the default FLAGS
-
-AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
-AS_VAR_PUSHDEF([FLAGS],[FCFLAGS])dnl
-AS_VAR_PUSHDEF([VAR],[ax_cv_fcflags_warn_all])dnl
+AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
+AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
VAR,[VAR="no, unknown"
- AC_LANG_PUSH([Fortran])
- ac_save_[]FLAGS="$[]FLAGS"
+ac_save_[]FLAGS="$[]FLAGS"
for ac_arg dnl
in "-warn all % -warn all" dnl Intel
"-pedantic % -Wall" dnl GCC
@@ -164,8 +79,7 @@ do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e
's,%%.*,,' -e 's,%,,'`
AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
done
- FLAGS="$ac_save_[]FLAGS"
- AC_LANG_POP([Fortran])
+FLAGS="$ac_save_[]FLAGS"
])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
@@ -181,8 +95,7 @@ case ".$VAR" in
esac
AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
-])
-
+])dnl AX_FLAGS_WARN_ALL
dnl implementation tactics:
dnl the for-argument contains a list of options. The first part of
dnl these does only exist to detect the compiler - usually it is
@@ -193,3 +106,21 @@ dnl like -Woption or -Xoption as they think of it is a
pass-through
dnl to later compile stages or something. The "%" is used as a
dnl delimiter. A non-option comment can be given after "%%" marks
dnl which will be shown but not added to the respective C/CXXFLAGS.
+
+AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C])
+])
+
+AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C++])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C++])
+])
+
+AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([Fortran])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([Fortran])
+])
--
1.7.4.1