Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlfaultinjection / repo / third_party / nlbuild-autotools / repo / autoconf / m4 / nl_filtered_canonical.m4
1 #
2 #    Copyright 2019 Google LLC. All Rights Reserved.
3 #    Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
4 #
5 #    Licensed under the Apache License, Version 2.0 (the "License");
6 #    you may not use this file except in compliance with the License.
7 #    You may obtain a copy of the License at
8 #
9 #    http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #    Unless required by applicable law or agreed to in writing, software
12 #    distributed under the License is distributed on an "AS IS" BASIS,
13 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #    See the License for the specific language governing permissions and
15 #    limitations under the License.
16 #
17
18 #
19 #    Description:
20 #      This file defines a GNU autoconf M4-style macro for filtering
21 #      the autoconf canonical build, host, or target.
22 #
23 #      Mac OS X / Darwin ends up putting some versioning cruft on the
24 #      end of its tuples that most users of these variables rarely
25 #      care about.
26 #
27
28 #
29 # _NL_FILTERED_CANONICAL_SPLIT(name)
30 #
31 #   name - The existing autoconf variable to split
32 #
33 #   This splits, by CPU architecture, vendor, and OS, the filtered
34 #   tuples otherwise created by autotools, creating:
35 #
36 #     nl_filtered_<name>
37 #     nl_filtered_<name>_cpu
38 #     nl_filtered_<name>_os
39 #     nl_filtered_<name>_vendor
40 #
41 #   filtered of the versioning cruft on the vendor component that most
42 #   users of these variables rarely care about.
43 #
44 #   The resulting values are available both in configure.ac as well
45 #   as in makefiles.
46 #
47 _NL_FILTERED_CANONICAL_SPLIT(name)
48 AC_DEFUN([_NL_FILTERED_CANONICAL_SPLIT],
49 [
50     case ${nl_cv_filtered_$1} in
51     
52     *-*-*) ;;
53     *) AC_MSG_ERROR([invalid value of canonical $1]);;
54     
55     esac
56     
57     AC_SUBST([nl_filtered_$1], [$nl_cv_filtered_$1])
58     
59     nl_save_IFS=$IFS; IFS='-'
60     set x $nl_cv_filtered_$1
61     shift
62     
63     AC_SUBST([nl_filtered_$1_cpu], [$[1]])
64     AC_SUBST([nl_filtered_$1_vendor], [$[2]])
65     
66     shift; shift
67     [# Remember, the first character of IFS is used to create $]*,
68     # except with old shells:
69     nl_filtered_$1_os=$[*]
70     IFS=$nl_save_IFS
71     
72     case nl_filtered_$$1_os in
73     
74     *\ *) nl_filtered_$1_os=`echo "$$1_os" | sed 's/ /-/g'`;;
75     
76     esac
77     
78     AC_SUBST([nl_filtered_$1_os])
79 ])
80
81 #
82 # _NL_FILTERED_CANONICAL(name)
83 #
84 #   name - The existing autoconf variable to filter
85 #
86 #   Mac OS X / Darwin ends up putting some versioning cruft on the end
87 #   of its tuples that most users of these variables rarely care about.
88 #
89 #   This filters such versioning cruft from the variable 'name'
90 #   generated from AC_CANONICAL_<NAME> and saves it in
91 #   'nl_filtered_<name>'.
92 #
93 _NL_FILTERED_CANONICAL(name)
94 AC_DEFUN([_NL_FILTERED_CANONICAL],
95 [
96     AC_CACHE_CHECK([filtered $1 system type],
97         [nl_cv_filtered_$1],
98         [nl_cv_filtered_$1=`echo ${$1} | sed -e 's/[[[:digit:].]]*$//g'`
99         nl_filtered_$1=${nl_cv_filtered_$1}])
100
101     _NL_FILTERED_CANONICAL_SPLIT($1)
102 ])
103
104 #
105 # NL_FILTERED_CANONICAL_BUILD
106 #
107 #   Mac OS X / Darwin ends up putting some versioning cruft on the end
108 #   of its tuples that most users of these variables rarely care about.
109 #
110 #   This filters such versioning cruft from the variable 'build'
111 #   generated from AC_CANONICAL_BUILD and saves it in
112 #   'nl_filtered_build'.
113 #
114 NL_FILTERED_CANONICAL_BUILD
115 AC_DEFUN([NL_FILTERED_CANONICAL_BUILD],
116 [
117     AC_REQUIRE([AC_CANONICAL_BUILD])
118     _NL_FILTERED_CANONICAL(build)
119 ])
120
121 #
122 # NL_FILTERED_CANONICAL_HOST
123 #
124 #   Mac OS X / Darwin ends up putting some versioning cruft on the end
125 #   of its tuples that most users of these variables rarely care about.
126 #
127 #   This filters such versioning cruft from the variable 'host'
128 #   generated from AC_CANONICAL_HOST and saves it in
129 #   'nl_filtered_build'.
130 #
131 NL_FILTERED_CANONICAL_HOST
132 AC_DEFUN([NL_FILTERED_CANONICAL_HOST],
133 [
134     AC_REQUIRE([AC_CANONICAL_HOST])
135     _NL_FILTERED_CANONICAL(host)
136 ])
137
138 #
139 # NL_FILTERED_CANONICAL_TARGET
140 #
141 #   Mac OS X / Darwin ends up putting some versioning cruft on the end
142 #   of its tuples that most users of these variables rarely care about.
143 #
144 #   This filters such versioning cruft from the variable 'target'
145 #   generated from AC_CANONICAL_TARGET and saves it in
146 #   'nl_filtered_target'.
147 #
148 NL_FILTERED_CANONICAL_TARGET
149 AC_DEFUN([NL_FILTERED_CANONICAL_TARGET],
150 [
151     AC_REQUIRE([AC_CANONICAL_TARGET])
152     _NL_FILTERED_CANONICAL(target)
153 ])