Image-PNG-Simple
view release on metacpan or search on metacpan
libpng-1.6.17/scripts/options.awk view on Meta::CPAN
# respectively for the build to succeed. This allows interdependencies
# between options of the form "at least one of" or "at most one of"
# to be checked. For example:
#
# option FLOATING_POINT enables ok_math
# option FIXED_POINT enables ok_math
# This ensures that at least one of FLOATING_POINT and FIXED_POINT
# must be set for the build to succeed.
#
# option fail_math requires FLOATING_POINT FIXED_POINT
# This means the build will fail if *both* FLOATING_POINT and
# FIXED_POINT are set (this is an example; in fact both are allowed.)
#
# If all these options were given the build would require exactly one
# of the names to be enabled.
END{
# END{} gets run on an exit (a traditional awk feature)
if (err) exit 1
if (pre) {
# Record the final value of the variables
print "deb =", deb >out
if (everything != "") {
print "everything =", everything >out
}
print "logunsupported =", logunsupported >out
exit 0
}
# Do the options first (allowing options to set settings). The dependency
# tree is thus:
#
# name > name
# name requires name
# name if name
# name enabledby name
#
# First build a list 'tree' by option of all the things on which
# it depends.
print "" >out
print "/* OPTIONS */" >out
print comment, "options", cend >out
for (opt in enabledby) tree[opt] = 1 # may not be explicit options
for (opt in option) if (opt != "") {
o = option[opt]
# option should always be one of the following values
if (o != "on" && o != "off" && o != "disabled" && o != "enabled") {
print "internal option error (" o ")"
exit 1
}
tree[opt] = "" # so unlisted options marked
}
for (opt in tree) if (opt != "") {
if (tree[opt] == 1) {
tree[opt] = ""
if (option[opt] != "") {
print "internal error (1)"
exit 1
}
# Macros only listed in 'enables' remain off unless
# one of the enabling macros is on.
option[opt] = "disabled"
}
split("", list) # clear 'list'
# Now add every requires, iffs or enabledby entry to 'list'
# so that we can add a unique list of requirements to tree[i]
split(requires[opt] iffs[opt] enabledby[opt], r)
for (i in r) list[r[i]] = 1
for (i in list) tree[opt] = tree[opt] " " i
}
# print the tree for extreme debugging
if (deb > 2) for (i in tree) if (i != "") print i, "depends-on" tree[i]
# Ok, now check all options marked explicitly 'on' or 'off':
#
# If an option[opt] is 'on' then turn on all requires[opt]
# If an option[opt] is 'off' then turn off all enabledby[opt]
#
# Error out if we have to turn 'on' to an 'off' option or vice versa.
npending = 0
for (opt in option) if (opt != "") {
if (option[opt] == "on" || option[opt] == "off") {
pending[++npending] = opt
}
}
err = 0 # set on error
while (npending > 0) {
opt = pending[npending--]
if (option[opt] == "on") {
nreqs = split(requires[opt], r)
for (j=1; j<=nreqs; ++j) {
if (option[r[j]] == "off") {
print "option", opt, "turned on, but requirement", r[j], "is turned off"
err = 1
} else if (option[r[j]] != "on") {
option[r[j]] = "on"
pending[++npending] = r[j]
}
}
} else {
if (option[opt] != "off") {
print "internal error (2)"
exit 1
}
nreqs = split(enabledby[opt], r)
for (j=1; j<=nreqs; ++j) {
if (option[r[j]] == "on") {
print "option", opt, "turned off, but enabled by", r[j], "which is turned on"
err = 1
} else if (option[r[j]] != "off") {
option[r[j]] = "off"
pending[++npending] = r[j]
}
}
}
}
if (err) exit 1
( run in 1.679 second using v1.01-cache-2.11-cpan-39bf76dae61 )