2 # Copyright 2019 Google LLC. All Rights Reserved.
3 # Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
20 # This file defines a GNU autoconf M4-style macro for filtering
21 # the autoconf canonical build, host, or target.
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
29 # _NL_FILTERED_CANONICAL_SPLIT(name)
31 # name - The existing autoconf variable to split
33 # This splits, by CPU architecture, vendor, and OS, the filtered
34 # tuples otherwise created by autotools, creating:
37 # nl_filtered_<name>_cpu
38 # nl_filtered_<name>_os
39 # nl_filtered_<name>_vendor
41 # filtered of the versioning cruft on the vendor component that most
42 # users of these variables rarely care about.
44 # The resulting values are available both in configure.ac as well
47 _NL_FILTERED_CANONICAL_SPLIT(name)
48 AC_DEFUN([_NL_FILTERED_CANONICAL_SPLIT],
50 case ${nl_cv_filtered_$1} in
53 *) AC_MSG_ERROR([invalid value of canonical $1]);;
57 AC_SUBST([nl_filtered_$1], [$nl_cv_filtered_$1])
59 nl_save_IFS=$IFS; IFS='-'
60 set x $nl_cv_filtered_$1
63 AC_SUBST([nl_filtered_$1_cpu], [$[1]])
64 AC_SUBST([nl_filtered_$1_vendor], [$[2]])
67 [# Remember, the first character of IFS is used to create $]*,
68 # except with old shells:
69 nl_filtered_$1_os=$[*]
72 case nl_filtered_$$1_os in
74 *\ *) nl_filtered_$1_os=`echo "$$1_os" | sed 's/ /-/g'`;;
78 AC_SUBST([nl_filtered_$1_os])
82 # _NL_FILTERED_CANONICAL(name)
84 # name - The existing autoconf variable to filter
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.
89 # This filters such versioning cruft from the variable 'name'
90 # generated from AC_CANONICAL_<NAME> and saves it in
91 # 'nl_filtered_<name>'.
93 _NL_FILTERED_CANONICAL(name)
94 AC_DEFUN([_NL_FILTERED_CANONICAL],
96 AC_CACHE_CHECK([filtered $1 system type],
98 [nl_cv_filtered_$1=`echo ${$1} | sed -e 's/[[[:digit:].]]*$//g'`
99 nl_filtered_$1=${nl_cv_filtered_$1}])
101 _NL_FILTERED_CANONICAL_SPLIT($1)
105 # NL_FILTERED_CANONICAL_BUILD
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.
110 # This filters such versioning cruft from the variable 'build'
111 # generated from AC_CANONICAL_BUILD and saves it in
112 # 'nl_filtered_build'.
114 NL_FILTERED_CANONICAL_BUILD
115 AC_DEFUN([NL_FILTERED_CANONICAL_BUILD],
117 AC_REQUIRE([AC_CANONICAL_BUILD])
118 _NL_FILTERED_CANONICAL(build)
122 # NL_FILTERED_CANONICAL_HOST
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.
127 # This filters such versioning cruft from the variable 'host'
128 # generated from AC_CANONICAL_HOST and saves it in
129 # 'nl_filtered_build'.
131 NL_FILTERED_CANONICAL_HOST
132 AC_DEFUN([NL_FILTERED_CANONICAL_HOST],
134 AC_REQUIRE([AC_CANONICAL_HOST])
135 _NL_FILTERED_CANONICAL(host)
139 # NL_FILTERED_CANONICAL_TARGET
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.
144 # This filters such versioning cruft from the variable 'target'
145 # generated from AC_CANONICAL_TARGET and saves it in
146 # 'nl_filtered_target'.
148 NL_FILTERED_CANONICAL_TARGET
149 AC_DEFUN([NL_FILTERED_CANONICAL_TARGET],
151 AC_REQUIRE([AC_CANONICAL_TARGET])
152 _NL_FILTERED_CANONICAL(target)