2 # Copyright 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.
19 # This file defines a number of GNU autoconf M4-style macros
20 # for checking language-specific preprocessor options.
24 # _AX_CHECK_PREPROCESSOR_OPTION_WITH_VAR(language, variable, option)
26 # language - The autoconf language (C, C++, Objective C, Objective C++,
28 # variable - The variable to add the checked preprocessor option to.
29 # option - The preprocessor flag to check.
31 # Add, if supported, the specified preprocessor flag for the preprocessor
32 # selected for the specified language to the provided variable.
33 # ----------------------------------------------------------------------------
34 AC_DEFUN([_AX_CHECK_PREPROCESSOR_OPTION_WITH_VAR],
37 AC_MSG_CHECKING([whether the _AC_LANG preprocessor understands $3])
38 SAVE_CPPFLAGS=${CPPFLAGS}
41 AC_TRY_CPP(,AC_MSG_RESULT([yes]); CPPFLAGS="${SAVE_CPPFLAGS}"; $2="${SAVE_$2} $3",AC_MSG_RESULT([no]); CPPFLAGS=${SAVE_CPPFLAGS}; $2=${SAVE_$2});
48 # _AX_CHECK_PREPROCESSOR_OPTION(language, option)
50 # language - The autoconf language (C, C++, Objective C, Objective C++,
52 # option - The preprocessor flag to check.
54 # Add, if supported, the specified preprocessor flag for the preprocessor
55 # selected for the specified language.
56 # ----------------------------------------------------------------------------
57 AC_DEFUN([_AX_CHECK_PREPROCESSOR_OPTION],
60 AC_MSG_CHECKING([whether the _AC_LANG preprocessor understands $2])
61 SAVE_CPPFLAGS=${CPPFLAGS}
63 AC_TRY_CPP(,AC_MSG_RESULT([yes]); CPPFLAGS="${SAVE_CPPFLAGS} $2",AC_MSG_RESULT([no]); CPPFLAGS=${SAVE_CPPFLAGS});
69 # AX_CHECK_PREPROCESSOR_OPTION(language, [variable,] option)
71 # language - The autoconf language (C, C++, Objective C, Objective C++,
73 # variable - If supplied, the variable to add the checked preprocessor option
75 # option - The preprocessor flag to check.
77 # Add, if supported, the specified preprocessor flag for the preprocessor
78 # selected for the specified language, optionally saving it to the specified
80 # ----------------------------------------------------------------------------
81 AC_DEFUN([AX_CHECK_PREPROCESSOR_OPTION],
85 [_AX_CHECK_PREPROCESSOR_OPTION_WITH_VAR($1, $2, $3)],
86 [_AX_CHECK_PREPROCESSOR_OPTION($1, $2)])
90 # AX_CHECK_PREPROCESSOR_OPTIONS(language, [variable,] option ...)
92 # language - The autoconf language (C, C++, Objective C, Objective C++,
94 # variable - If supplied, the variable to add the checked preprocessor option
96 # options - The preprocessor flags to check.
98 # Add, if supported, the specified preprocessor flags for the preprocessor
99 # selected for the specified language, optionally saving it to the specified
101 # ----------------------------------------------------------------------------
102 AC_DEFUN([AX_CHECK_PREPROCESSOR_OPTIONS],
107 for ax_preprocessor_option in [$3]; do
108 _AX_CHECK_PREPROCESSOR_OPTION_WITH_VAR([$1], [$2], $ax_preprocessor_option)
112 for ax_preprocessor_option in [$2]; do
113 _AX_CHECK_PREPROCESSOR_OPTION([$1], $ax_preprocessor_option)