Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

734 lines
25 KiB

  1. #!/bin/awk -f
  2. # scripts/options.awk - library build configuration control
  3. #
  4. # last changed in libpng version 1.5.0 - January 6, 2011
  5. #
  6. # Copyright (c) 1998-2011 Glenn Randers-Pehrson
  7. #
  8. # This code is released under the libpng license.
  9. # For conditions of distribution and use, see the disclaimer
  10. # and license in png.h
  11. # The output of this script is written to the file given by
  12. # the variable 'out'. The script is run twice, once with
  13. # an intermediate output file, 'options.tmp' then again on
  14. # that file to produce the final output:
  15. #
  16. # awk -f scripts/options.awk out=options.tmp scripts/options.dfa 1>&2
  17. # awk -f scripts/options.awk out=options.dfn options.tmp 1>&2
  18. #
  19. # Some options may be specified on the command line:
  20. #
  21. # deb=1 Causes debugging to be output
  22. # logunsupported=1 Causes all options to be recorded in the output
  23. # everything=off Causes all options to be disabled by default
  24. # everything=on Causes all options to be enabled by default
  25. #
  26. # If awk fails on your platform, try nawk instead.
  27. #
  28. # These options may also be specified in the original input file (and
  29. # are copied to the preprocessed file).
  30. BEGIN{
  31. out="/dev/null" # intermediate, preprocessed, file
  32. pre=-1 # preprocess (first line)
  33. err=0 # in-line exit sets this
  34. start="PNG_DEFN_MAGIC-" # Arbitrary start
  35. end="-PNG_DEFN_END" # Arbitrary end
  36. cx= "/@@@*" # Open C comment for output file
  37. comment=start cx # Comment start
  38. cend="*/" end # Comment end
  39. def=start "#define PNG_@@@" # Arbitrary define
  40. sup="@@@_SUPPORTED" end # end supported option
  41. und=comment "#undef PNG_@@@" # Unsupported option
  42. une="@@@_SUPPORTED" cend # end unsupported option
  43. error=start "ERROR:" # error message
  44. # Variables
  45. deb=0 # debug - set on command line
  46. everything="" # do not override defaults
  47. logunsupported=0 # write unsupported options too
  48. # Precreate arrays
  49. option[""] = "" # list of all options: default enabled/disabled
  50. done[""] = 1 # marks option as having been output
  51. requires[""] = "" # requires by option
  52. iffs[""] = "" # if by option
  53. enabledby[""] = "" # options that enable it by option
  54. setting[""] = "" # requires by setting
  55. defaults[""] = "" # used for a defaulted value
  56. doneset[""] = 1 # marks setting as having been output
  57. r[""] = "" # Temporary array
  58. # For decorating the output file
  59. protect = ""
  60. }
  61. # The output file must be specified before any input:
  62. out == "/dev/null" {
  63. print "out=output.file must be given on the command line"
  64. err = 1
  65. exit 1
  66. }
  67. # The very first line indicates whether we are reading pre-processed
  68. # input or not, this must come *first* because 'PREPROCESSED' needs
  69. # to be the very first line in the temporary file.
  70. pre == -1{
  71. if ($0 == "PREPROCESSED") {
  72. pre = 0
  73. next
  74. } else {
  75. pre = 1
  76. print "PREPROCESSED" >out
  77. # And fall through to continue processing
  78. }
  79. }
  80. # variable=value
  81. # Sets the given variable to the given value (the syntax is fairly
  82. # free form, except for deb (you are expected to understand how to
  83. # set the debug variable...)
  84. #
  85. # This happens before the check on 'pre' below skips most of the
  86. # rest of the actions, so the variable settings happen during
  87. # preprocessing but are recorded in the END action too. This
  88. # allows them to be set on the command line too.
  89. $0 ~ /^[ ]*everything[ =]*off[ ]*$/{
  90. everything = "off"
  91. next
  92. }
  93. $0 ~ /^[ ]*everything[ =]*on[ ]*$/{
  94. everything = "on"
  95. next
  96. }
  97. $0 ~ /^[ ]*logunsupported[ =]*0[ ]*$/{
  98. logunsupported = 0
  99. next
  100. }
  101. $0 ~ /^[ ]*logunsupported[ =]*1[ ]*$/{
  102. logunsupported = 1
  103. next
  104. }
  105. $1 == "deb" && $2 == "=" && NF == 3{
  106. deb = $3
  107. next
  108. }
  109. # Preprocessing - this just copies the input file with lines
  110. # that need preprocessing (just chunk at present) expanded
  111. # The bare "pre" instead of "pre != 0" crashes under Sunos awk
  112. pre && $1 != "chunk"{
  113. print >out
  114. next
  115. }
  116. # The first characters of the line determine how it is processed,
  117. # leading spaces are ignored. In general tokens that are not
  118. # keywords are the names of options. An option 'name' is
  119. # controlled by the definition of the corresponding macros:
  120. #
  121. # PNG_name_SUPPORTED The option is turned on
  122. # PNG_NO_name
  123. # PNG_NO_name_SUPPORTED If the first macro is not defined
  124. # either of these will turn the option off
  125. #
  126. # If none of these macros are defined the option is turned on, unless
  127. # the keyword 'off' is given in a line relating to the option. The
  128. # keyword 'on' can also be given, but it will be ignored (since it is
  129. # the default.)
  130. #
  131. # In the syntax below a 'name' is indicated by "NAME", other macro
  132. # values are indicated by "MACRO", as with "NAME" the leading "PNG_"
  133. # is omitted, but in this case the "NO_" prefix and the "_SUPPORTED"
  134. # suffix are never used.
  135. #
  136. # Each line is introduced by a keyword - the first non-space characters
  137. # on the line. A line starting with a '#' is a comment - it is totally
  138. # ignored. Keywords are as follows, a NAME, is simply a macro name
  139. # without the leading PNG_, PNG_NO_ or the trailing _SUPPORTED.
  140. $1 ~ /^#/ || $0 ~ /^[ ]*$/{
  141. next
  142. }
  143. # com <comment>
  144. # The whole line is placed in the output file as a comment with
  145. # the preceding 'com' removed
  146. $1 == "com"{
  147. if (NF > 1) {
  148. # sub(/^[ ]*com[ ]*/, "")
  149. $1 = ""
  150. print comment, $0, cend >out
  151. } else
  152. print start end >out
  153. next
  154. }
  155. # file output input protect
  156. # Informational: the official name of the input file (without
  157. # make generated local directories), the official name of the
  158. # output file and, if required, a name to use in a protection
  159. # macro for the contents.
  160. $1 == "file" && NF >= 2{
  161. print comment, $2, cend >out
  162. print comment, "Machine generated file: DO NOT EDIT", cend >out
  163. if (NF >= 3)
  164. print comment, "Derived from:", $3, cend >out
  165. protect = $4
  166. if (protect != "") {
  167. print start "#ifndef", protect end >out
  168. print start "#define", protect end >out
  169. }
  170. next
  171. }
  172. # option NAME ( (requires|enables|if) NAME* | on | off | disabled )*
  173. # Declares an option 'NAME' and describes its default setting (disabled)
  174. # and its relationship to other options. The option is disabled
  175. # unless *all* the options listed after 'requires' are set and at
  176. # least one of the options listed after 'if' is set. If the
  177. # option is set then it turns on all the options listed after 'enables'.
  178. #
  179. # Note that "enables" takes priority over the required/if/disabled/off
  180. # setting of the target option.
  181. #
  182. # The definition file may list an option as 'disabled': off by default,
  183. # otherwise the option is enabled: on by default. A later (and it must
  184. # be later) entry may turn an option on or off explicitly.
  185. $1 == "option" && NF >= 2{
  186. onoff = option[$2] # records current (and the default is "", enabled)
  187. key = ""
  188. for (i=3; i<=NF; ++i) {
  189. if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") {
  190. key = ""
  191. if (onoff != $(i)) {
  192. # on or off can zap disabled or enabled:
  193. if (onoff == "" || (onoff == "disabled" || onoff == "enabled") && ($(i) == "on" || $(i) == "off")) {
  194. # It's easy to mis-spell the option when turning it
  195. # on or off, so warn about it here:
  196. if (onoff == "" && ($(i) == "on" || $(i) == "off")) {
  197. print $2 ": ERROR: turning unrecognized option", $(i)
  198. # For the moment error out - it is safer
  199. err = 1 # prevent END{} running
  200. exit 1
  201. }
  202. onoff = $(i)
  203. } else {
  204. # Print a message, otherwise the error
  205. # below is incomprehensible
  206. print $2 ": currently", onoff ": attempt to turn", $(i)
  207. break
  208. }
  209. }
  210. } else if ($(i) == "requires" || $(i) == "if" || $(i) == "enables") {
  211. key = $(i)
  212. } else if (key == "requires") {
  213. requires[$2] = requires[$2] " " $(i)
  214. } else if (key == "if") {
  215. iffs[$2] = iffs[$2] " " $(i)
  216. } else if (key == "enables") {
  217. enabledby[$(i)] = enabledby[$(i)] " " $2
  218. } else
  219. break # bad line format
  220. }
  221. if (i > NF) {
  222. # Set the option, defaulting to 'enabled'
  223. if (onoff == "") onoff = "enabled"
  224. option[$2] = onoff
  225. next
  226. }
  227. # Else fall through to the error handler
  228. }
  229. # chunk NAME [requires OPT] [on|off|disabled]
  230. # Expands to the 'option' settings appropriate to the reading and
  231. # writing of an ancilliary PNG chunk 'NAME':
  232. #
  233. # option READ_NAME requires READ_ANCILLARY_CHUNKS [READ_OPT]
  234. # option READ_NAME enables NAME
  235. # [option READ_NAME off]
  236. # option WRITE_NAME requires WRITE_ANCILLARY_CHUNKS [WRITE_OPT]
  237. # option WRITE_NAME enables NAME
  238. # [option WRITE_NAME off]
  239. pre != 0 && $1 == "chunk" && NF >= 2{
  240. # 'chunk' is handled on the first pass by writing appropriate
  241. # 'option' lines into the intermediate file.
  242. onoff = ""
  243. reqread = ""
  244. reqwrite = ""
  245. i = 3 # indicates format error
  246. if (NF > 2) {
  247. # read the keywords/additional OPTS
  248. req = 0
  249. for (i=3; i<=NF; ++i) {
  250. if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") {
  251. if (onoff != $(i)) {
  252. if (onoff == "")
  253. onoff = $(i)
  254. else
  255. break # on/off conflict
  256. }
  257. } else if ($(i) == "requires")
  258. req = 1
  259. else if (req != 1)
  260. break # bad line: handled below
  261. else {
  262. reqread = reqread " READ_" $(i)
  263. reqwrite = reqwrite " WRITE_" $(i)
  264. }
  265. }
  266. }
  267. if (i > NF) {
  268. # Output new 'option' lines to the intermediate file (out)
  269. print "option READ_" $2, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", $2, onoff >out
  270. print "option WRITE_" $2, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", $2, onoff >out
  271. next
  272. }
  273. # Else hit the error handler below - bad line format!
  274. }
  275. # setting MACRO ( requires MACRO* )* [ default VALUE ]
  276. # Behaves in a similar way to 'option' without looking for NO_ or
  277. # _SUPPORTED; the macro is enabled if it is defined so long as all
  278. # the 'requires' macros are also defined. The definitions may be
  279. # empty, an error will be issued if the 'requires' macros are
  280. # *not* defined. If given the 'default' value is used if the
  281. # macro is not defined. The default value will be re-tokenised.
  282. # (BTW: this is somewhat restrictive, it mainly exists for the
  283. # support of non-standard configurations and numeric parameters,
  284. # see the uses in scripts/options.dat
  285. $1 == "setting" && (NF == 2 || NF >= 3 && ($3 == "requires" || $3 == "default")){
  286. reqs = ""
  287. deflt = ""
  288. isdef = 0
  289. key = ""
  290. for (i=3; i<=NF; ++i)
  291. if ($(i) == "requires" || $(i) == "default") {
  292. key = $(i)
  293. if (key == "default") isdef = 1
  294. } else if (key == "requires")
  295. reqs = reqs " " $(i)
  296. else if (key == "default")
  297. deflt = deflt " " $(i)
  298. else
  299. break # Format error, handled below
  300. setting[$2] = reqs
  301. # NOTE: this overwrites a previous value silently
  302. if (isdef && deflt == "")
  303. deflt = " " # as a flag to force output
  304. defaults[$2] = deflt
  305. next
  306. }
  307. # The order of the dependency lines (option, chunk, setting) is irrelevant
  308. # - the 'enables', 'requires' and 'if' settings will be used to determine
  309. # the correct order in the output and the final values in pnglibconf.h are
  310. # not order dependent. 'requires' and 'if' entries take precedence over
  311. # 'enables' from other options; if an option requires another option it
  312. # won't be set regardless of any options that enable it unless the other
  313. # option is also enabled.
  314. #
  315. # Similarly 'enables' trumps a NO_ definition in CFLAGS or pngusr.h
  316. #
  317. # For simplicity cycles in the definitions are regarded as errors,
  318. # even if they are not ambiguous.
  319. # A given NAME can be specified in as many 'option' lines as required, the
  320. # definitions are additive.
  321. # For backwards compatibility equivalent macros may be listed thus:
  322. #
  323. # = [NO_]NAME MACRO
  324. # Makes -DMACRO equivalent to -DPNG_NO_NAME or -DPNG_NAME_SUPPORTED
  325. # as appropriate.
  326. #
  327. # The definition is injected into the C compiler input when encountered
  328. # in the second pass (so all these definitions appear *after* the @
  329. # lines!)
  330. #
  331. # 'NAME' is as above, but 'MACRO' is the full text of the equivalent
  332. # old, deprecated, macro.
  333. $1 == "=" && NF == 3{
  334. print "#ifdef PNG_" $3 >out
  335. if ($2 ~ /^NO_/)
  336. print "# define PNG_" $2 >out
  337. else
  338. print "# define PNG_" $2 "_SUPPORTED" >out
  339. print "#endif" >out
  340. next
  341. }
  342. # Lines may be injected into the C compiler input by preceding them
  343. # with an "@" character. The line is copied with just the leading
  344. # @ removed.
  345. $1 ~ /^@/{
  346. # sub(/^[ ]*@/, "")
  347. $1 = substr($1, 2)
  348. print >out
  349. next
  350. }
  351. # Check for unreognized lines, because of the preprocessing chunk
  352. # format errors will be detected on the first pass independent of
  353. # any other format errors.
  354. {
  355. print "options.awk: bad line (" NR "):", $0
  356. err = 1 # prevent END{} running
  357. exit 1
  358. }
  359. # For checking purposes names that start with "ok_" or "fail_" are
  360. # not output to pnglibconf.h and must be either enabled or disabled
  361. # respectively for the build to succeed. This allows interdependencies
  362. # between options of the form "at least one of" or "at most one of"
  363. # to be checked. For example:
  364. #
  365. # option FLOATING_POINT enables ok_math
  366. # option FIXED_POINT enables ok_math
  367. # This ensures that at least one of FLOATING_POINT and FIXED_POINT
  368. # must be set for the build to succeed.
  369. #
  370. # option fail_math requires FLOATING_POINT FIXED_POINT
  371. # This means the build will fail if *both* FLOATING_POINT and
  372. # FIXED_POINT are set (this is an example; in fact both are allowed.)
  373. #
  374. # If all these options were given the build would require exactly one
  375. # of the names to be enabled.
  376. END{
  377. # END{} gets run on an exit (a traditional awk feature)
  378. if (err) exit 1
  379. if (pre) {
  380. # Record the final value of the variables
  381. print "deb =", deb >out
  382. if (everything != "") {
  383. print "everything =", everything >out
  384. }
  385. print "logunsupported =", logunsupported >out
  386. exit 0
  387. }
  388. # Do the 'setting' values first, the algorithm the standard
  389. # tree walk (O(1)) done in an O(2) while/for loop; interations
  390. # settings x depth, outputing the deepest required macros
  391. # first.
  392. print "" >out
  393. print "/* SETTINGS */" >out
  394. print comment, "settings", cend >out
  395. finished = 0
  396. while (!finished) {
  397. finished = 1
  398. movement = 0 # done nothing
  399. for (i in setting) if (!doneset[i]) {
  400. nreqs = split(setting[i], r)
  401. if (nreqs > 0) {
  402. for (j=1; j<=nreqs; ++j) if (!doneset[r[j]]) {
  403. break
  404. }
  405. if (j<=nreqs) {
  406. finished = 0
  407. continue # try a different setting
  408. }
  409. }
  410. # All the requirements have been processed, output
  411. # this setting.
  412. if (deb) print "setting", i
  413. print "" >out
  414. print "/* setting: ", i >out
  415. print " * requires:" setting[i] >out
  416. print " * default: ", defaults[i], "*/" >out
  417. if (defaults[i] == "") { # no default, only check if defined
  418. print "#ifdef PNG_" i >out
  419. }
  420. for (j=1; j<=nreqs; ++j) {
  421. print "# ifndef PNG_" r[j] >out
  422. print error, i, "requires", r[j] end >out
  423. print "# endif" >out
  424. }
  425. if (defaults[i] != "") { # default handling
  426. print "#ifdef PNG_" i >out
  427. }
  428. print def i, "PNG_" i end >out
  429. if (defaults[i] != "") {
  430. print "#else /*default*/" >out
  431. # And add the default definition for the benefit
  432. # of later settings an options test:
  433. print "# define PNG_" i defaults[i] >out
  434. print def i defaults[i] end >out
  435. }
  436. print "#endif" >out
  437. doneset[i] = 1
  438. ++movement
  439. }
  440. if (!finished && !movement) {
  441. print "setting: loop or missing setting in 'requires', cannot process:"
  442. for (i in setting) if (!doneset[i]) {
  443. print " setting", i, "requires" setting[i]
  444. }
  445. exit 1
  446. }
  447. }
  448. print comment, "end of settings", cend >out
  449. # Now do the options - somewhat more complex. The dependency
  450. # tree is thus:
  451. #
  452. # name > name
  453. # name requires name
  454. # name if name
  455. # name enabledby name
  456. #
  457. # First build a list 'tree' by option of all the things on which
  458. # it depends.
  459. print "" >out
  460. print "/* OPTIONS */" >out
  461. print comment, "options", cend >out
  462. for (opt in enabledby) tree[opt] = 1 # may not be explicit options
  463. for (opt in option) if (opt != "") {
  464. o = option[opt]
  465. # option should always be one of the following values
  466. if (o != "on" && o != "off" && o != "disabled" && o != "enabled") {
  467. print "internal option error (" o ")"
  468. exit 1
  469. }
  470. tree[opt] = "" # so unlisted options marked
  471. }
  472. for (opt in tree) if (opt != "") {
  473. if (tree[opt] == 1) {
  474. tree[opt] = ""
  475. if (option[opt] != "") {
  476. print "internal error (1)"
  477. exit 1
  478. }
  479. # Macros only listed in 'enables' remain off unless
  480. # one of the enabling macros is on.
  481. option[opt] = "disabled"
  482. }
  483. split("", list) # clear 'list'
  484. # Now add every requires, iffs or enabledby entry to 'list'
  485. # so that we can add a unique list of requirements to tree[i]
  486. split(requires[opt] iffs[opt] enabledby[opt], r)
  487. for (i in r) list[r[i]] = 1
  488. for (i in list) tree[opt] = tree[opt] " " i
  489. }
  490. # print the tree for extreme debugging
  491. if (deb > 2) for (i in tree) if (i != "") print i, "depends-on" tree[i]
  492. # Ok, now check all options marked explicitly 'on' or 'off':
  493. #
  494. # If an option[opt] is 'on' then turn on all requires[opt]
  495. # If an option[opt] is 'off' then turn off all enabledby[opt]
  496. #
  497. # Error out if we have to turn 'on' an 'off' option or vice versa.
  498. npending = 0
  499. for (opt in option) if (opt != "") {
  500. if (option[opt] == "on" || option[opt] == "off") {
  501. pending[++npending] = opt
  502. }
  503. }
  504. err = 0 # set on error
  505. while (npending > 0) {
  506. opt = pending[npending--]
  507. if (option[opt] == "on") {
  508. nreqs = split(requires[opt], r)
  509. for (j=1; j<=nreqs; ++j) {
  510. if (option[r[j]] == "off") {
  511. print "option", opt, "turned on, but requirement", r[j], "is turned off"
  512. err = 1
  513. } else if (option[r[j]] != "on") {
  514. option[r[j]] = "on"
  515. pending[++npending] = r[j]
  516. }
  517. }
  518. } else {
  519. if (option[opt] != "off") {
  520. print "internal error (2)"
  521. exit 1
  522. }
  523. nreqs = split(enabledby[opt], r)
  524. for (j=1; j<=nreqs; ++j) {
  525. if (option[r[j]] == "on") {
  526. print "option", opt, "turned off, but enabled by", r[j], "which is turned on"
  527. err = 1
  528. } else if (option[r[j]] != "off") {
  529. option[r[j]] = "off"
  530. pending[++npending] = r[j]
  531. }
  532. }
  533. }
  534. }
  535. if (err) exit 1
  536. # option[i] is now the complete list of all the tokens we may
  537. # need to output, go through it as above, depth first.
  538. finished = 0
  539. while (!finished) {
  540. finished = 1
  541. movement = 0 # done nothing
  542. for (i in option) if (!done[i]) {
  543. nreqs = split(tree[i], r)
  544. if (nreqs > 0) {
  545. for (j=1; j<=nreqs; ++j) if (!done[r[j]]) {
  546. break
  547. }
  548. if (j<=nreqs) {
  549. finished = 0
  550. continue # next option
  551. }
  552. }
  553. # All the requirements have been processed, output
  554. # this option. An option is _SUPPORTED if:
  555. #
  556. # all 'requires' are _SUPPORTED AND
  557. # at least one of the 'if' options are _SUPPORTED AND
  558. # EITHER:
  559. # The name is _SUPPORTED (on the command line)
  560. # OR:
  561. # an 'enabledby' is _SUPPORTED
  562. # OR:
  563. # NO_name is not defined AND
  564. # the option is not disabled; an option is disabled if:
  565. # option == off
  566. # option == disabled && everything != on
  567. # option == "" && everything == off
  568. if (deb) print "option", i
  569. print "" >out
  570. print "/* option:", i, option[i] >out
  571. print " * requires: " requires[i] >out
  572. print " * if: " iffs[i] >out
  573. print " * enabled-by:" enabledby[i], "*/" >out
  574. print "#undef PNG_on" >out
  575. print "#define PNG_on 1" >out
  576. # requires
  577. nreqs = split(requires[i], r)
  578. for (j=1; j<=nreqs; ++j) {
  579. print "#ifndef PNG_" r[j] "_SUPPORTED" >out
  580. print "# undef PNG_on /*!" r[j] "*/" >out
  581. # this error appears in the final output if something
  582. # was switched 'on' but the processing above to force
  583. # the requires did not work
  584. if (option[i] == "on") {
  585. print error, i, "requires", r[j] end >out
  586. }
  587. print "#endif" >out
  588. }
  589. # if
  590. nreqs = split(iffs[i], r)
  591. print "#undef PNG_no_if" >out
  592. if (nreqs > 0) {
  593. print "/* if" iffs[i], "*/" >out
  594. print "#define PNG_no_if 1" >out
  595. for (j=1; j<=nreqs; ++j) {
  596. print "#ifdef PNG_" r[j] "_SUPPORTED" >out
  597. print "# undef PNG_no_if /*" r[j] "*/" >out
  598. print "#endif" >out
  599. }
  600. print "#ifdef PNG_no_if /*missing if*/" >out
  601. print "# undef PNG_on" >out
  602. # There is no checking above for this, because we
  603. # don't know which 'if' to choose, so whine about
  604. # it here:
  605. if (option[i] == "on") {
  606. print error, i, "needs one of:", iffs[i] end >out
  607. }
  608. print "#endif" >out
  609. }
  610. print "#ifdef PNG_on /*requires, if*/" >out
  611. # enables
  612. print "# undef PNG_not_enabled" >out
  613. print "# define PNG_not_enabled 1" >out
  614. print " /* enabled by" enabledby[i], "*/" >out
  615. nreqs = split(enabledby[i], r)
  616. for (j=1; j<=nreqs; ++j) {
  617. print "#ifdef PNG_" r[j] "_SUPPORTED" >out
  618. print "# undef PNG_not_enabled /*" r[j] "*/" >out
  619. # Oops, probably not intended (should be factored
  620. # out by the checks above).
  621. if (option[i] == "off") {
  622. print error, i, "enabled by:", r[j] end >out
  623. }
  624. print "#endif" >out
  625. }
  626. print "# ifndef PNG_" i "_SUPPORTED /*!command line*/" >out
  627. print "# ifdef PNG_not_enabled /*!enabled*/" >out
  628. if (option[i] == "off" || option[i] == "disabled" && everything != "on" || option[i] == "enabled" && everything == "off") {
  629. print "# undef PNG_on /*default off*/" >out
  630. } else {
  631. print "# ifdef PNG_NO_" i >out
  632. print "# undef PNG_on /*turned off*/" >out
  633. print "# endif" >out
  634. print "# ifdef PNG_NO_" i "_SUPPORTED" >out
  635. print "# undef PNG_on /*turned off*/" >out
  636. print "# endif" >out
  637. }
  638. print "# endif /*!enabled*/" >out
  639. print "# ifdef PNG_on" >out
  640. # The _SUPPORTED macro must be defined so that dependent
  641. # options output later work.
  642. print "# define PNG_" i "_SUPPORTED" >out
  643. print "# endif" >out
  644. print "# endif /*!command line*/" >out
  645. # If PNG_on is still set the option should be defined in
  646. # pnglibconf.h
  647. print "# ifdef PNG_on" >out
  648. if (i ~ /^fail_/) {
  649. print error, i, "is on: enabled by:" iffs[i] enabledby[i] ", requires" requires[i] end >out
  650. } else if (i !~ /^ok_/) {
  651. print def i sup >out
  652. }
  653. print "# endif /* definition */" >out
  654. print "#endif /*requires, if*/" >out
  655. if (logunsupported || i ~ /^ok_/) {
  656. print "#ifndef PNG_on" >out
  657. if (logunsupported) {
  658. print und i une >out
  659. }
  660. if (i ~ /^ok_/) {
  661. print error, i, "not enabled: requires:" requires[i] ", enabled by:" iffs[i] enabledby[i] end >out
  662. }
  663. print "#endif" >out
  664. }
  665. done[i] = 1
  666. ++movement
  667. }
  668. if (!finished && !movement) {
  669. print "option: loop or missing option in dependency tree, cannot process:"
  670. for (i in option) if (!done[i]) {
  671. print " option", i, "depends on" tree[i], "needs:"
  672. nreqs = split(tree[i], r)
  673. if (nreqs > 0) for (j=1; j<=nreqs; ++j) if (!done[r[j]]) {
  674. print " " r[j]
  675. }
  676. }
  677. exit 1
  678. }
  679. }
  680. print comment, "end of options", cend >out
  681. # Regular end - everything looks ok
  682. if (protect != "") {
  683. print start "#endif", cx, protect, "*/" end >out
  684. }
  685. }