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