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