Build: Fix typo ac_cv_search_pthread_crate
[official-gcc.git] / gcc / config / avr / genmultilib.awk
blob8ba0dd99d4ed21fe770a159d28839d18933eb112
1 # Copyright (C) 2011-2024 Free Software Foundation, Inc.
3 # This file is part of GCC.
5 # GCC is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation; either version 3, or (at your option) any later
8 # version.
10 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with GCC; see the file COPYING3. If not see
17 # <http://www.gnu.org/licenses/>.
19 ##################################################################
21 # Transform Core/Device Information from avr-mcus.def to a
22 # Representation that is understood by GCC's multilib Machinery.
24 # The Script works as a Filter from STDIN to STDOUT.
25 # It generates a Makefile Snippet that sets some
26 # MULTILIB_* Variables as needed.
28 ##################################################################
30 BEGIN {
31 FS ="[(, \t]+"
32 option[""] = ""
33 comment = 1
35 dir_tiny = "tiny-stack"
36 opt_tiny = "msp8"
38 dir_rcall = "short-calls"
39 opt_rcall = "mshort-calls"
41 # awk Variable Makefile Variable
42 # ------------------------------------------
43 # m_options <-> MULTILIB_OPTIONS
44 # m_dirnames <-> MULTILIB_DIRNAMES
45 # m_required <-> MULTILIB_REQUIRED
46 # m_reuse <-> MULTILIB_REUSE
47 m_sep = ""
48 m_options = "\nMULTILIB_OPTIONS = "
49 m_dirnames = "\nMULTILIB_DIRNAMES ="
50 m_required = "\nMULTILIB_REQUIRED ="
51 m_reuse = "\nMULTILIB_REUSE ="
53 have_long_double_is_double = (HAVE_LONG_DOUBLE_IS_DOUBLE \
54 == "HAVE_LONG_DOUBLE_IS_DOUBLE")
55 have_double32 = (HAVE_DOUBLE32 == "HAVE_DOUBLE32")
56 have_double64 = (HAVE_DOUBLE64 == "HAVE_DOUBLE64")
57 have_long_double32 = (HAVE_LONG_DOUBLE32 == "HAVE_LONG_DOUBLE32")
58 have_long_double64 = (HAVE_LONG_DOUBLE64 == "HAVE_LONG_DOUBLE64")
60 have_double_multi = (have_double32 && have_double64)
61 have_long_double_multi = (! have_long_double_is_double \
62 && have_long_double32 && have_long_double64)
64 # How to switch away from the default.
65 dir_double = "double" (96 - with_double)
66 opt_double = "mdouble=" (96 - with_double)
68 dir_long_double = "long-double" (96 - with_long_double)
69 opt_long_double = "mlong-double=" (96 - with_long_double)
71 if (with_multilib_list != "")
73 split(with_multilib_list, multilib_list, ",")
75 for (i in multilib_list)
77 multilibs[multilib_list[i]] = 1
82 ##################################################################
83 # Add some Comments to the generated Files and copy-paste
84 # Copyright Notice from above.
85 ##################################################################
87 /^#/ {
88 if (!comment)
89 next
90 else if (comment == 1)
92 print "# Auto-generated Makefile Snip"
93 print "# Generated by : ./gcc/config/avr/genmultilib.awk"
94 print "# Generated from : ./gcc/config/avr/avr-mcus.def"
95 print "# Used by : tmake_file from Makefile and genmultilib"
96 print ""
99 comment = 2;
101 print
104 /^$/ {
105 # The first empty line stops copy-pasting the GPL comments
106 # from this file to the generated file.
108 if (comment)
110 print
112 if (have_double_multi)
114 print "# dir_double = " dir_double
115 print "# opt_double = -" opt_double
117 else
118 print "# No multilib for double."
120 if (have_long_double_multi)
122 print "# dir_long_double = " dir_long_double
123 print "# opt_long_double = -" opt_long_double
125 else
126 print "# No multilib for long double."
128 comment = 0
131 ##################################################################
132 # Run over all AVR_MCU Lines. If we encounter a required multilib
133 # variant, add according combination of options to m_required,
134 # but onyl once. Add encountered cores to m_dirnames and
135 # according -mmcu= options to m_options.
136 ##################################################################
138 /^AVR_MCU/ {
139 name = $2
140 gsub ("\"", "", name)
142 if ($5 == "NULL")
144 core = name
146 # avr1 is supported for Assembler only: It gets no multilib
147 if (core == "avr1")
148 next
150 if (with_multilib_list != "" && !(core in multilibs))
151 next
153 option[core] = "mmcu=" core
155 m_options = m_options m_sep option[core]
156 m_dirnames = m_dirnames " " core
157 m_sep = "/"
159 next
162 # avr1 is supported for Assembler only: Its Devices are ignored
163 if (core == "avr1")
164 next
166 if (with_multilib_list != "" && !(core in multilibs))
167 next
169 opts = option[core]
171 # split device specific feature list
172 n = split($4,dev_attribute,"|")
174 for (i=1; i <= n; i++)
176 if (dev_attribute[i] == "AVR_SHORT_SP")
177 opts = opts "/" opt_tiny
178 if (dev_attribute[i] == "AVR_ISA_RCALL")
179 opts = opts "/" opt_rcall
182 if (!have[opts])
184 have[opts] = 1
185 # Some special handling for the default mmcu: Remove a
186 # leading "mmcu=avr2/" in order not to confuse genmultilib.
187 gsub (/^mmcu=avr2\//, "", opts)
188 if (opts != "mmcu=avr2")
190 m_required = m_required " \\\n\t" opts
191 if (have_double_multi && have_long_double_multi)
193 m_required = m_required " \\\n\t" opts "/" opt_double
194 m_required = m_required " \\\n\t" opts "/" opt_long_double
196 # We have only 3 different combinations because -mdouble=64
197 # implies -mlong-double=64, and -mlong-double=32 implies
198 # -mdouble=32, hence add respective reuses. The reuse is
199 # not needed in the case with_double != with_long_double
200 # which means with_double=32 with_long_double=64 because
201 # the driver will rectify combining -mdouble=64 and
202 # -mlong-double=32.
203 if (with_double == with_long_double)
205 d_opts = with_double == 32 ? opt_double : opt_long_double
206 d_opts = opts "/" d_opts
207 d_reuse = opts "/" opt_double "/" opt_long_double
208 gsub (/=/, ".", d_opts)
209 gsub (/=/, ".", d_reuse)
210 m_reuse = m_reuse " \\\n\t" d_opts "=" d_reuse
213 else if (have_double_multi)
214 m_required = m_required " \\\n\t" opts "/" opt_double
215 else if (have_long_double_multi)
216 m_required = m_required " \\\n\t" opts "/" opt_long_double
221 ##################################################################
223 ##################################################################
225 END {
226 ############################################################
227 # Output that Stuff
228 ############################################################
230 # Intended Target: $(top_builddir)/gcc/t-multilib-avr
232 if (have_double_multi && have_long_double_multi)
234 print m_options " " opt_tiny " " opt_rcall " " opt_double "/" opt_long_double
235 print m_dirnames " " dir_tiny " " dir_rcall " " dir_double " " dir_long_double
236 # Notice that the ./double* and ./long-double* variants cannot
237 # be copied by t-avrlibc because the . default multilib is built
238 # after all the others.
239 m_required = m_required " \\\n\t" opt_double
240 m_required = m_required " \\\n\t" opt_long_double
241 if (with_double == with_long_double)
243 d_opts = with_double == 32 ? opt_double : opt_long_double
244 d_reuse = opt_double "/" opt_long_double
245 gsub (/=/, ".", d_opts)
246 gsub (/=/, ".", d_reuse)
247 m_reuse = m_reuse " \\\n\t" d_opts "=" d_reuse
251 else if (have_double_multi)
253 print m_options " " opt_tiny " " opt_rcall " " opt_double
254 print m_dirnames " " dir_tiny " " dir_rcall " " dir_double
255 m_required = m_required " \\\n\t" opt_double
257 else if (have_long_double_multi)
259 print m_options " " opt_tiny " " opt_rcall " " opt_long_double
260 print m_dirnames " " dir_tiny " " dir_rcall " " dir_long_double
261 m_required = m_required " \\\n\t" opt_long_double
263 else
265 print m_options " " opt_tiny " " opt_rcall
266 print m_dirnames " " dir_tiny " " dir_rcall
269 print m_required
270 print m_reuse