2 # Copyright 2014-2016 Nest Labs Inc. All Rights Reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 # _AX_CHECK_COMPILER_OPTION_WITH_VAR(language, variable, option)
20 # language - The autoconf language (C, C++, Objective C, Objective C++,
22 # variable - The variable to add the checked compiler option to.
23 # option - The compiler flag to check.
25 # Add, if supported, the specified compiler flag for the compiler selected
26 # for the specified language to the provided variable.
27 # ----------------------------------------------------------------------------
28 AC_DEFUN([_AX_CHECK_COMPILER_OPTION_WITH_VAR],
31 AC_MSG_CHECKING([whether the _AC_LANG compiler understands $3])
32 SAVE_[]_AC_LANG_PREFIX[]FLAGS=${_AC_LANG_PREFIX[]FLAGS}
34 _AC_LANG_PREFIX[]FLAGS=$3
35 AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); _AC_LANG_PREFIX[]FLAGS="${SAVE_[]_AC_LANG_PREFIX[]FLAGS}"; $2="${SAVE_$2} $3",AC_MSG_RESULT([no]); _AC_LANG_PREFIX[]FLAGS=${SAVE_[]_AC_LANG_PREFIX[]FLAGS}; $2=${SAVE_$2});
36 unset SAVE_[]_AC_LANG_PREFIX[]FLAGS
42 # _AX_CHECK_COMPILER_OPTION(language, option)
44 # language - The autoconf language (C, C++, Objective C, Objective C++,
46 # option - The compiler flag to check.
48 # Add, if supported, the specified compiler flag for the compiler selected
49 # for the specified language.
50 # ----------------------------------------------------------------------------
51 AC_DEFUN([_AX_CHECK_COMPILER_OPTION],
54 AC_MSG_CHECKING([whether the _AC_LANG compiler understands $2])
55 SAVE_[]_AC_LANG_PREFIX[]FLAGS=${_AC_LANG_PREFIX[]FLAGS}
56 _AC_LANG_PREFIX[]FLAGS=$2
57 AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); _AC_LANG_PREFIX[]FLAGS="${SAVE_[]_AC_LANG_PREFIX[]FLAGS} $2",AC_MSG_RESULT([no]); _AC_LANG_PREFIX[]FLAGS=${SAVE_[]_AC_LANG_PREFIX[]FLAGS});
58 unset SAVE_[]_AC_LANG_PREFIX[]FLAGS
63 # AX_CHECK_COMPILER_OPTION(language, [variable,] option)
65 # language - The autoconf language (C, C++, Objective C, Objective C++,
67 # variable - If supplied, the variable to add the checked compiler option
69 # option - The compiler flag to check.
71 # Add, if supported, the specified compiler flag for the compiler selected
72 # for the specified language, optionally saving it to the specified variable.
73 # ----------------------------------------------------------------------------
74 AC_DEFUN([AX_CHECK_COMPILER_OPTION],
78 [_AX_CHECK_COMPILER_OPTION_WITH_VAR($1, $2, $3)],
79 [_AX_CHECK_COMPILER_OPTION($1, $2)])
83 # AX_CHECK_COMPILER_OPTIONS(language, [variable,] option ...)
85 # language - The autoconf language (C, C++, Objective C, Objective C++,
87 # variable - If supplied, the variable to add the checked compiler option
89 # options - The compiler flags to check.
91 # Add, if supported, the specified compiler flags for the compiler selected
92 # for the specified language, optionally saving it to the specified variable.
93 # ----------------------------------------------------------------------------
94 AC_DEFUN([AX_CHECK_COMPILER_OPTIONS],
99 for ax_compiler_option in [$3]; do
100 _AX_CHECK_COMPILER_OPTION_WITH_VAR([$1], [$2], $ax_compiler_option)
104 for ax_compiler_option in [$2]; do
105 _AX_CHECK_COMPILER_OPTION([$1], $ax_compiler_option)