Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlassert / repo / third_party / nlbuild-autotools / repo / autoconf / m4 / ax_check_compiler.m4
1 #
2 #    Copyright 2014-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 # _AX_CHECK_COMPILER_OPTION_WITH_VAR(language, variable, option)
19 #
20 #   language - The autoconf language (C, C++, Objective C, Objective C++,
21 #              etc.).
22 #   variable - The variable to add the checked compiler option to.
23 #   option   - The compiler flag to check.
24 #
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],
29 [
30     AC_LANG_PUSH($1)
31     AC_MSG_CHECKING([whether the _AC_LANG compiler understands $3])
32     SAVE_[]_AC_LANG_PREFIX[]FLAGS=${_AC_LANG_PREFIX[]FLAGS}
33     SAVE_$2=${$2}
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
37     unset SAVE_$2
38     AC_LANG_POP($1)
39 ])
40
41 #
42 # _AX_CHECK_COMPILER_OPTION(language, option)
43 #
44 #   language - The autoconf language (C, C++, Objective C, Objective C++,
45 #              etc.).
46 #   option   - The compiler flag to check.
47 #
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],
52 [
53     AC_LANG_PUSH($1)
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
59     AC_LANG_POP($1)
60 ])
61
62 #
63 # AX_CHECK_COMPILER_OPTION(language, [variable,] option)
64 #
65 #   language - The autoconf language (C, C++, Objective C, Objective C++,
66 #              etc.).
67 #   variable - If supplied, the variable to add the checked compiler option
68 #              to.
69 #   option   - The compiler flag to check.
70 #
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],
75 [
76     ifelse($#,
77         3,
78         [_AX_CHECK_COMPILER_OPTION_WITH_VAR($1, $2, $3)],
79         [_AX_CHECK_COMPILER_OPTION($1, $2)])
80 ])
81
82 #
83 # AX_CHECK_COMPILER_OPTIONS(language, [variable,] option ...)
84 #
85 #   language - The autoconf language (C, C++, Objective C, Objective C++,
86 #              etc.).
87 #   variable - If supplied, the variable to add the checked compiler option
88 #              to.
89 #   options  - The compiler flags to check.
90 #
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],
95 [
96     ifelse($#,
97         3,
98         [
99             for ax_compiler_option in [$3]; do
100                 _AX_CHECK_COMPILER_OPTION_WITH_VAR([$1], [$2], $ax_compiler_option)
101             done
102         ],
103         [
104             for ax_compiler_option in [$2]; do
105                 _AX_CHECK_COMPILER_OPTION([$1], $ax_compiler_option)
106             done
107         ])
108 ])