Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlunit-test / repo / third_party / nlbuild-autotools / repo / autoconf / m4 / ax_check_preprocessor.m4
1 #
2 #    Copyright 2016 Nest Labs Inc. All Rights Reserved.
3 #
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
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 #
16
17 #
18 #    Description:
19 #      This file defines a number of GNU autoconf M4-style macros
20 #      for checking language-specific preprocessor options.
21 #
22
23 #
24 # _AX_CHECK_PREPROCESSOR_OPTION_WITH_VAR(language, variable, option)
25 #
26 #   language - The autoconf language (C, C++, Objective C, Objective C++,
27 #              etc.).
28 #   variable - The variable to add the checked preprocessor option to.
29 #   option   - The preprocessor flag to check.
30 #
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],
35 [
36     AC_LANG_PUSH($1)
37     AC_MSG_CHECKING([whether the _AC_LANG preprocessor understands $3])
38     SAVE_CPPFLAGS=${CPPFLAGS}
39     SAVE_$2=${$2}
40     CPPFLAGS=$3
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});
42     unset SAVE_CPPFLAGS
43     unset SAVE_$2
44     AC_LANG_POP($1)
45 ])
46
47 #
48 # _AX_CHECK_PREPROCESSOR_OPTION(language, option)
49 #
50 #   language - The autoconf language (C, C++, Objective C, Objective C++,
51 #              etc.).
52 #   option   - The preprocessor flag to check.
53 #
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],
58 [
59     AC_LANG_PUSH($1)
60     AC_MSG_CHECKING([whether the _AC_LANG preprocessor understands $2])
61     SAVE_CPPFLAGS=${CPPFLAGS}
62     CPPFLAGS=$2
63     AC_TRY_CPP(,AC_MSG_RESULT([yes]); CPPFLAGS="${SAVE_CPPFLAGS} $2",AC_MSG_RESULT([no]); CPPFLAGS=${SAVE_CPPFLAGS});
64     unset SAVE_CPPFLAGS
65     AC_LANG_POP($1)
66 ])
67
68 #
69 # AX_CHECK_PREPROCESSOR_OPTION(language, [variable,] option)
70 #
71 #   language - The autoconf language (C, C++, Objective C, Objective C++,
72 #              etc.).
73 #   variable - If supplied, the variable to add the checked preprocessor option
74 #              to.
75 #   option   - The preprocessor flag to check.
76 #
77 # Add, if supported, the specified preprocessor flag for the preprocessor
78 # selected for the specified language, optionally saving it to the specified
79 # variable.
80 # ----------------------------------------------------------------------------
81 AC_DEFUN([AX_CHECK_PREPROCESSOR_OPTION],
82 [
83     ifelse($#,
84         3,
85         [_AX_CHECK_PREPROCESSOR_OPTION_WITH_VAR($1, $2, $3)],
86         [_AX_CHECK_PREPROCESSOR_OPTION($1, $2)])
87 ])
88
89 #
90 # AX_CHECK_PREPROCESSOR_OPTIONS(language, [variable,] option ...)
91 #
92 #   language - The autoconf language (C, C++, Objective C, Objective C++,
93 #              etc.).
94 #   variable - If supplied, the variable to add the checked preprocessor option
95 #              to.
96 #   options  - The preprocessor flags to check.
97 #
98 # Add, if supported, the specified preprocessor flags for the preprocessor
99 # selected for the specified language, optionally saving it to the specified
100 # variable.
101 # ----------------------------------------------------------------------------
102 AC_DEFUN([AX_CHECK_PREPROCESSOR_OPTIONS],
103 [
104     ifelse($#,
105         3,
106         [
107             for ax_preprocessor_option in [$3]; do
108                 _AX_CHECK_PREPROCESSOR_OPTION_WITH_VAR([$1], [$2], $ax_preprocessor_option)
109             done
110         ],
111         [
112             for ax_preprocessor_option in [$2]; do
113                 _AX_CHECK_PREPROCESSOR_OPTION([$1], $ax_preprocessor_option)
114             done
115         ])
116 ])