From 3afaa67190258aa4bd46c66da0aafa34e888a681 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 23 Nov 2012 01:32:21 -0500 Subject: update ax_*.m4 files from upstream Signed-off-by: Mike Frysinger --- m4/ax_append_compile_flags.m4 | 65 +++++++++++++++++++ m4/ax_append_link_flags.m4 | 63 +++++++++++++++++++ m4/ax_cflags_force_c89.m4 | 93 +++++++++++++++++++++++++++ m4/ax_cflags_no_writable_strings.m4 | 121 ++++++++++++++++++++++++++++++++++++ m4/ax_cflags_strict_prototypes.m4 | 118 +++++++++++++++++++++++++++++++++++ m4/ax_cflags_warn_all.m4 | 3 +- 6 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 m4/ax_append_compile_flags.m4 create mode 100644 m4/ax_append_link_flags.m4 create mode 100644 m4/ax_cflags_force_c89.m4 create mode 100644 m4/ax_cflags_no_writable_strings.m4 create mode 100644 m4/ax_cflags_strict_prototypes.m4 diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4 new file mode 100644 index 0000000..1f8e708 --- /dev/null +++ b/m4/ax_append_compile_flags.m4 @@ -0,0 +1,65 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# For every FLAG1, FLAG2 it is checked whether the compiler works with the +# flag. If it does, the flag is added FLAGS-VARIABLE +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. During the check the flag is always added to the +# current language's flags. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# NOTE: This macro depends on the AX_APPEND_FLAG and +# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with +# AX_APPEND_LINK_FLAGS. +# +# LICENSE +# +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 3 + +AC_DEFUN([AX_APPEND_COMPILE_FLAGS], +[AC_REQUIRE([AX_CHECK_COMPILE_FLAG]) +AC_REQUIRE([AX_APPEND_FLAG]) +for flag in $1; do + AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3]) +done +])dnl AX_APPEND_COMPILE_FLAGS diff --git a/m4/ax_append_link_flags.m4 b/m4/ax_append_link_flags.m4 new file mode 100644 index 0000000..48cbd4b --- /dev/null +++ b/m4/ax_append_link_flags.m4 @@ -0,0 +1,63 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# For every FLAG1, FLAG2 it is checked whether the linker works with the +# flag. If it does, the flag is added FLAGS-VARIABLE +# +# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is +# used. During the check the flag is always added to the linker's flags. +# +# If EXTRA-FLAGS is defined, it is added to the linker's default flags +# when the check is done. The check is thus made with the flags: "LDFLAGS +# EXTRA-FLAGS FLAG". This can for example be used to force the linker to +# issue an error when a bad flag is given. +# +# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG. +# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS. +# +# LICENSE +# +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 3 + +AC_DEFUN([AX_APPEND_LINK_FLAGS], +[AC_REQUIRE([AX_CHECK_LINK_FLAG]) +AC_REQUIRE([AX_APPEND_FLAG]) +for flag in $1; do + AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3]) +done +])dnl AX_APPEND_LINK_FLAGS diff --git a/m4/ax_cflags_force_c89.m4 b/m4/ax_cflags_force_c89.m4 new file mode 100644 index 0000000..19ada7f --- /dev/null +++ b/m4/ax_cflags_force_c89.m4 @@ -0,0 +1,93 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_cflags_force_c89.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CFLAGS_FORCE_C89 [(shellvar [,default, [A/NA]])] +# +# DESCRIPTION +# +# Try to find a compiler option that enables strict C89 mode. +# +# For the GNU CC compiler it will be -ansi -pedantic. The result is added +# to the shellvar being CFLAGS by default. +# +# Currently this macro knows about GCC, Solaris C compiler, Digital Unix C +# compiler, C for AIX Compiler, HP-UX C compiler, IRIX C compiler, NEC +# SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos 10.0.0.8) C +# compiler. +# +# - $1 shell-variable-to-add-to : CFLAGS +# - $2 add-value-if-not-found : nothing +# - $3 action-if-found : add value to shellvariable +# - $4 action-if-not-found : nothing +# +# NOTE: These macros depend on AX_APPEND_FLAG. +# +# LICENSE +# +# Copyright (c) 2009 Guido U. Draheim +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 8 + +AC_DEFUN([AX_CFLAGS_FORCE_C89],[dnl +AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl +AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_force_c89])dnl +AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for C89 mode], +VAR,[VAR="no, unknown" + AC_LANG_SAVE + AC_LANG_C + ac_save_[]FLAGS="$[]FLAGS" +for ac_arg dnl +in "-pedantic % -ansi -pedantic" dnl GCC + "-xstrconst % -v -Xc" dnl Solaris C + "-std1 % -std1" dnl Digital Unix + " % -qlanglvl=ansi" dnl AIX + " % -ansi -ansiE" dnl IRIX + "+ESlit % -Aa" dnl HP-UX C + "-Xc % -Xc" dnl NEC SX-5 (Super-UX 10) + "-h conform % -h conform" dnl Cray C (Unicos) + # +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" + AC_LANG_RESTORE +]) +AS_VAR_POPDEF([FLAGS])dnl +AC_REQUIRE([AX_APPEND_FLAG]) +case ".$VAR" in + .ok|.ok,*) m4_ifvaln($3,$3) ;; + .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; + *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; +esac +AS_VAR_POPDEF([VAR])dnl +]) diff --git a/m4/ax_cflags_no_writable_strings.m4 b/m4/ax_cflags_no_writable_strings.m4 new file mode 100644 index 0000000..2fb6f12 --- /dev/null +++ b/m4/ax_cflags_no_writable_strings.m4 @@ -0,0 +1,121 @@ +# ================================================================================= +# http://www.gnu.org/software/autoconf-archive/ax_cflags_no_writable_strings.html +# ================================================================================= +# +# SYNOPSIS +# +# AX_CFLAGS_NO_WRITABLE_STRINGS [(shellvar [,default, [A/NA]])] +# +# DESCRIPTION +# +# Try to find a compiler option that makes all string literals readonly. +# +# The sanity check is done by looking at string.h which has a set of +# strcpy definitions that should be defined with const-modifiers to not +# emit a warning in all so many places. +# +# For the GNU CC compiler it will be -fno-writable-strings -Wwrite-strings +# The result is added to the shellvar being CFLAGS by default. +# +# DEFAULTS: +# +# - $1 shell-variable-to-add-to : CFLAGS +# - $2 add-value-if-not-found : nothing +# - $3 action-if-found : add value to shellvariable +# - $4 action-if-not-found : nothing +# +# NOTE: These macros depend on AX_APPEND_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 13 + +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_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 ],[ + 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" +]) +AS_VAR_POPDEF([FLAGS])dnl +AC_REQUIRE([AX_APPEND_FLAG]) +case ".$VAR" in + .ok|.ok,*) m4_ifvaln($3,$3) ;; + .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; + *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; +esac +AS_VAR_POPDEF([VAR])dnl +])dnl AX_FLAGS_NO_WRITABLE_STRINGS + +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 +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 new file mode 100644 index 0000000..2ac34be --- /dev/null +++ b/m4/ax_cflags_strict_prototypes.m4 @@ -0,0 +1,118 @@ +# =============================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_cflags_strict_prototypes.html +# =============================================================================== +# +# SYNOPSIS +# +# AX_CFLAGS_STRICT_PROTOTYPES [(shellvar [,default, [A/NA]] +# +# DESCRIPTION +# +# Try to find a compiler option that requires strict prototypes. +# +# The sanity check is done by looking at sys/signal.h which has a set of +# macro-definitions SIG_DFL and SIG_IGN that are cast to the local +# signal-handler type. If that signal-handler type is not fully qualified +# then the system headers are not seen as strictly prototype clean. +# +# For the GNU CC compiler it will be -fstrict-prototypes +# -Wstrict-prototypes The result is added to the shellvar being CFLAGS by +# default. +# +# DEFAULTS: +# +# - $1 shell-variable-to-add-to : CFLAGS +# - $2 add-value-if-not-found : nothing +# - $3 action-if-found : add value to shellvariable +# - $4 action-if-not-found : nothing +# +# NOTE: These macros depend on AX_APPEND_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 12 + +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_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" dnl oops + # +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 ],[ + 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" +]) +AS_VAR_POPDEF([FLAGS])dnl +AC_REQUIRE([AX_APPEND_FLAG]) +case ".$VAR" in + .ok|.ok,*) m4_ifvaln($3,$3) ;; + .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; + *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; +esac +AS_VAR_POPDEF([VAR])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 c22e37f..0fa3e18 100644 --- a/m4/ax_cflags_warn_all.m4 +++ b/m4/ax_cflags_warn_all.m4 @@ -58,7 +58,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 13 +#serial 14 AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl @@ -84,6 +84,7 @@ done FLAGS="$ac_save_[]FLAGS" ]) AS_VAR_POPDEF([FLAGS])dnl +AC_REQUIRE([AX_APPEND_FLAG]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; -- cgit v1.2.3-65-gdbad