1 ##### http://autoconf-archive.cryp.to/ax_check_compiler_flags.html
5 # AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
9 # Check whether the given compiler FLAGS work with the current
10 # language's compiler, or whether they give an error. (Warnings,
11 # however, are ignored.)
13 # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
22 # Copyright (c) 2005 Steven G. Johnson <stevenj@alum.mit.edu>
23 # Copyright (c) 2005 Matteo Frigo
25 # This program is free software; you can redistribute it and/or
26 # modify it under the terms of the GNU General Public License as
27 # published by the Free Software Foundation; either version 2 of the
28 # License, or (at your option) any later version.
30 # This program is distributed in the hope that it will be useful, but
31 # WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 # General Public License for more details.
35 # You should have received a copy of the GNU General Public License
36 # along with this program; if not, write to the Free Software
37 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
40 # As a special exception, the respective Autoconf Macro's copyright
41 # owner gives unlimited permission to copy, distribute and modify the
42 # configure scripts that are the output of Autoconf when processing
43 # the Macro. You need not follow the terms of the GNU General Public
44 # License when using or distributing such scripts, even though
45 # portions of the text of the Macro appear in them. The GNU General
46 # Public License (GPL) does govern all other use of the material that
47 # constitutes the Autoconf Macro.
49 # This special exception to the GPL applies to versions of the
50 # Autoconf Macro released by the Autoconf Macro Archive. When you
51 # make and distribute a modified version of the Autoconf Macro, you
52 # may extend this special exception to the GPL to apply to your
53 # modified version as well.
55 AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
56 [AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
57 AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
58 dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
60 [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1), [
61 ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
62 _AC_LANG_PREFIX[]FLAGS="$1"
63 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
64 AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
65 AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
66 _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
67 [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
68 _AC_LANG_PREFIX[]FLAGS="$1"
69 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
70 eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=yes,
71 eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)=no)
72 _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
73 eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_$1)
74 AC_MSG_RESULT($ax_check_compiler_flags)
75 if test "x$ax_check_compiler_flags" = xyes; then
80 ])dnl AX_CHECK_COMPILER_FLAGS