]>
git.saurik.com Git - wxWidgets.git/blob - src/png/scripts/options.awk
2 # scripts/options.awk - library build configuration control
4 # last changed in libpng version 1.5.7 - December 15, 2011
6 # Copyright (c) 1998-2011 Glenn Randers-Pehrson
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
12 # The output of this script is written to the file given by
13 # the variable 'out'. The script is run twice, once with
14 # an intermediate output file, 'options.tmp' then again on
15 # that file to produce the final output:
17 # awk -f scripts/options.awk out=options.tmp scripts/options.dfa 1>&2
18 # awk -f scripts/options.awk out=options.dfn options.tmp 1>&2
20 # Some options may be specified on the command line:
22 # deb=1 Causes debugging to be output
23 # logunsupported=1 Causes all options to be recorded in the output
24 # everything=off Causes all options to be disabled by default
25 # everything=on Causes all options to be enabled by default
27 # If awk fails on your platform, try nawk instead.
29 # These options may also be specified in the original input file (and
30 # are copied to the preprocessed file).
33 out=
"" # intermediate, preprocessed, file
34 pre=
-1 # preprocess (first line)
35 version=
"libpng version unknown" # version information
36 version_file=
"" # where to find the version
37 err=
0 # in-line exit sets this
38 # The following definitions prevent the C preprocessor noticing the lines
39 # that will be in the final output file. Some C preprocessors tokenise
40 # the lines, for example by inserting spaces around operators, and all
41 # C preprocessors notice lines that start with '#', most remove comments.
42 # The technique adopted here is to make the final output lines into
43 # C strings (enclosed in double quotes), preceeded by PNG_DFN. As a
44 # consequence the output cannot contain a 'raw' double quote - instead put
45 # @' in, this will be replaced by a single " afterward. See the parser
46 # script dfn.awk for more capabilities (not required here). Note that if
47 # you need a " in a 'setting' in pnglibconf.dfa it must also be @'!
48 dq=
"@'" # For a single double quote
49 start=
" PNG_DFN \"" # Start stuff to output (can't contain a "!)
50 end=
"\" " # End stuff to output
51 subs=
"@\" " # Substitute start (substitute a C macro)
52 sube=
" \"@" # Substitute end
53 comment=start
"/*" # Comment start
54 cend=
"*/" end # Comment end
55 def=start
"#define PNG_" # Arbitrary define
56 sup=
"_SUPPORTED" end # end supported option
57 und=comment
"#undef PNG_" # Unsupported option
58 une=
"_SUPPORTED" cend
# end unsupported option
59 error=start
"ERROR:" # error message, terminate with 'end'
62 deb=
0 # debug - set on command line
63 everything=
"" # do not override defaults
64 logunsupported=
0 # write unsupported options too
68 option
[""] =
"" # list of all options: default enabled/disabled
69 done
[""] =
1 # marks option as having been output
70 requires
[""] =
"" # requires by option
71 iffs
[""] =
"" # if by option
72 enabledby
[""] =
"" # options that enable it by option
73 sets
[""] =
"" # settings set by each option
74 setval
[""] =
"" # value to set (indexed: 'option sets[option]')
76 setting
[""] =
"" # requires by setting
77 defaults
[""] =
"" # used for a defaulted value
78 doneset
[""] =
1 # marks setting as having been output
79 r
[""] =
"" # Temporary array
81 # For decorating the output file
85 # The output file must be specified before any input:
87 print "out=output.file must be given on the command line"
92 # The very first line indicates whether we are reading pre-processed
93 # input or not, this must come *first* because 'PREPROCESSED' needs
94 # to be the very first line in the temporary file.
96 if ($0 ==
"PREPROCESSED") {
101 print "PREPROCESSED" >out
102 # And fall through to continue processing
106 # While pre-processing if version is set to "search" look for a version string
107 # in the following file.
108 pre
&& version ==
"search" && version_file ==
""{
109 version_file =
FILENAME
112 pre
&& version ==
"search" && version_file
!= FILENAME{
113 print "version string not found in", version_file
118 pre
&& version ==
"search" && $0 ~
/^ \
* libpng version
/{
119 version =
substr($0, 4)
120 print "version =", version
>out
124 pre
&& FILENAME == version_file
{
129 # Sets the given variable to the given value (the syntax is fairly
130 # free form, except for deb (you are expected to understand how to
131 # set the debug variable...)
133 # This happens before the check on 'pre' below skips most of the
134 # rest of the actions, so the variable settings happen during
135 # preprocessing but are recorded in the END action too. This
136 # allows them to be set on the command line too.
137 $0 ~
/^
[ ]*version
[ ]*=
/{
138 sub(/^
[ ]*version
[ ]*=
[ ]*/, "")
142 $0 ~
/^
[ ]*everything
[ =
]*off
[ ]*$
/{
146 $0 ~
/^
[ ]*everything
[ =
]*on
[ ]*$
/{
150 $0 ~
/^
[ ]*logunsupported
[ =
]*0[ ]*$
/{
154 $0 ~
/^
[ ]*logunsupported
[ =
]*1[ ]*$
/{
158 $1 ==
"deb" && $2 ==
"=" && NF ==
3{
163 # Preprocessing - this just copies the input file with lines
164 # that need preprocessing (just chunk at present) expanded
165 # The bare "pre" instead of "pre != 0" crashes under Sunos awk
166 pre
&& $1 != "chunk"{
171 # The first characters of the line determine how it is processed,
172 # leading spaces are ignored. In general tokens that are not
173 # keywords are the names of options. An option 'name' is
174 # controlled by the definition of the corresponding macros:
176 # PNG_name_SUPPORTED The option is turned on
178 # PNG_NO_name_SUPPORTED If the first macro is not defined
179 # either of these will turn the option off
181 # If none of these macros are defined the option is turned on, unless
182 # the keyword 'off' is given in a line relating to the option. The
183 # keyword 'on' can also be given, but it will be ignored (since it is
186 # In the syntax below a 'name' is indicated by "NAME", other macro
187 # values are indicated by "MACRO", as with "NAME" the leading "PNG_"
188 # is omitted, but in this case the "NO_" prefix and the "_SUPPORTED"
189 # suffix are never used.
191 # Each line is introduced by a keyword - the first non-space characters
192 # on the line. A line starting with a '#' is a comment - it is totally
193 # ignored. Keywords are as follows, a NAME, is simply a macro name
194 # without the leading PNG_, PNG_NO_ or the trailing _SUPPORTED.
196 $1 ~
/^
#/ || $0 ~ /^[ ]*$/{
201 # The whole line is placed in the output file as a comment with
202 # the preceding 'com' removed
205 # sub(/^[ ]*com[ ]*/, "")
207 print comment
$0, cend
>out
214 # Inserts a version comment
215 $1 ==
"version" && NF ==
1{
217 print "ERROR: no version string set"
218 err =
1 # prevent END{} running
222 print comment
, version
, cend
>out
226 # file output input protect
227 # Informational: the official name of the input file (without
228 # make generated local directories), the official name of the
229 # output file and, if required, a name to use in a protection
230 # macro for the contents.
231 $1 ==
"file" && NF >=
2{
232 print comment
, $2, cend
>out
233 print comment
, "Machine generated file: DO NOT EDIT", cend
>out
235 print comment
, "Derived from:", $3, cend
>out
238 print start
"#ifndef", protect
end >out
239 print start
"#define", protect
end >out
244 # option NAME ( (requires|enables|if) NAME* | on | off | disabled |
245 # sets SETTING VALUE+ )*
247 # Declares an option 'NAME' and describes its default setting (disabled)
248 # and its relationship to other options. The option is disabled
249 # unless *all* the options listed after 'requires' are set and at
250 # least one of the options listed after 'if' is set. If the
251 # option is set then it turns on all the options listed after 'enables'.
253 # Note that "enables" takes priority over the required/if/disabled/off
254 # setting of the target option.
256 # The definition file may list an option as 'disabled': off by default,
257 # otherwise the option is enabled: on by default. A later (and it must
258 # be later) entry may turn an option on or off explicitly.
260 $1 ==
"option" && NF >=
2{
263 onoff = option
[opt
] # records current (and the default is "", enabled)
267 if (istart ==
1) { # continuation line
270 if (val
!= 1) { # error reading it
272 print "option", opt
": ERROR: missing contination line"
274 print "option", opt
": ERROR: error reading continuation line"
276 # This is a hard error
277 err =
1 # prevent END{} running
282 for (i=istart
; i
<=
NF; ++i
) {
285 if (val ==
"on" || val ==
"off" || val ==
"disabled") {
288 # on or off can zap disabled or enabled:
289 if (onoff ==
"" || (onoff ==
"disabled" || onoff ==
"enabled") &&
290 (val ==
"on" || val ==
"off")) {
291 # It's easy to mis-spell the option when turning it
292 # on or off, so warn about it here:
293 if (onoff ==
"" && (val ==
"on" || val ==
"off")) {
294 print "option", opt
": ERROR: turning unrecognized option", val
295 # For the moment error out - it is safer
296 err =
1 # prevent END{} running
301 # Print a message, otherwise the error
302 # below is incomprehensible
303 print "option", opt
": currently", onoff
": attempt to turn", val
307 } else if (val ==
"requires" || val ==
"if" || val ==
"enables" || val ==
"sets") {
309 } else if (key ==
"requires") {
310 requires
[opt
] = requires
[opt
] " " val
311 } else if (key ==
"if") {
312 iffs
[opt
] = iffs
[opt
] " " val
313 } else if (key ==
"enables") {
314 enabledby
[val
] = enabledby
[val
] " " opt
315 } else if (key ==
"sets") {
316 sets
[opt
] = sets
[opt
] " " val
319 } else if (key ==
"setval") {
320 setval
[opt
" " set
] = setval
[opt
" " set
] " " val
322 break # bad line format
326 } while (i
> NF && $0 ~
/,$
/)
329 # Set the option, defaulting to 'enabled'
330 if (onoff ==
"") onoff =
"enabled"
334 # Else fall through to the error handler
337 # chunk NAME [requires OPT] [enables LIST] [on|off|disabled]
338 # Expands to the 'option' settings appropriate to the reading and
339 # writing of an ancilliary PNG chunk 'NAME':
341 # option READ_NAME requires READ_ANCILLARY_CHUNKS [READ_OPT]
342 # option READ_NAME enables NAME LIST
343 # [option READ_NAME off]
344 # option WRITE_NAME requires WRITE_ANCILLARY_CHUNKS [WRITE_OPT]
345 # option WRITE_NAME enables NAME LIST
346 # [option WRITE_NAME off]
348 pre
!= 0 && $1 ==
"chunk" && NF >=
2{
349 # 'chunk' is handled on the first pass by writing appropriate
350 # 'option' lines into the intermediate file.
360 if (istart ==
1) { # continuation line
363 if (val
!= 1) { # error reading it
365 print "chunk", opt
": ERROR: missing contination line"
367 print "chunk", opt
": ERROR: error reading continuation line"
369 # This is a hard error
370 err =
1 # prevent END{} running
375 # read the keywords/additional OPTS
376 for (i=istart
; i
<=
NF; ++i
) {
379 if (val ==
"on" || val ==
"off" || val ==
"disabled") {
384 break # on/off conflict
387 } else if (val ==
"requires")
389 else if (val ==
"enables")
392 reqread = reqread
" READ_" val
393 reqwrite = reqwrite
" WRITE_" val
395 enables = enables
" " val
397 break # bad line: handled below
401 } while (i
> NF && $0 ~
/,$
/)
404 # Output new 'option' lines to the intermediate file (out)
405 print "option READ_" opt
, "requires READ_ANCILLARY_CHUNKS" reqread
, "enables", opt enables
, onoff
>out
406 print "option WRITE_" opt
, "requires WRITE_ANCILLARY_CHUNKS" reqwrite
, "enables", opt enables
, onoff
>out
409 # Else hit the error handler below - bad line format!
412 # setting MACRO ( requires MACRO* )* [ default VALUE ]
413 # Behaves in a similar way to 'option' without looking for NO_ or
414 # _SUPPORTED; the macro is enabled if it is defined so long as all
415 # the 'requires' macros are also defined. The definitions may be
416 # empty, an error will be issued if the 'requires' macros are
417 # *not* defined. If given the 'default' value is used if the
418 # macro is not defined. The default value will be re-tokenised.
419 # (BTW: this is somewhat restrictive, it mainly exists for the
420 # support of non-standard configurations and numeric parameters,
421 # see the uses in scripts/options.dat
423 $1 ==
"setting" && (NF ==
2 || NF >=
3 && ($3 ==
"requires" || $3 ==
"default")){
428 for (i=
3; i
<=
NF; ++i
)
429 if ($
(i
) ==
"requires" || $
(i
) ==
"default") {
431 if (key ==
"default") isdef =
1
432 } else if (key ==
"requires")
434 else if (key ==
"default")
435 deflt = deflt
" " $
(i
)
437 break # Format error, handled below
440 # NOTE: this overwrites a previous value silently
441 if (isdef
&& deflt ==
"")
442 deflt =
" " # as a flag to force output
447 # The order of the dependency lines (option, chunk, setting) is irrelevant
448 # - the 'enables', 'requires' and 'if' settings will be used to determine
449 # the correct order in the output and the final values in pnglibconf.h are
450 # not order dependent. 'requires' and 'if' entries take precedence over
451 # 'enables' from other options; if an option requires another option it
452 # won't be set regardless of any options that enable it unless the other
453 # option is also enabled.
455 # Similarly 'enables' trumps a NO_ definition in CFLAGS or pngusr.h
457 # For simplicity cycles in the definitions are regarded as errors,
458 # even if they are not ambiguous.
459 # A given NAME can be specified in as many 'option' lines as required, the
460 # definitions are additive.
462 # For backwards compatibility equivalent macros may be listed thus:
465 # Makes -DMACRO equivalent to -DPNG_NO_NAME or -DPNG_NAME_SUPPORTED
468 # The definition is injected into the C compiler input when encountered
469 # in the second pass (so all these definitions appear *after* the @
472 # 'NAME' is as above, but 'MACRO' is the full text of the equivalent
473 # old, deprecated, macro.
475 $1 ==
"=" && NF ==
3{
476 print "#ifdef PNG_" $3 >out
478 print "# define PNG_" $2 >out
480 print "# define PNG_" $2 "_SUPPORTED" >out
485 # Lines may be injected into the C compiler input by preceding them
486 # with an "@" character. The line is copied with just the leading
496 # Check for unreognized lines, because of the preprocessing chunk
497 # format errors will be detected on the first pass independent of
498 # any other format errors.
500 print "options.awk: bad line (" NR "):", $0
501 err =
1 # prevent END{} running
505 # For checking purposes names that start with "ok_" or "fail_" are
506 # not output to pnglibconf.h and must be either enabled or disabled
507 # respectively for the build to succeed. This allows interdependencies
508 # between options of the form "at least one of" or "at most one of"
509 # to be checked. For example:
511 # option FLOATING_POINT enables ok_math
512 # option FIXED_POINT enables ok_math
513 # This ensures that at least one of FLOATING_POINT and FIXED_POINT
514 # must be set for the build to succeed.
516 # option fail_math requires FLOATING_POINT FIXED_POINT
517 # This means the build will fail if *both* FLOATING_POINT and
518 # FIXED_POINT are set (this is an example; in fact both are allowed.)
520 # If all these options were given the build would require exactly one
521 # of the names to be enabled.
524 # END{} gets run on an exit (a traditional awk feature)
528 # Record the final value of the variables
529 print "deb =", deb
>out
530 if (everything
!= "") {
531 print "everything =", everything
>out
533 print "logunsupported =", logunsupported
>out
537 # Do the options first (allowing options to set settings). The dependency
543 # name enabledby name
545 # First build a list 'tree' by option of all the things on which
548 print "/* OPTIONS */" >out
549 print comment
, "options", cend
>out
550 for (opt in enabledby
) tree
[opt
] =
1 # may not be explicit options
551 for (opt in option
) if (opt
!= "") {
553 # option should always be one of the following values
554 if (o
!= "on" && o
!= "off" && o
!= "disabled" && o
!= "enabled") {
555 print "internal option error (" o
")"
558 tree
[opt
] =
"" # so unlisted options marked
560 for (opt in tree
) if (opt
!= "") {
561 if (tree
[opt
] ==
1) {
563 if (option
[opt
] != "") {
564 print "internal error (1)"
567 # Macros only listed in 'enables' remain off unless
568 # one of the enabling macros is on.
569 option
[opt
] =
"disabled"
572 split("", list
) # clear 'list'
573 # Now add every requires, iffs or enabledby entry to 'list'
574 # so that we can add a unique list of requirements to tree[i]
575 split(requires
[opt
] iffs
[opt
] enabledby
[opt
], r
)
576 for (i in r
) list
[r
[i
]] =
1
577 for (i in list
) tree
[opt
] = tree
[opt
] " " i
580 # print the tree for extreme debugging
581 if (deb
> 2) for (i in tree
) if (i
!= "") print i
, "depends-on" tree
[i
]
583 # Ok, now check all options marked explicitly 'on' or 'off':
585 # If an option[opt] is 'on' then turn on all requires[opt]
586 # If an option[opt] is 'off' then turn off all enabledby[opt]
588 # Error out if we have to turn 'on' an 'off' option or vice versa.
590 for (opt in option
) if (opt
!= "") {
591 if (option
[opt
] ==
"on" || option
[opt
] ==
"off") {
592 pending
[++npending
] = opt
596 err =
0 # set on error
597 while (npending
> 0) {
598 opt = pending
[npending
--]
599 if (option
[opt
] ==
"on") {
600 nreqs =
split(requires
[opt
], r
)
601 for (j=
1; j
<=nreqs
; ++j
) {
602 if (option
[r
[j
]] ==
"off") {
603 print "option", opt
, "turned on, but requirement", r
[j
], "is turned off"
605 } else if (option
[r
[j
]] != "on") {
607 pending
[++npending
] = r
[j
]
611 if (option
[opt
] != "off") {
612 print "internal error (2)"
615 nreqs =
split(enabledby
[opt
], r
)
616 for (j=
1; j
<=nreqs
; ++j
) {
617 if (option
[r
[j
]] ==
"on") {
618 print "option", opt
, "turned off, but enabled by", r
[j
], "which is turned on"
620 } else if (option
[r
[j
]] != "off") {
622 pending
[++npending
] = r
[j
]
630 print "PNG_DFN_START_SORT 2" >out
632 # option[i] is now the complete list of all the tokens we may
633 # need to output, go through it as above, depth first.
637 movement =
0 # done nothing
638 for (i in option
) if (!done
[i
]) {
639 nreqs =
split(tree
[i
], r
)
641 for (j=
1; j
<=nreqs
; ++j
) if (!done
[r
[j
]]) {
646 continue # next option
650 # All the requirements have been processed, output
651 # this option. An option is _SUPPORTED if:
653 # all 'requires' are _SUPPORTED AND
654 # at least one of the 'if' options are _SUPPORTED AND
656 # The name is _SUPPORTED (on the command line)
658 # an 'enabledby' is _SUPPORTED
660 # NO_name is not defined AND
661 # the option is not disabled; an option is disabled if:
663 # option == disabled && everything != on
664 # option == "" && everything == off
665 if (deb
) print "option", i
667 print "/* option:", i
, option
[i
] >out
668 print " * requires: " requires
[i
] >out
669 print " * if: " iffs
[i
] >out
670 print " * enabled-by:" enabledby
[i
] >out
671 print " * sets: " sets
[i
], "*/" >out
672 print "#undef PNG_on" >out
673 print "#define PNG_on 1" >out
676 nreqs =
split(requires
[i
], r
)
677 for (j=
1; j
<=nreqs
; ++j
) {
678 print "#ifndef PNG_" r
[j
] "_SUPPORTED" >out
679 print "# undef PNG_on /*!" r
[j
] "*/" >out
680 # this error appears in the final output if something
681 # was switched 'on' but the processing above to force
682 # the requires did not work
683 if (option
[i
] ==
"on") {
684 print error
, i
, "requires", r
[j
] end >out
690 nreqs =
split(iffs
[i
], r
)
691 print "#undef PNG_no_if" >out
693 print "/* if" iffs
[i
], "*/" >out
694 print "#define PNG_no_if 1" >out
695 for (j=
1; j
<=nreqs
; ++j
) {
696 print "#ifdef PNG_" r
[j
] "_SUPPORTED" >out
697 print "# undef PNG_no_if /*" r
[j
] "*/" >out
700 print "#ifdef PNG_no_if /*missing if*/" >out
701 print "# undef PNG_on" >out
702 # There is no checking above for this, because we
703 # don't know which 'if' to choose, so whine about
705 if (option
[i
] ==
"on") {
706 print error
, i
, "needs one of:", iffs
[i
] end >out
711 print "#ifdef PNG_on /*requires, if*/" >out
713 print "# undef PNG_not_enabled" >out
714 print "# define PNG_not_enabled 1" >out
715 print " /* enabled by" enabledby
[i
], "*/" >out
716 nreqs =
split(enabledby
[i
], r
)
717 for (j=
1; j
<=nreqs
; ++j
) {
718 print "#ifdef PNG_" r
[j
] "_SUPPORTED" >out
719 print "# undef PNG_not_enabled /*" r
[j
] "*/" >out
720 # Oops, probably not intended (should be factored
721 # out by the checks above).
722 if (option
[i
] ==
"off") {
723 print error
, i
, "enabled by:", r
[j
] end >out
728 print "# ifndef PNG_" i
"_SUPPORTED /*!command line*/" >out
729 print "# ifdef PNG_not_enabled /*!enabled*/" >out
730 if (option
[i
] ==
"off" || option
[i
] ==
"disabled" && everything
!= "on" || option
[i
] ==
"enabled" && everything ==
"off") {
731 print "# undef PNG_on /*default off*/" >out
733 print "# ifdef PNG_NO_" i
>out
734 print "# undef PNG_on /*turned off*/" >out
736 print "# ifdef PNG_NO_" i
"_SUPPORTED" >out
737 print "# undef PNG_on /*turned off*/" >out
740 print "# endif /*!enabled*/" >out
741 print "# ifdef PNG_on" >out
742 # The _SUPPORTED macro must be defined so that dependent
743 # options output later work.
744 print "# define PNG_" i
"_SUPPORTED" >out
746 print "# endif /*!command line*/" >out
747 # If PNG_on is still set the option should be defined in
749 print "# ifdef PNG_on" >out
751 print error
, i
, "is on: enabled by:" iffs
[i
] enabledby
[i
] ", requires" requires
[i
] end >out
752 } else if (i !~
/^ok_
/) {
754 # Supported option, set required settings
755 nreqs =
split(sets
[i
], r
)
756 for (j=
1; j
<=nreqs
; ++j
) {
757 print "# ifdef PNG_set_" r
[j
] >out
758 # Some other option has already set a value:
759 print error
, i
, "sets", r
[j
] ": duplicate setting" end >out
760 print error
, " previous value: " end "PNG_set_" r
[j
] >out
762 # Else set the default: note that this won't accept arbitrary
763 # values, the setval string must be acceptable to all the C
764 # compilers we use. That means it must be VERY simple; a number,
765 # a name or a string.
766 print "# define PNG_set_" r
[j
], setval
[i
" " r
[j
]] >out
770 print "# endif /* definition */" >out
771 print "#endif /*requires, if*/" >out
772 if (logunsupported
|| i ~
/^ok_
/) {
773 print "#ifndef PNG_on" >out
774 if (logunsupported
) {
778 print error
, i
, "not enabled: requires:" requires
[i
] ", enabled by:" iffs
[i
] enabledby
[i
] end >out
787 if (!finished
&& !movement
) {
788 print "option: loop or missing option in dependency tree, cannot process:"
789 for (i in option
) if (!done
[i
]) {
790 print " option", i
, "depends on" tree
[i
], "needs:"
791 nreqs =
split(tree
[i
], r
)
792 if (nreqs
> 0) for (j=
1; j
<=nreqs
; ++j
) if (!done
[r
[j
]]) {
799 print "PNG_DFN_END_SORT" >out
800 print comment
, "end of options", cend
>out
802 # Do the 'setting' values second, the algorithm the standard
803 # tree walk (O(1)) done in an O(2) while/for loop; interations
804 # settings x depth, outputing the deepest required macros
807 print "/* SETTINGS */" >out
808 print comment
, "settings", cend
>out
809 # Sort (in dfn.awk) on field 2, the setting name
810 print "PNG_DFN_START_SORT 2" >out
814 movement =
0 # done nothing
815 for (i in setting
) if (!doneset
[i
]) {
816 nreqs =
split(setting
[i
], r
)
818 # By default assume the requires values are options, but if there
819 # is no option with that name check for a setting
820 for (j=
1; j
<=nreqs
; ++j
) if (option
[r
[j
]] ==
"" && !doneset
[r
[j
]]) {
825 continue # try a different setting
829 # All the requirements have been processed, output
831 if (deb
) print "setting", i
833 # Remove any spurious trailing spaces
835 # A leading @ means leave it unquoted so the preprocessor
836 # can substitute the build time value
838 deflt =
" " subs
substr(deflt
, 3) sube
840 print "/* setting: ", i
>out
841 print " * requires:" setting
[i
] >out
842 print " * default: ", defaults
[i
] deflt
, "*/" >out
843 for (j=
1; j
<=nreqs
; ++j
) {
844 if (option
[r
[j
]] != "")
845 print "#ifndef PNG_" r
[j
] "_SUPPORTED" >out
847 print "#ifndef PNG_" r
[j
] >out
848 print error
, i
, "requires", r
[j
] end >out
853 # 1) External definition; trumps:
854 # 2) Option 'sets' value; trumps:
855 # 3) Setting 'default'
857 print "#ifdef PNG_" i
>out
858 # PNG_<i> is defined, so substitute the value:
859 print def i
, subs
"PNG_" i sube
end >out
860 print "#else /* use default */" >out
861 print "# ifdef PNG_set_" i
>out
862 # Value from an option 'sets' argument
863 print def i
, subs
"PNG_set_" i sube
end >out
864 # This is so that subsequent tests on the setting work:
865 print "# define PNG_" i
, "1" >out
866 if (defaults
[i
] != "") {
867 print "# else /*default*/" >out
868 print def i deflt
end >out
869 print "# define PNG_" i
, "1" >out
871 print "# endif /* defaults */" >out
872 print "#endif /* setting", i
, "*/" >out
878 if (!finished
&& !movement
) {
879 print "setting: loop or missing setting in 'requires', cannot process:"
880 for (i in setting
) if (!doneset
[i
]) {
881 print " setting", i
, "requires" setting
[i
]
886 print "PNG_DFN_END_SORT" >out
887 print comment
, "end of settings", cend
>out
889 # Regular end - everything looks ok
891 print start
"#endif", "/*", protect
, "*/" end >out