|
Packit |
6c4009 |
# Generate posix-conf-vars-def.h with definitions for CONF_DEF{CONF} for each
|
|
Packit |
6c4009 |
# configuration variable that getconf or sysconf may use. Currently it is
|
|
Packit |
6c4009 |
# equipped only to generate such macros for specification macros and for
|
|
Packit |
6c4009 |
# SYSCONF macros in the _POSIX namespace.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
BEGIN {
|
|
Packit |
6c4009 |
prefix = ""
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$1 ~ /^#/ || $0 ~ /^\s*$/ {
|
|
Packit |
6c4009 |
next
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Begin a new prefix.
|
|
Packit |
6c4009 |
$NF == "{" {
|
|
Packit |
6c4009 |
type = $1
|
|
Packit |
6c4009 |
prefix = $2
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (NF == 4)
|
|
Packit |
6c4009 |
sc_prefix = $3
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
sc_prefix = "_SC"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
next
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
$1 == "}" {
|
|
Packit |
6c4009 |
prefix = ""
|
|
Packit |
6c4009 |
type = ""
|
|
Packit |
6c4009 |
sc_prefix = ""
|
|
Packit |
6c4009 |
next
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (prefix == "" && type == "" && sc_prefix == "") {
|
|
Packit |
6c4009 |
printf ("Syntax error at %s:%d\n", FILENAME, FNR) > "/dev/stderr"
|
|
Packit |
6c4009 |
exit 1
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# The prefix and variable names are indices and the value indicates what type
|
|
Packit |
6c4009 |
# of variable it is. The possible options are:
|
|
Packit |
6c4009 |
# CONFSTR: A configuration string
|
|
Packit |
6c4009 |
# SYSCONF: A numeric value
|
|
Packit |
6c4009 |
# SPEC: A specification
|
|
Packit |
6c4009 |
c = prefix "_" $1
|
|
Packit |
6c4009 |
sc_prefixes[c] = sc_prefix
|
|
Packit |
6c4009 |
prefix_conf[c] = type
|
|
Packit |
6c4009 |
conf[c] = $1
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
END {
|
|
Packit |
6c4009 |
print "/* AUTOGENERATED by gen-posix-conf-vars.awk. DO NOT EDIT. */\n"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Generate macros that specify if a sysconf macro is defined and/or set.
|
|
Packit |
6c4009 |
for (c in prefix_conf) {
|
|
Packit |
6c4009 |
printf "#ifndef _%s\n", c
|
|
Packit |
6c4009 |
printf "# define CONF_DEF_%s CONF_DEF_UNDEFINED\n", c
|
|
Packit |
6c4009 |
# CONFSTR have string values and they are not set or unset.
|
|
Packit |
6c4009 |
if (prefix_conf[c] != "CONFSTR") {
|
|
Packit |
6c4009 |
printf "#else\n"
|
|
Packit |
6c4009 |
printf "# if _%s > 0\n", c
|
|
Packit |
6c4009 |
printf "# define CONF_DEF_%s CONF_DEF_DEFINED_SET\n", c
|
|
Packit |
6c4009 |
printf "# else\n"
|
|
Packit |
6c4009 |
printf "# define CONF_DEF_%s CONF_DEF_DEFINED_UNSET\n", c
|
|
Packit |
6c4009 |
printf "# endif\n"
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
printf "#endif\n\n"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Build a name -> sysconf number associative array to print a C array at
|
|
Packit |
6c4009 |
# the end.
|
|
Packit |
6c4009 |
if (prefix_conf[c] == "SPEC")
|
|
Packit |
6c4009 |
spec[c] = sc_prefixes[c] "_" conf[c]
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# Print the specification array. Define the macro NEED_SPEC_ARRAY before
|
|
Packit |
6c4009 |
# including posix-conf-vars.h to make it available in the compilation unit.
|
|
Packit |
6c4009 |
print "#if NEED_SPEC_ARRAY"
|
|
Packit |
6c4009 |
print "static const struct { const char *name; int num; } specs[] ="
|
|
Packit |
6c4009 |
print " {"
|
|
Packit |
6c4009 |
for (s in spec) {
|
|
Packit |
6c4009 |
printf " { \"%s\", %s },\n", s, spec[s]
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
print " };"
|
|
Packit |
6c4009 |
print "static const size_t nspecs = sizeof (specs) / sizeof (specs[0]);"
|
|
Packit |
6c4009 |
print "#endif"
|
|
Packit |
6c4009 |
}
|