acinclude/ax_check_compiler_flags.m4
changeset 5029 5d7d48157be7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/acinclude/ax_check_compiler_flags.m4	Tue Jan 18 22:40:45 2011 -0800
     1.3 @@ -0,0 +1,76 @@
     1.4 +# ===========================================================================
     1.5 +#  http://www.gnu.org/software/autoconf-archive/ax_check_compiler_flags.html
     1.6 +# ===========================================================================
     1.7 +#
     1.8 +# SYNOPSIS
     1.9 +#
    1.10 +#   AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
    1.11 +#
    1.12 +# DESCRIPTION
    1.13 +#
    1.14 +#   Check whether the given compiler FLAGS work with the current language's
    1.15 +#   compiler, or whether they give an error. (Warnings, however, are
    1.16 +#   ignored.)
    1.17 +#
    1.18 +#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
    1.19 +#   success/failure.
    1.20 +#
    1.21 +# LICENSE
    1.22 +#
    1.23 +#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
    1.24 +#   Copyright (c) 2009 Matteo Frigo
    1.25 +#
    1.26 +#   This program is free software: you can redistribute it and/or modify it
    1.27 +#   under the terms of the GNU General Public License as published by the
    1.28 +#   Free Software Foundation, either version 3 of the License, or (at your
    1.29 +#   option) any later version.
    1.30 +#
    1.31 +#   This program is distributed in the hope that it will be useful, but
    1.32 +#   WITHOUT ANY WARRANTY; without even the implied warranty of
    1.33 +#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
    1.34 +#   Public License for more details.
    1.35 +#
    1.36 +#   You should have received a copy of the GNU General Public License along
    1.37 +#   with this program. If not, see <http://www.gnu.org/licenses/>.
    1.38 +#
    1.39 +#   As a special exception, the respective Autoconf Macro's copyright owner
    1.40 +#   gives unlimited permission to copy, distribute and modify the configure
    1.41 +#   scripts that are the output of Autoconf when processing the Macro. You
    1.42 +#   need not follow the terms of the GNU General Public License when using
    1.43 +#   or distributing such scripts, even though portions of the text of the
    1.44 +#   Macro appear in them. The GNU General Public License (GPL) does govern
    1.45 +#   all other use of the material that constitutes the Autoconf Macro.
    1.46 +#
    1.47 +#   This special exception to the GPL applies to versions of the Autoconf
    1.48 +#   Macro released by the Autoconf Archive. When you make and distribute a
    1.49 +#   modified version of the Autoconf Macro, you may extend this special
    1.50 +#   exception to the GPL to apply to your modified version as well.
    1.51 +
    1.52 +#serial 9
    1.53 +
    1.54 +AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
    1.55 +[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
    1.56 +AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
    1.57 +dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
    1.58 +AS_LITERAL_IF([$1],
    1.59 +  [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]), [
    1.60 +      ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
    1.61 +      _AC_LANG_PREFIX[]FLAGS="$1"
    1.62 +      AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
    1.63 +        AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
    1.64 +        AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
    1.65 +      _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
    1.66 +  [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
    1.67 +   _AC_LANG_PREFIX[]FLAGS="$1"
    1.68 +   AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
    1.69 +     eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
    1.70 +     eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
    1.71 +   _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
    1.72 +eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])
    1.73 +AC_MSG_RESULT($ax_check_compiler_flags)
    1.74 +if test "x$ax_check_compiler_flags" = xyes; then
    1.75 +	m4_default([$2], :)
    1.76 +else
    1.77 +	m4_default([$3], :)
    1.78 +fi
    1.79 +])dnl AX_CHECK_COMPILER_FLAGS