blob: 81707e76c6a19e94ebd41c92cb708cab6e1c2436 [file]
# Copyright (C) 2026 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# This Awk script takes input file (usually auto-host.h) and effective target
# definitions from preprocessed et-static.def, and writes et-static.exp
# implementing checks for select effective-target keywords.
#
# Usage: awk -v etlist=<path to etlist> -f gen-et-static.awk <input file>
BEGIN {
input = ARGV[1]
SAVEFS=FS
FS=SUBSEP
# Read preprocessed et-static.def. Each line consists of
# <effective-target> <macro> <comment>.
while ((getline < etlist) > 0) {
et[$2] = $1
comment[$2] = $3
}
close(etlist)
FS=SAVEFS
}
function emit_effective_target(name, value, comment)
{
print "";
print "# " comment;
print "proc check_effective_target_" name " { } {";
print " return " value;
print "}";
}
# #define <MACRO> <value>
/^#define/ { value[$2] = $3 }
# /* #undef <MACRO> */
/^\/\* #undef/ { value[$3] = 0 }
END {
print "# This file is auto-generated by gen-et-static.awk from " input
print "# and et-static.def."
for (macro in et) {
if (macro in value) {
val = value[macro]
# Characters, strings and tri-state macros would need
# special handling.
if (val !~ /^[01]/) {
print "#error non-0/1/#undef value " val " for " macro
exit(1)
}
} else {
# Treat missing macros as unsupported.
print "#warning definition for " macro " missing"
val = 0
}
emit_effective_target(et[macro], val,
"Return 1 if " comment[macro] ", 0 otherwise.");
}
}