AutoGen - The Automated Program Generator
AutoGen - The Automated Program Generator
Bruce Korb
bkorb@gnu.org
AutoGen copyright
c 1992-2007 Bruce Korb
1 Introduction
AutoGen is a tool designed for generating program files that contain repetitive text with
varied substitutions. Its goal is to simplify the maintenance of programs that contain large
amounts of repetitious text. This is especially valuable if there are several blocks of such
text that must be kept synchronized in parallel tables.
One common example is the problem of maintaining the code required for processing
program options. Processing options requires a minimum of four different constructs be
kept in proper order in different places in your program. You need at least:
1. The flag character in the flag string,
2. code to process the flag when it is encountered,
3. a global state variable or two, and
4. a line in the usage text.
You will need more things besides this if you choose to implement long option names,
rc/ini/config file processing, environment variables and so on. All of this can be done
mechanically; with the proper templates and this program. In fact, it has already been
done and AutoGen itself uses it See Chapter 7 [AutoOpts], page 73. For a simple example
of Automated Option processing, See Section 7.3 [Quick Start], page 76. For a full list of
the Automated Option features, See Section 7.1 [Features], page 73.
expressions that transform the value. Of course, our expressions are less cryptic than
the shell methods.
6. These same markers are used, in conjunction with enclosed keywords, to indicate sec-
tions of text that are to be skipped and for sections of text that are to be repeated.
This is a major improvement over using C preprocessing macros. With the C prepro-
cessor, you have no way of selecting output text because it is an unvarying, mechanical
substitution process.
7. Finally, we supply methods for carefully controlling the output. Sometimes, it is just
simply easier and clearer to compute some text or a value in one context when its
application needs to be later. So, functions are available for saving text or values for
later use.
associations between the enumeration names and the strings. The order of the differently
named elements inside of list is unimportant. They are reversed inside of the beta entry
and the output is unaffected.
Now, to actually create the output, we need a template or two that can be expanded
into the files you want. In this program, we use a single template that is capable of multiple
output files. The definitions above refer to a ‘list’ template, so it would normally be
named, ‘list.tpl’.
It looks something like this. (For a full description, See Chapter 3 [Template File],
page 20.)
[+ AutoGen5 template h c +]
[+ CASE (suffix) +][+
== h +]
typedef enum {[+
FOR list "," +]
IDX_[+ (string-upcase! (get "list_element")) +][+
ENDFOR list +] } list_enum;
== c +]
#include "list.h"
char const* az_name_list[] = {[+
FOR list "," +]
"[+list_info+]"[+
ENDFOR list +] };[+
ESAC +]
The [+ AutoGen5 template h c +] text tells AutoGen that this is an AutoGen version
5 template file; that it is to be processed twice; that the start macro marker is [+; and the
end marker is +]. The template will be processed first with a suffix value of h and then
with c. Normally, the suffix values are appended to the ‘base-name’ to create the output
file name.
The [+ == h +] and [+ == c +] CASE selection clauses select different text for the two
different passes. In this example, the output is nearly disjoint and could have been put in
two separate templates. However, sometimes there are common sections and this is just an
example.
The [+FOR list "," +] and [+ ENDFOR list +] clauses delimit a block of text that will
be repeated for every definition of list. Inside of that block, the definition name-value
pairs that are members of each list are available for substitutions.
The remainder of the macros are expressions. Some of these contain special expres-
sion functions that are dependent on AutoGen named values; others are simply Scheme
expressions, the result of which will be inserted into the output text. Other expressions are
names of AutoGen values. These values will be inserted into the output text. For example,
[+list_info+] will result in the value associated with the name list_info being inserted
Chapter 1: Introduction 4
between the double quotes and (string-upcase! (get "list_element")) will first "get"
the value associated with the name list_element, then change the case of all the letters
to upper case. The result will be inserted into the output document.
If you have compiled AutoGen, you can copy out the template and definitions as de-
scribed above and run autogen list.def. This will produce exactly the hypothesized
desired output.
One more point, too. Lets say you decided it was too much trouble to figure out how
to use AutoGen, so you created this enumeration and string list with thousands of entries.
Now, requirements have changed and it has become necessary to map a string containing
the enumeration name into the enumeration number. With AutoGen, you just alter the
template to emit the table of names. It will be guaranteed to be in the correct order, missing
none of the entries. If you want to do that by hand, well, good luck.
So far so good! Of course, now that there is a template, writing all of that tedious optargs
processing and usage functions is no longer an issue. Creating a table of the options needed
for the new project and running AutoGen generates all of the option processing code in
C automatically from just the tabular data. AutoGen in fact already ships with such a
template... AutoOpts.
One final consequence of the good separation in the design of AutoGen is that it is
retargetable to a greater extent. The egcs/gcc/fixinc/inclhack.def can equally be used (with
different templates) to create a shell script (inclhack.sh) or a c program (fixincl.c).
This is just the tip of the iceberg. AutoGen is far more powerful than these examples
might indicate, and has many other varied uses. I am certain Bruce or I could supply you
with many and varied examples, and I would heartily recommend that you try it for your
project and see for yourself how it compares to m4.
As an aside, I would be interested to see whether someone might be persuaded to ratio-
nalise autoconf with AutoGen in place of m4... Ben, are you listening? autoconf-3.0! ‘kay?
=)O|
Sincerely,
Gary V. Vaughan
Chapter 2: Definitions File 6
2 Definitions File
This chapter describes the syntax and semantics of the AutoGen definition file. In order
to instantiate a template, you normally must provide a definitions file that identifies itself
and contains some value definitions. Consequently, we keep it very simple. For "advanced"
users, there are preprocessing directives, sparse arrays, named indexes and comments that
may be used as well.
The definitions file is used to associate values with names. Every value is implicitly
an array of values, even if there is only one value. Values may be either simple strings
or compound collections of name-value pairs. An array may not contain both simple and
compound members. Fundamentally, it is as simple as:
prog-name = "autogen";
flag = {
name = templ_dirs;
value = L;
descrip = "Template search directory list";
};
For purposes of commenting and controlling the processing of the definitions, C-style
comments and most C preprocessing directives are honored. The major exception is that
the #if directive is ignored, along with all following text through the matching #endif
directive. The C preprocessor is not actually invoked, so C macro substitution is not
performed.
If AutoGen fails to find the template file in one of these places, it prints an error message
and exits.
Chapter 2: Definitions File 7
no_text_name ’;’
No_text_name is a simple definition with a shorthand empty string value. The string values
for definitions may be specified in any of several formation rules.
fumble = ’
\#endif
’;
As with the double quote string, a series of these, even intermixed with double quote strings,
will be concatenated together.
$quotes = " ’ ‘
STR_END;
STR_END;
The first string contains no new line characters. The first character is the dollar sign,
the last the back quote.
The second string contains one new line character. The first character is the tab character
preceding the dollar sign. The last character is the semicolon after the STR_END. That STR_
END does not end the string because it is not at the beginning of the line. In the preceding
case, the leading tab was stripped.
All values in a range do not have to be filled in. If you leave gaps, then you will have
a sparse array. This is fine (see Section 3.6.14 [FOR], page 55). You have your choice of
iterating over all the defined values, or iterating over a range of slots. This:
[+ FOR mumble +][+ ENDFOR +]
iterates over all and only the defined entries, whereas this:
[+ FOR mumble (for-by 1) +][+ ENDFOR +]
will iterate over all 10 "slots". Your template will likely have to contain something like this:
[+ IF (exist? (sprintf "mumble[%d]" (for-index))) +]
or else "mumble" will have to be a compound value that, say, always contains a "grumble"
value:
[+ IF (exist? "grumble") +]
executable and "run" the definitions file as if it were a direct invocation of AutoGen. This
was done for its hack value.
The ignored directives are: ‘#ident’, ‘#let’, ‘#pragma’, and ‘#if’. Note that when
ignoring the #if directive, all intervening text through its matching #endif is also ignored,
including the #else clause.
The AutoGen directives that affect the processing of definitions are:
#assert ‘shell-script‘ | (scheme-expr) | <anything else>
If the shell-script or scheme-expr do not yield true valued results, autogen
will be aborted. If <anything else> or nothing at all is provided, then this
directive is ignored.
When writing the shell script, remember this is on a preprocessing line. Multiple
lines must be backslash continued and the result is a single long line. Separate
multiple commands with semi-colons.
The result is false (and fails) if the result is empty, the number zero, or a
string that starts with the letters ’n’ or ’f’ ("no" or "false").
#define name [ <text> ]
Will add the name to the define list as if it were a DEFINE program argument.
Its value will be the first non-whitespace token following the name. Quotes are
not processed.
After the definitions file has been processed, any remaining entries in the define
list will be added to the environment.
#elif
This must follow an #if otherwise it will generate an error. It will be ignored.
#else
This must follow an #if, #ifdef or #ifndef. If it follows the #if, then it will
be ignored. Otherwise, it will change the processing state to the reverse of what
it was.
#endif
This must follow an #if, #ifdef or #ifndef. In all cases, this will resume
normal processing of text.
#endmac
This terminates a "macdef", but must not ever be encountered directly.
#endshell
Ends the text processed by a command shell into autogen definitions.
#error [ <descriptive text> ]
This directive will cause AutoGen to stop processing and exit with a status of
EXIT FAILURE.
#if [ <ignored conditional expression> ]
#if expressions are not analyzed. Everything from here to the matching #endif
is skipped.
Chapter 2: Definitions File 12
#ifdef name-to-test
The definitions that follow, up to the matching #endif will be processed only
if there is a corresponding -Dname command line option or if a #define of that
name has been previously encountered.
#ifndef name-to-test
The definitions that follow, up to the matching #endif will be processed only
if there is not a corresponding -Dname command line option or there was a
canceling -Uname option.
#include unadorned-file-name
This directive will insert definitions from another file into the current collection.
If the file name is adorned with double quotes or angle brackets (as in a C
program), then the include is ignored.
#line
Alters the current line number and/or file name. You may wish to use this
directive if you extract definition source from other files. getdefs uses this
mechanism so AutoGen will report the correct file and approximate line number
of any errors found in extracted definitions.
#macdef
This is a new AT&T research preprocessing directive. Basically, it is a multi-line
#define that may include other preprocessing directives.
#option opt-name [ <text> ]
This directive will pass the option name and associated text to the AutoOpts op-
tionLoadLine routine (see Section 7.5.32.8 [libopts-optionLoadLine], page 113).
The option text may span multiple lines by continuing them with a backslash.
The backslash/newline pair will be replaced with two space characters. This di-
rective may be used to set a search path for locating template files For example,
this:
#option templ-dirs $ENVVAR/dirname
will direct autogen to use the ENVVAR environment variable to find a direc-
tory named dirname that (may) contain templates. Since these directories are
searched in most recently supplied first order, search directories supplied in this
way will be searched before any supplied on the command line.
#shell
Invokes $SHELL or ‘/bin/sh’ on a script that should generate AutoGen defini-
tions. It does this using the same server process that handles the back-quoted
‘ text. CAUTION let not your $SHELL be csh.
#undef name-to-undefine
Will remove any entries from the define list that match the undef name pattern.
and in shell scripts with environment variable tests. __autogen__ is always defined. For
other names, AutoGen will first try to use the POSIX version of the sysinfo(2) system
call. Failing that, it will try for the POSIX uname(2) call. If neither is available, then only
"__autogen__" will be inserted into the environment. In all cases, the associated names
are converted to lower case, surrounded by doubled underscores and non-symbol characters
are replaced with underscores.
With Solaris on a sparc platform, sysinfo(2) is available. The following strings are
used:
• SI_SYSNAME (e.g., " sunos ")
• SI_HOSTNAME (e.g., " ellen ")
• SI_ARCHITECTURE (e.g., " sparc ")
• SI_HW_PROVIDER (e.g., " sun microsystems ")
• SI_PLATFORM (e.g., " sun ultra 5 10 ")
• SI_MACHINE (e.g., " sun4u ")
For Linux and other operating systems that only support the uname(2) call, AutoGen
will use these values:
• sysname (e.g., " linux ")
• machine (e.g., " i586 ")
• nodename (e.g., " bach ")
By testing these pre-defines in my definitions, you can select pieces of the definitions
without resorting to writing shell scripts that parse the output of uname(1). You can also
segregate real C code from autogen definitions by testing for "__autogen__".
#ifdef __bach__
location = home;
#else
location = work;
#endif
*/
global = "value for a global text definition.";
/*
* Include a standard set of definitions
*/
#include standards.def
a_block = {
a_field;
a_subblock = {
sub_name = first;
sub_field = "sub value.";
};
#ifdef FEATURE
a_subblock = {
sub_name = second;
};
#endif
};
/* STATE 0: DP_ST_INIT */
{ { DP_ST_NEED_DEF, NULL }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: End-Of-File */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: var_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: other_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: here_string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: number */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: ; */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: = */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: , */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: { */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: } */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: [ */
Chapter 2: Definitions File 15
/* STATE 1: DP_ST_NEED_DEF */
{ { DP_ST_INVALID, dp_do_invalid }, /* EVT: autogen */
{ DP_ST_NEED_TPL, NULL }, /* EVT: definitions */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: End-Of-File */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: var_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: other_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: here_string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: number */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: ; */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: = */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: , */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: { */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: } */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: [ */
{ DP_ST_INVALID, dp_do_invalid } /* EVT: ] */
/* STATE 2: DP_ST_NEED_TPL */
{ { DP_ST_INVALID, dp_do_invalid }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: End-Of-File */
{ DP_ST_NEED_SEMI, dp_do_tpl_name }, /* EVT: var_name */
{ DP_ST_NEED_SEMI, dp_do_tpl_name }, /* EVT: other_name */
{ DP_ST_NEED_SEMI, dp_do_tpl_name }, /* EVT: string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: here_string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: number */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: ; */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: = */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: , */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: { */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: } */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: [ */
{ DP_ST_INVALID, dp_do_invalid } /* EVT: ] */
/* STATE 3: DP_ST_NEED_SEMI */
{ { DP_ST_INVALID, dp_do_invalid }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: End-Of-File */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: var_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: other_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: here_string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: number */
{ DP_ST_NEED_NAME, NULL }, /* EVT: ; */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: = */
Chapter 2: Definitions File 16
/* STATE 4: DP_ST_NEED_NAME */
{ { DP_ST_NEED_DEF, NULL }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
{ DP_ST_DONE, dp_do_need_name_end }, /* EVT: End-Of-File */
{ DP_ST_HAVE_NAME, dp_do_need_name_var_name }, /* EVT: var_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: other_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: here_string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: number */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: ; */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: = */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: , */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: { */
{ DP_ST_HAVE_VALUE, dp_do_end_block }, /* EVT: } */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: [ */
{ DP_ST_INVALID, dp_do_invalid } /* EVT: ] */
/* STATE 5: DP_ST_HAVE_NAME */
{ { DP_ST_INVALID, dp_do_invalid }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: End-Of-File */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: var_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: other_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: here_string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: number */
{ DP_ST_NEED_NAME, dp_do_empty_val }, /* EVT: ; */
{ DP_ST_NEED_VALUE, dp_do_have_name_lit_eq }, /* EVT: = */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: , */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: { */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: } */
{ DP_ST_NEED_IDX, NULL }, /* EVT: [ */
{ DP_ST_INVALID, dp_do_invalid } /* EVT: ] */
/* STATE 6: DP_ST_NEED_VALUE */
{ { DP_ST_INVALID, dp_do_invalid }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: End-Of-File */
{ DP_ST_HAVE_VALUE, dp_do_str_value }, /* EVT: var_name */
{ DP_ST_HAVE_VALUE, dp_do_str_value }, /* EVT: other_name */
{ DP_ST_HAVE_VALUE, dp_do_str_value }, /* EVT: string */
Chapter 2: Definitions File 17
/* STATE 7: DP_ST_NEED_IDX */
{ { DP_ST_INVALID, dp_do_invalid }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: End-Of-File */
{ DP_ST_NEED_CBKT, dp_do_indexed_name }, /* EVT: var_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: other_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: here_string */
{ DP_ST_NEED_CBKT, dp_do_indexed_name }, /* EVT: number */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: ; */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: = */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: , */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: { */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: } */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: [ */
{ DP_ST_INVALID, dp_do_invalid } /* EVT: ] */
/* STATE 8: DP_ST_NEED_CBKT */
{ { DP_ST_INVALID, dp_do_invalid }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: End-Of-File */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: var_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: other_name */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: here_string */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: number */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: ; */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: = */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: , */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: { */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: } */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: [ */
{ DP_ST_INDX_NAME, NULL } /* EVT: ] */
/* STATE 9: DP_ST_INDX_NAME */
{ { DP_ST_INVALID, dp_do_invalid }, /* EVT: autogen */
{ DP_ST_INVALID, dp_do_invalid }, /* EVT: definitions */
Chapter 2: Definitions File 18
‘no definitions’
It is entirely possible to write a template that does not depend upon external
definitions. Such a template would likely have an unvarying output, but be
convenient nonetheless because of an external library of either AutoGen or
Scheme functions, or both. This can be accommodated by providing the -
-override-tpl and --no-definitions options on the command line. See
Chapter 5 [autogen Invocation], page 61.
‘CGI’ AutoGen behaves as a CGI server if the definitions input is from stdin and the
environment variable REQUEST_METHOD is defined and set to either "GET" or
"POST", See Section 6.2 [AutoGen CGI], page 70. Obviously, all the values
are constrained to strings because there is no way to represent nested values.
Chapter 2: Definitions File 19
‘XML’ AutoGen comes with a program named, xml2ag. Its output can either be
redirected to a file for later use, or the program can be used as an AutoGen
wrapper. See Section 8.6 [xml2ag Invocation], page 166.
The introductory template example (see Section 1.2 [Example Usage], page 2)
can be rewritten in XML as follows:
<EXAMPLE template="list.tpl">
<LIST list_element="alpha"
list_info="some alpha stuff"/>
<LIST list_info="more beta stuff"
list_element="beta"/>
<LIST list_element="omega"
list_info="final omega stuff"/>
</EXAMPLE>
A more XML-normal form might look like this:
<EXAMPLE template="list.tpl">
<LIST list_element="alpha">some alpha stuff</LIST>
<LIST list_element="beta" >more beta stuff</LIST>
<LIST list_element="omega">final omega stuff</LIST>
</EXAMPLE>
but you would have to change the template list_info references into text
references.
‘standard AutoGen definitions’
Of course. :-)
Chapter 3: Template File 20
3 Template File
The AutoGen template file defines the content of the output text. It is composed of two
parts. The first part consists of a pseudo macro invocation and commentary. It is followed
by the template proper.
This pseudo macro is special. It is used to identify the file as a AutoGen template
file, fixing the starting and ending marks for the macro invocations in the rest of the file,
specifying the list of suffixes to be generated by the template and, optionally, the shell to
use for processing shell commands embedded in the template.
AutoGen-ing a file consists of copying text from the template to the output file until a
start macro marker is found. The text from the start marker to the end marker constitutes
the macro text. AutoGen macros may cause sections of the template to be skipped or
processed several times. The process continues until the end of the template is reached.
The process is repeated once for each suffix specified in the pseudo macro.
This chapter describes the format of the AutoGen template macros and the usage of
the AutoGen native macros. Users may augment these by defining their own macros, See
Section 3.6.5 [DEFINE], page 53.
If the suffix begins with one of these three latter characters and a formatting string is
not specified, then that character is presumed to be the suffix separator. Otherwise,
without a specified format string, a single period will separate the suffix from the base
name in constructing the output file name.
4. Comments: blank lines, lines starting with a hash mark [#]), and edit mode comments
(text between pairs of -*- strings).
5. Some scheme expressions may be inserted in order to make configuration changes before
template processing begins. “before template processing begins” means that there
is no current output file, no current suffix and, basically, none of the AutoGen specific
functions (see Section 3.4 [AutoGen Functions], page 25) may be invoked.
It is used, for example, to allow the template writer to specify the shell program that
must be used to interpret the shell commands in the template. It can have no effect
on any shell commands in the definitions file, as that file will have been processed by
the time the pseudo macro is interpreted.
(setenv "SHELL" "/bin/sh")
This is extremely useful to ensure that the shell used is the one the template was
written to use. By default, AutoGen determines the shell to use by user preferences.
Sometimes, that can be the "csh", though.
The scheme expression can also be used to save a pre-existing output file for later text
extraction (see Section 3.5.8 [SCM extract], page 36).
(shellf "mv -f %1$s.c %1$s.sav" (base-name))
The ending macro marker has a few constraints on its content. Some of them are just
advisory, though. There is no special check for advisory restrictions.
• It must not begin with a POSIX file name character (hyphen -, underscore _ or period
.), the backslash (\) or open parenthesis ((). These are used to identify a suffix
specification, indicate Scheme code and trim white space.
• If it begins with an equal sign, then it must be separated from any suffix specification
by white space.
• The closing marker may not begin with an open parenthesis, as that is used to enclose
a scheme expression.
• It cannot begin with a backslash, as that is used to indicate white space trimming after
the end macro mark. If, in the body of the template, you put the backslash character
(\) before the end macro mark, then any white space characters after the mark and
through the newline character are trimmed.
• It is also helpful to avoid using the comment marker (#). It might be seen as a comment
within the pseudo macro.
• You should avoid using any of the quote characters double, single or back-quote. It
won’t confuse AutoGen, but it might well confuse you and/or your editor.
Chapter 3: Template File 22
As an example, assume we want to use [+ and +] as the start and end macro markers,
and we wish to produce a ‘.c’ and a ‘.h’ file, then the pseudo macro might look something
like this:
[+ AutoGen5 template -*- Mode: emacs-mode-of-choice -*-
h=chk-%s.h
c
# make sure we don’t use csh:
(setenv "SHELL" "/bin/sh") +]
The template proper starts after the pseudo-macro. The starting character is either the
first non-whitespace character or the first character after the newline that follows the end
macro marker.
Arguments:
message - message to display before exiting
value (if the name resolves), the alternate value (if one is provided), or else the empty string.
The result is passed through "string->c-name!" and "string->down-case!".
Arguments:
ag-name - name of AutoGen value
Arguments:
ag-name - name of AutoGen value
open file. It is an error if there has not been a push. See Section 3.7 [output controls],
page 57.
If there is no argument, no further action is taken. Otherwise, the argument should be
#t and the contents of the file are returned by the function.
Arguments:
disp - Optional - return contents of the file
This is equivalent to out-pop followed by out-push-new, except that you may not pop the
base level output file, but you may switch it. See Section 3.7 [output controls], page 57.
Arguments:
file-name - name of the file to create
but that is also already supplied with the scheme variable See Section 3.4.46 [SCM c-file-
line-fmt], page 34. You may use it thus:
(tpl-file-line c-file-line-fmt)
It is also safe to use the formatting string, "%2$d". AutoGen uses an argument vector
version of printf: See Section 8.7 [snprintfv], page 171.
Arguments:
msg-fmt - Optional - formatting for line message
/*=fumble bumble
* fmt: ’stumble %s: %d\n’
=*/
You may wish to generate a macro:
Arguments:
port - Guile-scheme output port
format - formatting string
format-arg - Optional - list of arguments to formatting string
Arguments:
prog-name - name of the program under the GPL
prefix - String for starting each output line
two
lines
The result string will contain:
# two
# lines
Arguments:
prefix - string to insert at start of each line
text - multi-line block of text
WARNING:
This function omits the extra backslash in front of a backslash, however, if it is followed by
either a backquote or a dollar sign. It must do this because otherwise it would be impossible
to protect the dollar sign or backquote from shell evaluation. Consequently, it is not possible
to render the strings "\\$" or "\\‘". The lesser of two evils.
All others characters are copied directly into the output.
The sub-shell-str variation of this routine behaves identically, except that the extra
backslash is omitted in front of " instead of ‘. You have to think about it. I’m open to
suggestions.
Meanwhile, the best way to document is with a detailed output example. If the back-
slashes make it through the text processing correctly, below you will see what happens
with three example strings. The first example string contains a list of quoted foos, the
second is the same with a single backslash before the quote characters and the last is with
two backslash escapes. Below each is the result of the raw-shell-str, shell-str and
sub-shell-str functions.
foo[0] ’’foo’’ ’foo’ "foo" ‘foo‘ $foo
raw-shell-str -> \’\’’foo’\’\’’ ’\’’foo’\’’ "foo" ‘foo‘ $foo’
shell-str -> "’’foo’’ ’foo’ \"foo\" ‘foo‘ $foo"
sub-shell-str -> ‘’’foo’’ ’foo’ "foo" \‘foo\‘ $foo‘
Arguments:
text - text to test for pattern
match - pattern/substring to search for
that will yield the address of the first byte of the inserted string. See the ‘strtable.test’
AutoGen test for a usage example.
Arguments:
st-name - the name of the array of characters
str-val - the (possibly) new value to add
loop is done, the current output is suspended under the name, “main” and the “scribble”
table is then emitted into the primary output. (emit-string-table inserts its output
directly into the current output stream. It does not need to be the last function in an
AutoGen macro block.) Next I ag-fprintf the array-of-pointer declaration directly into
the current output. Finally I restore the “main” output stream and (out-pop #t)-it into
the main output stream.
Here is the result. Note that duplicate strings are not repeated in the string table:
static char const scribble[18] =
"that\0" "was\0" "the\0" "week\0";
5. Do you need a default match when none of the others match? Use a single asterisk (*).
6. Do you need to distinguish between an empty string value and a value that was not
found? Use the non-existence test (!E) before testing a full match against an empty
string (== ’’). There is also an existence test (+E), more for symmetry than for practical
use.
For example:
[+ CASE <full-expression> +]
[+ ~~* "[Tt]est" +]reg exp must match at start, not at end
[+ == "TeSt" +]a full-string, case sensitive compare
[+ = "TEST" +]a full-string, case insensitive compare
[+ !E +]not exists - matches if no AutoGen value found
[+ == "" +]expression yielded a zero-length string
[+ +E +]exists - matches if there is any value result
[+ * +]always match - no testing
[+ ESAC +]
<full-expression> (see Section 3.3 [expression syntax], page 22) may be any expres-
sion, including the use of apply-codes and value-names. If the expression yields a number,
it is converted to a decimal string.
These case selection codes have also been implemented as Scheme expression functions
using the same codes. They are documented in this texi doc as “string-*?” predicates (see
Section 3.5 [Common Functions], page 35).
for detecting missing definitions and emitting default text. In this fashion, you can insert
entries from a sparse or non-zero based array into a dense, zero based array.
NB: the for-from, for-to, for-by and for-sep functions are disabled outside of the
context of the FOR macro. Likewise, the first-for, last-for and for-index functions
are disabled outside of the range of a FOR block.
Also: the <value-name> must be a single level name, not a compound name (see
Section 3.2 [naming values], page 22).
[+FOR var (for-from 0) (for-to <number>) (for-sep ",") +]
... text with various substitutions ...[+
ENDFOR var+]
this will repeat the ... text with various substitutions ... <number>+1 times. Each
repetition, except for the last, will have a comma , after it.
[+FOR var ",\n" +]
... text with various substitutions ...[+
ENDFOR var +]
This will do the same thing, but only for the index values of var that have actually been
defined.
ELIF <full-expression-2> +]
emit things that are true maybe[+
ENDWHILE +]
<full-expression> may be any expression described in the EXPR expression function, in-
cluding the use of apply-codes and value-names. If the expression yields an empty string,
it is interpreted as false.
not supply a name, then the text is written to a scratch pad and retrieved by
passing a “#t” argument to the out-pop (see Section 3.4.33 [SCM out-pop],
page 31) function.
‘out-pop (see Section 3.4.33 [SCM out-pop], page 31)’
This function closes the current output file and resumes output to the next
one in the stack. At least one output must have been pushed onto the output
stack with the out-push-new (see Section 3.4.35 [SCM out-push-new], page 32)
function. If “#t” is passed in as an argument, then the entire contents of the
diversion (or file) is returned.
‘out-suspend (see Section 3.4.37 [SCM out-suspend], page 32)’
This function does not close the current output, but instead sets it aside for
resumption by the given name with out-resume. The current output must have
been pushed on the output queue with out-push-new (see Section 3.4.35 [SCM
out-push-new], page 32).
‘out-resume (see Section 3.4.36 [SCM out-resume], page 32)’
This will put a named file descriptor back onto the top of stack so that it
becomes the current output again.
‘out-switch (see Section 3.4.38 [SCM out-switch], page 32)’
This closes the current output and creates a new file, purging any preexisting
one. This is a shortcut for "pop" followed by "push", but this can also be done
at the base level.
‘out-move (see Section 3.4.31 [SCM out-move], page 31)’
Renames the current output file without closing it.
There are also several functions for determining the output status. See Section 3.4
[AutoGen Functions], page 25.
Chapter 4: Augmenting AutoGen Features 59
* this function.
=*/
SCM
ag_scm_<function-name>( SCM arg_name[, ...] )
{ <code> }
‘gfunc’ You must have this exactly thus.
‘<function-name>’
This must follow C syntax for variable names
‘<short one-liner>’
This should be about a half a line long. It is used as a subsection title in this
document.
‘general_use:’
You must supply this unless you are an AutoGen maintainer and are writing a
function that queries or modifies the state of AutoGen.
‘<invocation-name-string>’
Normally, the function-name string will be transformed into a reasonable in-
vocation name. However, that is not always true. If the result does not suit
your needs, then supply an alternate string.
‘exparg:’ You must supply one for each argument to your function. All optional argu-
ments must be last. The last of the optional arguments may be a list, if you
choose.
‘doc:’ Please say something meaningful.
‘[, ...]’ Do not actually specify an ANSI ellipsis here. You must provide for all the
arguments you specified with exparg.
See the Guile documentation for more details. More information is also available in a
large comment at the beginning of the ‘agen5/snarf.tpl’ template file.
5 Invoking autogen
AutoGen creates text files from templates using external definitions. The definitions file
(‘<def-file>’) can be specified with the ‘definitions’ option or as the command argument,
but not both. Omitting it or specifying ‘-’ will result in reading definitions from standard
input.
The output file names are based on the template, but generally use the base name of
the definition file. If standard in is read for the definitions, then ‘stdin’ will be used for
that base name. The suffixes to the base name are gotten from the template. However,
the template file may specify the entire output file name. The generated files are always
created in the current directory. If you need to place output in an alternate directory, ‘cd’
to that directory and use the ‘–templ dirs’ option to search the original directory.
‘loop-limit’ is used in debugging to stop runaway expansions.
This chapter was generated by AutoGen, the aginfo template and the option descriptions
for the autogen program. It documents the autogen usage text and option meanings.
This software is released under the GNU General Public License.
The following options are often useful while debugging new templates:
The output file names are based on the template, but generally use the
base name of the definition file. If standard in is read for the
definitions, then ‘stdin’ will be used for that base name. The
suffixes to the base name are gotten from the template. However, the
template file may specify the entire output file name. The generated
files are always created in the current directory. If you need to
place output in an alternate directory, ‘cd’ to that directory and use
the ‘--templ_dirs’ option to search the original directory.
can be generated by using the following command and the ‘snarf.tpl’ template. Read the
introductory comment in ‘snarf.tpl’ to see what the ‘getdefs(1AG)’ comment must contain.
First, create a config file for getdefs, and then invoke getdefs loading that file:
cat > getdefs.cfg <<EOF
subblock exparg=arg_name,arg_desc,arg_optional,arg_list
defs-to-get gfunc
template snarf
srcfile
linenum
assign group = name_of_some_group
assign init = _init
EOF
cd ${top_builddir}/agen5
DEBUG_ENABLED=true bash bootstrap.dir expr.ini
make CFLAGS=’-g -DDEBUG_ENABLED=1’
Be aware tha tyou cannot rebuild this source in this way without first having
installed the autogen executable in your search path. Because of this, "expr.ini"
is in the distributed source list, and not in the dependencies.
ELSE ?><?
form-error ?><?
ENDIF ?>
This forces the template to be found in the "cgi-tpl/" directory. Note also that there is
no suffix specified in the pseudo macro (see Section 3.1 [pseudo macro], page 20). That tells
AutoGen to emit the output to ‘stdout’.
The output is actually spooled until it is complete so that, in the case of an error, the
output can be discarded and a proper error message can be written in its stead.
Please also note that it is advisable, especially for network accessible machines, to con-
figure AutoGen (see Section 6.1 [configuring], page 69) with shell processing disabled (--
disable-shell). That will make it impossible for any referenced template to hand data to
a subshell for interpretation.
is unlikely to match what your system uses. This can be fixed. Once you have installed
autogen, the mapping can be rebuilt on the host operating system. To do so, you must
perform the following steps:
1. Build and install AutoGen in a place where it will be found in your search path.
2. cd ${top_srcdir}/compat
3. autogen strsignal.def
4. Verify the results by examining the ‘strsignal.h’ file produced.
5. Re-build and re-install AutoGen.
If you have any problems or peculiarities that cause this process to fail on your platform,
please send me copies of the header files containing the signal names and numbers, along
with the full path names of these files. I will endeavor to fix it. There is a shell script inside
of ‘strsignal.def’ that tries to hunt down the information.
failures, you will need to invoke the test scripts individually. You may do so by specifying
the test (or list of test) in the TESTS make variable, thus:
gmake TESTS=test-name.test check
I specify gmake because most makes will not let you override internal definitions with
command line arguments. gmake does.
All of the AutoGen tests are written to honor the contents of the VERBOSE environment
variable. Normally, any commentary generated during a test run is discarded unless the
VERBOSE environment variable is set. So, to see what is happening during the test, you
might invoke the following with bash or ksh:
VERBOSE=1 gmake TESTS="for.test forcomma.test" check
Or equivalently with csh:
env VERBOSE=1 gmake TESTS="for.test forcomma.test" check
Chapter 7: Automated Option Processing 73
‘--usage’ This is added to the option list if “usage-opt” is specified. It yields the
abbreviated usage to ‘stdout’.
‘--version’
This is added to the option list if “version = xxx;” is specified.
‘--load-opts’
‘--save-opts’
These are added to the option list if “homerc” is specified.
9. Various forms of main procedures can be added to the output, See Section 7.4.3 [Gen-
erated main], page 82. There are four basic forms:
a. A program that processes the arguments and writes to standard out portable shell
commands containing the digested options.
b. A program that will generate portable shell commands to parse the defined options.
The expectation is that this result will be copied into a shell script and used there.
c. A “for-each” main that will invoke a named function once for either each non-
option argument on the command line or, if there are none, then once for each
non-blank, non-comment input line read from stdin.
d. A main procedure of your own design. Its code can be supplied in the option
description template or by incorporating another template.
10. There are several methods for handling option arguments.
• nothing (see Section 7.5.13 [OPT ARG], page 104) option argument strings are
globally available.
• user supplied (see Section 7.4.7 [Option Argument Handling], page 95)
• stack option arguments (see Section 7.4.7 [Option Argument Handling], page 95)
• integer numbers (see Section 7.4.6.5 [arg-type number], page 93)
• true or false valued (see Section 7.4.6.6 [arg-type boolean], page 94)
• enumerated list of names (see Section 7.4.6.7 [arg-type keyword], page 94)
• an enumeration (membership) set (see Section 7.4.6.8 [arg-type set membership],
page 94)
• a list of name/value pairs (option “subopts”) (see Section 7.4.6.9 [arg-type hierar-
chy], page 95)
• validated file name (see Section 7.4.6.10 [arg-type file name], page 95)
• optional option argument (see Section 7.4.6.2 [arg-optional], page 93)
11. The generated usage text can be emitted in either AutoOpts standard format (max-
imizing the information about each option), or GNU-ish normal form. The default
form is selected by either specifying or not specifying the gnu-usage attribute (see
Section 7.4.4 [information attributes], page 86). This can be overridden by the user
himself with the AUTOOPTS_USAGE environment variable. If it exists and is set to the
string gnu, it will force GNU-ish style format; if it is set to the string autoopts, it will
force AutoOpts standard format; otherwise, it will have no effect.
12. If you compile with ENABLE_NLS defined and _() defined to a localization function such
as gettext(3GNU), then the option processing code will be localizable (see Section 7.15
[i18n], page 153).
Chapter 7: Automated Option Processing 75
13. Provides a callable routine to parse a text string as if it were from one of the
rc/ini/config files, hereafter referred to as a configuration file.
14. By adding a ‘doc’ and ‘arg-name’ attributes to each option, AutoGen will also be able
to produce a man page and the ‘invoking’ section of a texinfo document.
15. Intermingled option processing. AutoOpts options may be intermingled with
command line operands and options processed with other parsing techniques. This
is accomplished by setting the allow-errors (see Section 7.4.1 [program attributes],
page 78) attribute. When processing reaches a point where optionProcess (see
Section 7.5.32.11 [libopts-optionProcess], page 114) needs to be called again, the
current option can be set with RESTART_OPT(n) (see Section 7.5.19 [RESTART OPT],
page 105) before calling optionProcess.
See: See Section 7.4.2 [library attributes], page 80.
16. Library suppliers can specify command line options that their client programs will
accept. They specify option definitions that get #include-d into the client option
definitions and they specify an "anchor" option that has a callback and must be invoked.
That will give the library access to the option state for their options.
17. library options. An AutoOpt-ed library may export its options for use in an AutoOpt-
ed program. This is done by providing an option definition file that client programs
#include into their own option definitions. See “AutoOpt-ed Library for AutoOpt-ed
Program” (see Section 7.4.2.1 [lib and program], page 81) for more details.
18. Insert the option processing state into Scheme-defined variables. Thus, Guile based
applications that are linked with private main() routines can take advantage of all of
AutoOpts’ functionality.
flag = {
name = check-dirs;
value = L; /* flag style option character */
arg-type = string; /* option argument indication */
max = NOLIMIT; /* occurrence limit (none) */
stack-arg; /* save opt args in a stack */
descrip = "Checkout directory list";
};
flag = {
name = show_defs;
descrip = "Show the definition tree";
disable = dont; /* mark as enable/disable type */
/* option. Disable as ‘dont-’ */
};
Then perform the following steps:
1. cflags="-DTEST_CHECK_OPTS ‘autoopts-config cflags‘"
2. ldflags="‘autoopts-config ldflags‘"
3. autogen checkopt.def
4. cc -o check -g ${cflags} checkopt.c ${ldflags}
5. ./check --help
Running those commands yields:
Chapter 7: Automated Option Processing 77
1. prog-name, prog-title, and argument, program attributes, See Section 7.4.1 [program
attributes], page 78.
2. name and descrip option attributes, See Section 7.4.5.1 [Required Attributes], page 88.
3. value (flag character) and min (occurrence counts) option attributes, See
Section 7.4.5.2 [Common Attributes], page 88.
4. arg-type from the option argument specification section, See Section 7.4.6 [Option
Arguments], page 92.
5. Read the overall how to, See Section 7.8 [Using AutoOpts], page 120.
6. Highly recommended, but not required, are the several "man" and "info" documenta-
tion attributes, See Section 7.4.9 [documentation attributes], page 97.
Keep in mind that the majority are rarely used and can be safely ignored. However,
when you have special option processing requirements, the flexibility is there.
‘export’ This string is inserted into the .h interface file. Generally used for global vari-
ables or #include directives required by flag-code text and shared with other
program text. Do not specify your configuration header (‘config.h’) in this
attribute or the include attribute, however. Instead, use config-header,
above.n.
‘full-usage’
If this attribute is provided, it may specify the full length usage text, or a
variable name assignable to a “char const *” pointer, or it may be empty. The
meanings are determined by the length.
• If not provided, the text will be computed as normal.
• If the length is zero, then the usage text will be derived from the current
settings and inserted as text into the generated .c file.
• If the length is 1 to 32 bytes, then it is presumed to be a variable name
that either points to or is an array of const chars.
• If it is longer than that, it is presumed to be the help text itself. This text
will be inserted into the generated .c file.
This string should be readily translatable and provision will be made to trans-
late it if this is provided and the source code is compiled with “ENABLE NLS”
defined.
‘guard-option-names’
AutoOpts generates macros that presume that there are no cpp macros with
the same name as the option name. For example, if you have an option named,
debug, then you must not use #ifdef DEBUG in your code. If you specify this
attribute, every option name will be guarded. If the name is #define-d, then a
warning will be issued and the name undefined. If you do not specify this and
there is a conflict, you will get strange error messages.
This attribute may be set to any of four recognized states:
• Not defined. AutoOpts will behave as described above.
• Defined, but set to the empty string. Text will be emitted into the header
to undefine (#undef) any conflicting preprocessor macros. The code will
include compiler warnings (via #warning). Some compilers are not ANSI-
C-99 compliant yet and will error out on those warnings. You may compile
with -DNO_OPTION_NAME_WARNINGS to silence or mostly silence them.
• Defined and set to the string, “no-warning”. All of the needed #undefs
will be emitted, without any conflict checking #warning directives emitted.
• Defined and set to the string, “full-enum”. The option manipulation
preprocessor macros will not token paste the option names to the index
enumeration prefix. e.g. you will need to use HAVE_OPT(INDEX_OPT_DEBUG)
instead of HAVE_OPT(DEBUG).
‘homerc’ Specifies either a directory or a file using a specific path (like . or
‘/usr/local/share/progname’) or an environment variable (like ‘$HOME/rc/’
or ‘$PREFIX/share/progname’) or the directory where the executable was
found (‘$$[/...]’) to use to try to find the rcfile. Use as many as you like.
Chapter 7: Automated Option Processing 80
In this method, do NOT utilize the global library attribute. Your library must specify
its options as if it were a complete program. You may choose to specify an alternate usage()
function so that usage for other parts of the option interface may be displayed as well. See
“Program Information Attributes” (see Section 7.4.4 [information attributes], page 86).
At the moment, there is no method for calling optionUsage() telling it to produce just
the information about the options and not the program as a whole. Some later revision
after somebody asks.
unset OPTION_CT
eval "‘opt_parser \"$@\"‘"
test -z "${OPTION_CT}" && exit 1
test ${OPTION_CT} -gt 0 && shift ${OPTION_CT}
If the option parsing code detects an error or a request for usage, it will not emit
an assignment to OPTION CT and the script should just exit. If the options are set
consistently, then something along the lines of the following will be written to ‘stdout’ and
evaled:
OPTION_CT=4
export OPTION_CT
MYPROG_SECOND=’first’
export MYPROG_SECOND
MYPROG_ANOTHER=1 # 0x1
export MYPROG_ANOTHER
If the arguments are to be reordered, however, then the resulting set of operands will be
emitted and OPTION_CT gets set to zero. For example, the following would be appended to
the above:
set -- ’operand1’ ’operand2’ ’operand3’
OPTION_CT=0
OPTION_CT is set to zero since it is not necessary to shift off any options.
int res = 0;
if (argc > 0) {
do {
res |= my_handler ( *(argv++) );
} while (--argc > 0);
} else { ...
handler-type
If you do not supply this attribute, your handler procedure must be the default
type. The profile of the procedure must be:
int my_handler ( char const *pz_entry );
However, if you do supply this attribute, you may select any of three alternate
flavors:
‘name-of-file’
This is essentially the same as the default handler type, except that
before your procedure is invoked, the generated code has verified
that the string names an existing file. The profile is unchanged.
‘file-X’ Before calling your procedure, the file is f-opened according to the
“X”, where “X” may be any of the legal modes for fopen(3C). In
this case, the profile for your procedure must be:
int my_handler ( char const* pz_fname, FILE* entry_fp );
‘text-of-file’
‘some-text-of-file’
Before calling your procedure, the contents of the file are read
into memory. (Excessively large files may cause problems.) The
“‘some-text-of-file’” disallows empty files. Both require regu-
lar files. In this case, the profile for your procedure must be:
int my_handler ( char const* pz_fname, char* file_text,
size_t text_size );
Note that though the file_text is not const, any changes made
to it are not written back to the original file. It is merely a memory
image of the file contents. Also, the memory allocated to hold the
text is text_size + 1 bytes long and the final byte is always NUL.
The file contents need not be text, as the data are read with the
read(2) system call.
my_handler-code
With this attribute, you provide the code for your handler procedure in the
option definition file. In this case, your main() procedure specification might
look something like this:
main = {
main-type = for-each;
handler-proc = my_handler ;
my_handler-code = <<- EndOfMyCode
/* whatever you want to do */
Chapter 7: Automated Option Processing 86
EndOfMyCode;
};
and instead of an emitted external reference, a procedure will be emitted that
looks like this:
static int
my_handler ( char const* pz_entry )
{
int res = 0;
<<my_handler-code goes here>>
return res;
}
main-init
This is code that gets inserted after the options have been processed, but before
the handler procs get invoked.
main-fini
This is code that gets inserted after all the entries have been processed, just
before returning from main().
comment-char
If you wish comment lines to start with a character other than a hash (#)
character, then specify one character with this attribute. If that character is
the NUL byte, then only blank lines will be considered comments.
copyright = {
date = "1992-2004";
owner = "Bruce Korb";
eaddr = ’bkorb@gnu.org’;
type = GPL;
};
‘detail’ This string is added to the usage output when the HELP option is selected.
‘explain’ Gives additional information whenever the usage routine is invoked..
‘package’ The name of the package the program belongs to. This will appear parenthet-
ically after the program name in the version and usage output, e.g.: autogen
(GNU autogen) - The Automated Program Generator.
‘preserve-case’
This attribute will not change anything except appearance. Normally, the op-
tion names are all documented in lower case. However, if you specify this at-
tribute, then they will display in the case used in their specification. Command
line options will still be matched without case sensitivity.
‘prog-desc and’
‘opts-ptr’
These define global pointer variables that point to the program descriptor and
the first option descriptor for a library option. This is intended for use by certain
libraries that need command line and/or initialization file option processing.
These definitions have no effect on the option template output, but are used for
creating a library interface file. Normally, the first "option" for a library will
be a documentation option that cannot be specified on the command line, but
is marked as settable. The library client program will invoke the SET_OPTION
macro which will invoke a handler function that will finally set these global
variables.
‘usage’ Optionally names the usage procedure, if the library routine optionUsage()
does not work for you. If you specify my_usage as the value of this attribute,
for example, you will use a procedure by that name for displaying usage. Of
course, you will need to provide that procedure and it must conform to this
profile:
void my_usage ( tOptions* pOptions, int exitCode )
‘gnu-usage’
Normally, the default format produced by the optionUsage procedure is Au-
toOpts Standard. By specifying this attribute, the default format will be GNU-
ish style. Either default may be overridden by the user with the AUTOOPTS_
USAGE environment variable. If it is set to gnu or autoopts, it will alter the
style appropriately. This attribute will conflict with the usage attribute.
‘reorder-args’
Some applications traditionally require that the command operands be inter-
mixed with the command options. In order to handle that, the arguments must
be reordered. If you are writing such an application, specify this global option.
Chapter 7: Automated Option Processing 88
All of the options (and any associated option arguments) will be brought to the
beginning of the argument list. New applications should not use this feature,
if at all possible. This feature is disabled if POSIXLY_CORRECT is defined in the
environment.
‘name’ Long name for the option. Even if you are not accepting long options and are
only accepting flags, it must be provided. AutoOpts generates private, named
storage that requires this name. This name also causes a #define-d name to
be emitted. It must not conflict with any other names you may be using in
your program.
For example, if your option name is, debug or munged-up, you must not use
the #define names DEBUG (or MUNGED_UP) in your program for non-AutoOpts
related purposes. They are now used by AutoOpts.
Sometimes (most especially under Windows), you may get a surprise. For
example, INTERFACE is apparently a user space name that one should be free
to use. Windows usurps this name. To solve this, you must do one of the
following:
1. Change the name of your option
2. add the program attribute (see Section 7.4.1 [program attributes], page 78):
export = ’#undef INTERFACE’;
3. add the program attribute:
guard-option-names;
‘descrip’ Except for documentation options, a very brief description of the option. About
40 characters on one line, maximum. It appears on the usage() output next
to the option name. If, however, the option is a documentation option, it will
appear on one or more lines by itself. It is thus used to visually separate and
comment upon groups of options in the usage text.
‘value’ The flag character to specify for traditional option flags, e.g., -L.
Chapter 7: Automated Option Processing 89
‘max’ Maximum occurrence count (invalid if disable present). The default maximum
is 1. NOLIMIT can be used for the value, otherwise it must be a number or a
#define that evaluates to a number.
‘min’ Minimum occurrence count. If present, then the option must appear on the
command line. Do not define it with the value zero (0).
‘must-set’
If an option must be specified, but it need not be specified on the command
line, then specify this attribute for the option.
‘enable’ Long-name prefix for enabling the option (invalid if disable not present). Only
useful if long option names are being processed.
‘disable’ Prefix for disabling (inverting sense of) the option. Only useful if long option
names are being processed.
‘enabled’ If default is for option being enabled. (Otherwise, the OPTST DISABLED bit
is set at compile time.) Only useful if the option can be disabled.
‘ifdef’
‘ifndef’ If an option is relevant on certain platforms or when certain features are enabled
or disabled, you can specify the compile time flag used to indicate when the
option should be compiled in or out. For example, if you have a configurable
feature, mumble that is indicated with the compile time define, WITH_MUMBLING,
then add:
ifdef = WITH_MUMBLING;
Take care when using these. There are several caveats:
• The case and spelling must match whatever is specified.
• Do not confuse these attributes with the AutoGen directives of the same
names, See Section 2.5 [Directives], page 10. These cause C preprocessing
directives to be inserted into the generated C text.
• Only one of these attributes may apply to any given option.
• The VALUE_OPT_ values are #define-d. If WITH_MUMBLING is not
defined, then the associated VALUE_OPT_ value will not be #define-d
either. So, if you have an option named, MUMBLING that is active
only if WITH_MUMBLING is #define-d, then VALUE_OPT_MUMBLING will
be #define-d iff WITH_MUMBLING is #define-d. Watch those switch
statements.
processed after all the homerc files and, in fact, after options that precede it on
the command line.
‘also’ If either the immediate or the immed-disable attributes are set to the string,
“also”, then the option will actually be processed twice: first at the immediate
processing phase and again at the “normal” time.
‘OPT_NO_XLAT_CFG_NAMES;’
‘OPT_XLAT_CFG_NAMES;’
Disable (or enable) the translations of option names for configuration files. If
you enable translation for config files, then they will be translated for command
line options.
‘OPT_NO_XLAT_OPT_NAMES;’
‘OPT_XLAT_OPT_NAMES;’
Disable (or enable) the translations of option names for command line process-
ing. If you disable the translation for command line processing, you will also
disable it for configuration file processing. Once translated, the option names
will remain translated.
‘doc’ First, every flag definition other than “documentation” definitions, must have
a doc attribute defined. If the option takes an argument, then it will need an
arg-name attribute as well. The doc text should be in plain sentences with
minimal formatting. The Texinfo commands @code, and @var will have its
enclosed text made into \fB entries in the man page, and the @file text will
be made into \fI entries. The arg-name attribute is used to display the option’s
argument in the man page.
Options marked with the “documentation” attribute are for documenting the
usage text. All other options should have the “doc” attribute in order to doc-
ument the usage of the option in the generated man pages.
Chapter 7: Automated Option Processing 98
‘arg-name’
If an option has an argument, the argument should have a name for documen-
tation purposes. It will default to arg-type, but it will likely be clearer with
something else like, file-name instead of string (the type).
‘prog-man-descrip’
‘prog-info-descrip’
Then, you need to supply a brief description of what your program does. If
you already have a detail definition, this may be sufficient. If not, or if you
need special formatting for one of the manual formats, then you will need ei-
ther a definition for prog-man-descrip or prog-info-descrip or both. These
will be inserted verbatim in the man page document and the info document,
respectively.
‘man-doc’ Finally, if you need to add man page sections like SEE ALSO or USAGE or other,
put that text in a man-doc definition. This text will be inserted verbatim in
the man page after the OPTIONS section and before the AUTHOR section.
copyright will be printed, too. If it is followed by the letter n, then the full
copyright notice (if available) will be printed.
‘save-opts ->’
This option will cause the option state to be printed in the configuration file
format when option processing is done but not yet verified for consistency. The
program will terminate successfully without running when this has completed.
Note that for most shells you will have to quote or escape the flag character to
restrict special meanings to the shell.
The output file will be the configuration file name (default or provided by
rcfile) in the last directory named in a homerc definition.
This option may be set from within your program by invoking the "SET_
OPT_SAVE_OPTS(filename )" macro (see Section 7.5.20 [SET OPT name],
page 106). Invoking this macro will set the file name for saving the option
processing state, but the state will not actually be saved. You must call
optionSaveFile to do that (see Section 7.5.32.13 [libopts-optionSaveFile],
page 115). CAVEAT: if, after invoking this macro, you call optionProcess,
the option processing state will be saved to this file and optionProcess
will not return. You may wish to invoke CLEAR_OPT( SAVE_OPTS ) (see
Section 7.5.2 [CLEAR OPT], page 103) beforehand.
‘load-opts -<’
This option will load options from the named file. They will be treated exactly
as if they were loaded from the normally found configuration files, but will not
be loaded until the option is actually processed. This can also be used within
another configuration file, causing them to nest. This is the only option that
can be activated inside of config files or with environment variables.
Specifying the negated form of the option (--no-load-opts) will suppress the
processing of configuration files and environment variables.
#define SILENT
#define QUIET
#define BRIEF
Chapter 7: Automated Option Processing 100
#define VERBOSE
By default, only the long form of the option will be available. To specify the short (flag)
form, suffix these names with _FLAG. e.g.,
#define DEBUG_FLAG
--silent, --quiet, --brief and --verbose are related in that they all indicate some
level of diagnostic output. These options are all designed to conflict with each other.
Instead of four different options, however, several levels can be incorporated by #define-
ing VERBOSE_ENUM. In conjunction with VERBOSE, it incorporates the notion of 5 levels in
an enumeration: silent, quiet, brief, informative and verbose; with the default being
brief.
Here is an example program that uses the following set of definitions:
AutoGen Definitions options;
prog-name = default-test;
prog-title = ’Default Option Example’;
homerc = ’$$/../share/default-test’, ’$HOME’, ’.’;
environrc;
long-opts;
gnu-usage;
usage-opt;
version = ’1.0’;
main = {
main-type = shell-process;
};
#define DEBUG_FLAG
#define WARN_FLAG
#define WARN_LEVEL
#define VERBOSE_FLAG
#define VERBOSE_ENUM
#define DRY_RUN_FLAG
#define OUTPUT_FLAG
#define INPUT_FLAG
#define DIRECTORY_FLAG
#define INTERACTIVE_FLAG
#include stdoptions.def
Running a few simple commands on that definition file:
autogen default-test.def
copts="-DTEST_DEFAULT_TEST_OPTS ‘autoopts-config cflags‘"
lopts="‘autoopts-config ldflags‘"
cc -o default-test ${copts} default-test.c ${lopts}
Yields a program which, when run with ‘--help’, prints out:
default-test - Default Option Example - Ver. 1.0
USAGE: default-test [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
Chapter 7: Automated Option Processing 101
The following options are commonly used and are provided and supported
by AutoOpts:
default:
if (gh_boolean_p( set ) && (set == SCM_BOOL_F))
CLEAR_OPT( WRITABLE );
else
SET_OPT_WRITABLE;
}
‘pzLastArg’
Pointer to the latest argument string. BEWARE If the argument type is nu-
meric, an enumeration or a bit mask, then this will be the argument value and
not a pointer to a string.
The following two fields are addressed from the tOptions* pointer:
‘pzProgName’
Points to a NUL-terminated string containing the current program name, as
retrieved from the argument vector.
‘pzProgPath’
Points to a NUL-terminated string containing the full path of the current pro-
gram, as retrieved from the argument vector. (If available on your system.)
Note these fields get filled in during the first call to optionProcess(). All other fields
are private, for the exclusive use of AutoOpts code and are subject to change.
if (HAVE_OPT( NAME )) {
char* p = OPT_ARG( NAME );
<do-things-with-opt-name-argument-string>;
}
do {
char* p = *pp++;
do-things-with-p;
} while (--ct > 0);
}
do {
char* p = *pp++;
do-things-with-p;
} while (--ct > 0);
}
Chapter 7: Automated Option Processing 107
case OPTST_SET:
option set via the SET_OPT_NAME() macro.
case OPTST_PRESET:
option set via an configuration file or environment variable
case OPTST_DEFINED:
option set via a command line option.
default:
cannot happen :)
}
The returned pointer should be deallocated with free(3C) when are done using the data.
The data are placed in a single block of allocated memory. Do not deallocate individual
token/strings.
The structure pointed to will contain at least these two fields:
‘tkn_ct’ The number of tokens found in the input string.
‘tok_list’
An array of tkn_ct + 1 pointers to substring tokens, with the last pointer set
to NULL.
There are two types of quoted strings: single quoted (’) and double quoted ("). Singly
quoted strings are fairly raw in that escape characters (\\) are simply another character,
except when preceding the following characters:
\\ double backslashes reduce to one
’ incorporates the single quote into the string
\n suppresses both the backslash and newline character
Double quote strings are formed according to the rules of string constants in ANSI-C
programs.
NULL is returned and errno will be set to indicate the problem:
• EINVAL - There was an unterminated quoted string.
• ENOENT - The input string was empty.
• ENOMEM - There is not enough memory.
7.5.32.2 configFileLoad
parse a configuration file
Usage:
const tOptionValue* res = configFileLoad( pzFile );
Where the arguments are:
Name Type Description
—– —– ————-
pzFile char const* the file to load
returns const An allocated, compound value structure
tOptionValue*
This routine will load a named configuration file and parse the text as a hierarchically val-
ued option. The option descriptor created from an option definition file is not used via this
interface. The returned value is "named" with the input file name and is of type "OPARG_
TYPE_HIERARCHY". It may be used in calls to optionGetValue(), optionNextValue() and
optionUnloadNested().
If the file cannot be loaded or processed, NULL is returned and errno is set. It may be
set by a call to either open(2) mmap(2) or other file system calls, or it may be:
• ENOENT - the file was empty.
• EINVAL - the file contents are invalid – not properly formed.
• ENOMEM - not enough memory to allocate the needed structures.
Chapter 7: Automated Option Processing 111
7.5.32.3 optionFileLoad
Load the locatable config files, in order
Usage:
int res = optionFileLoad( pOpts, pzProg );
Where the arguments are:
Name Type Description
—– —– ————-
pOpts tOptions* program options descriptor
7.5.32.4 optionFindNextValue
find a hierarcicaly valued option instance
Usage:
const tOptionValue* res = optionFindNextValue( pOptDesc, pPrevVal, name, value );
Where the arguments are:
Name Type Description
—– —– ————-
pOptDesc const an option with a nested arg type
tOptDesc*
pPrevVal const the last entry
tOptionValue*
name char const* name of value to find
• EINVAL - the pOptValue does not point to a valid hierarchical option value.
• ENOENT - no entry matched the given name.
7.5.32.5 optionFindValue
find a hierarcicaly valued option instance
Usage:
const tOptionValue* res = optionFindValue( pOptDesc, name, value );
Where the arguments are:
Name Type Description
—– —– ————-
pOptDesc const an option with a nested arg type
tOptDesc*
name char const* name of value to find
7.5.32.6 optionFree
free allocated option processing memory
Usage:
optionFree( pOpts );
Where the arguments are:
Name Type Description
—– —– ————-
pOpts tOptions* program options descriptor
AutoOpts sometimes allocates memory and puts pointers to it in the option state struc-
tures. This routine deallocates all such memory.
As long as memory has not been corrupted, this routine is always successful.
7.5.32.7 optionGetValue
get a specific value from a hierarcical list
Usage:
const tOptionValue* res = optionGetValue( pOptValue, valueName );
Where the arguments are:
Name Type Description
—– —– ————-
Chapter 7: Automated Option Processing 113
7.5.32.8 optionLoadLine
process a string for an option name and value
Usage:
optionLoadLine( pOpts, pzLine );
Where the arguments are:
Name Type Description
—– —– ————-
pOpts tOptions* program options descriptor
7.5.32.9 optionNextValue
get the next value from a hierarchical list
Usage:
const tOptionValue* res = optionNextValue( pOptValue, pOldValue );
Where the arguments are:
Name Type Description
—– —– ————-
pOptValue const a hierarchcal list value
tOptionValue*
Chapter 7: Automated Option Processing 114
7.5.32.10 optionOnlyUsage
Print usage text for just the options
Usage:
optionOnlyUsage( pOpts, ex_code );
Where the arguments are:
Name Type Description
—– —– ————-
pOpts tOptions* program options descriptor
7.5.32.11 optionProcess
this is the main option processing routine
Usage:
int res = optionProcess( pOpts, argc, argv );
Where the arguments are:
Name Type Description
—– —– ————-
pOpts tOptions* program options descriptor
The number of arguments processed always includes the program name. If one of the
arguments is "–", then it is counted and the processing stops. If an error was encountered
and errors are to be tolerated, then the returned value is the index of the argument causing
the error. A hyphen by itself ("-") will also cause processing to stop and will not be counted
among the processed arguments. A hyphen by itself is treated as an operand. Encountering
an operand stops option processing.
Errors will cause diagnostics to be printed. exit(3) may or may not be called. It
depends upon whether or not the options were generated with the "allow-errors" attribute,
or if the ERRSKIP OPTERR or ERRSTOP OPTERR macros were invoked.
7.5.32.12 optionRestore
restore option state from memory copy
Usage:
optionRestore( pOpts );
Where the arguments are:
Name Type Description
—– —– ————-
pOpts tOptions* program options descriptor
Copy back the option state from saved memory. The allocated memory is left intact, so
this routine can be called repeatedly without having to call optionSaveState again. If you
are restoring a state that was saved before the first call to optionProcess(3AO), then you
may change the contents of the argc/argv parameters to optionProcess.
If you have not called optionSaveState before, a diagnostic is printed to stderr and
exit is called.
7.5.32.13 optionSaveFile
saves the option state to a file
Usage:
optionSaveFile( pOpts );
Where the arguments are:
Name Type Description
—– —– ————-
pOpts tOptions* program options descriptor
This routine will save the state of option processing to a file. The name of that file can
be specified with the argument to the --save-opts option, or by appending the rcfile
attribute to the last homerc attribute. If no rcfile attribute was specified, it will default
to .programname rc. If you wish to specify another file, you should invoke the SET_OPT_
SAVE_OPTS( filename ) macro.
If no homerc file was specified, this routine will silently return and do nothing. If the
output file cannot be created or updated, a message will be printed to stderr and the
routine will return.
Chapter 7: Automated Option Processing 116
7.5.32.14 optionSaveState
saves the option state to memory
Usage:
optionSaveState( pOpts );
Where the arguments are:
Name Type Description
—– —– ————-
pOpts tOptions* program options descriptor
This routine will allocate enough memory to save the current option processing state.
If this routine has been called before, that memory will be reused. You may only save one
copy of the option state. This routine may be called before optionProcess(3AO). If you
do call it before the first call to optionProcess, then you may also change the contents of
argc/argv after you call optionRestore(3AO)
In fact, more strongly put: it is safest to only use this function before having processed
any options. In particular, the saving and restoring of stacked string arguments and hier-
archical values is disabled. The values are not saved.
If it fails to allocate the memory, it will print a message to stderr and exit. Otherwise,
it will always succeed.
7.5.32.15 optionUnloadNested
Deallocate the memory for a nested value
Usage:
optionUnloadNested( pOptVal );
Where the arguments are:
Name Type Description
—– —– ————-
pOptVal tOptionValue the hierarchical value
const *
A nested value needs to be deallocated. The pointer passed in should have been got-
ten from a call to configFileLoad() (See see Section 7.5.32.2 [libopts-configFileLoad],
page 110).
7.5.32.16 optionVersion
return the compiled AutoOpts version number
Usage:
char const* res = optionVersion();
Where the arguments are:
Name Type Description
—– —– ————-
returns char const* the version string in constant memory
Returns the full version string compiled into the library. The returned string cannot be
modified.
Chapter 7: Automated Option Processing 117
7.5.32.17 pathfind
fild a file in a list of directories
Usage:
char* res = pathfind( path, file, mode );
Where the arguments are:
Name Type Description
—– —– ————-
path char const* colon separated list of search directories
mode char const* the mode bits that must be set to match
returns char* the path to the located file
pathfind looks for a a file with name "FILE" and "MODE" access along colon delimited
"PATH", and returns the full pathname as a string, or NULL if not found. If "FILE"
contains a slash, then it is treated as a relative or absolute path and "PATH" is ignored.
NOTE: this function is compiled into ‘libopts’ only if it is not natively supplied.
The "MODE" argument is a string of option letters chosen from the list below:
Letter Meaning
r readable
w writable
x executable
f normal file (NOT IMPLEMENTED)
b block special (NOT IMPLEMENTED)
c character special (NOT IMPLEMENTED)
d directory (NOT IMPLEMENTED)
p FIFO (pipe) (NOT IMPLEMENTED)
u set user ID bit (NOT IMPLEMENTED)
g set group ID bit (NOT IMPLEMENTED)
k sticky bit (NOT IMPLEMENTED)
s size nonzero (NOT IMPLEMENTED)
returns NULL if the file is not found.
7.5.32.18 strequate
map a list of characters to the same value
Usage:
strequate( ch_list );
Where the arguments are:
Name Type Description
—– —– ————-
ch list char const* characters to equivalence
Each character in the input string get mapped to the first character in the string. This
function name is mapped to option strequate so as to not conflict with the POSIX name
space.
Chapter 7: Automated Option Processing 118
none.
7.5.32.19 streqvcmp
compare two strings with an equivalence mapping
Usage:
int res = streqvcmp( str1, str2 );
Where the arguments are:
Name Type Description
—– —– ————-
str1 char const* first string
7.5.32.20 streqvmap
Set the character mappings for the streqv functions
Usage:
streqvmap( From, To, ct );
Where the arguments are:
Name Type Description
—– —– ————-
From char Input character
7.5.32.21 strneqvcmp
compare two strings with an equivalence mapping
Usage:
int res = strneqvcmp( str1, str2, ct );
Where the arguments are:
Name Type Description
—– —– ————-
str1 char const* first string
7.5.32.22 strtransform
convert a string into its mapped-to value
Usage:
strtransform( dest, src );
Where the arguments are:
Name Type Description
—– —– ————-
dest char* output string
7.6 Multi-Threading
AutoOpts was designed to configure a program for running. This generally happens before
much real work has been started. Consequently, it is expected to be run before multi-
threaded applications have started multiple threads. However, this is not always the case.
Some applications may need to reset and reload their running configuration, and some
may use SET_OPT_xxx() macros during processing. If you need to dynamically change
your option configuration in your multi-threaded application, it is your responsibility to
Chapter 7: Automated Option Processing 120
prevent all threads from accessing the option configuration state, except the one altering
the configuration.
The various accessor macros (HAVE_OPT(), etc.) do not modify state and are safe to
use in a multi-threaded application. It is safe as long as no other thread is concurrently
modifying state, of course.
USAGE( EXIT_FAILURE );
}
argv += arg_ct;
Chapter 7: Automated Option Processing 121
}
if (HAVE_OPT(OPTN_NAME))
respond_to_optn_name();
...
}
• Compile ‘myopts.c’ and link your program with the following additional arguments:
‘autoopts-config cflags ldflags‘ myopts.c
http://autogen.sourceforge.net/blocksort.html
Alternatively, you can pull the libopts library sources into a build directory and build
it for installation along with your package. This can be done approximately as follows:
tar -xzvf ‘autoopts-config libsrc‘
cd libopts-*
./bootstrap
configure
make
make install
That will install the library, but not the headers or anything else.
appear in a configuration file. The files loaded are selected both by the homerc entries and,
optionally, via a command line option. The first component of the homerc entry may be
an environment variable such as $HOME, or it may also be $$ (two dollar sign characters) to
specify the directory of the executable. For example:
homerc = "$$/../share/autogen";
will cause the AutoOpts library to look in the normal autogen datadir relative to the current
installation directory for autogen.
The configuration files are processed in the order they are specified by the homerc at-
tribute, so that each new file will normally override the settings of the previous files. This
may be overridden by marking some options for immediate action (see Section 7.4.5.9
[Immediate Action], page 91). Any such options are acted upon in reverse order. The
disabled load-opts (--no-load-opts) option, for example, is an immediate action option.
Its presence in the last homerc file will prevent the processing of any prior homerc files
because its effect is immediate.
Configuration file processing can be completely suppressed by specifying --no-load-
opts on the command line, or PROGRAM_LOAD_OPTS=no in the environment (if environrc
has been specified).
See the “Configuration File Format” section (see Section 7.10 [Config File Format],
page 130) for details on the format of the file.
# Example:
#
#listattr def
# srcfile = ’%s’;
# @end example
# If an argument is supplied, that string will be used for the entry
# name instead of @var{srcfile}.
# Example:
#
#srcfile file
program that tries to load a configuration file ‘hello.conf’ to see if it should use an alternate
greeting or to personalize the salutation.
#include <sys/types.h>
#include <stdio.h>
#include <pwd.h>
#include <string.h>
#include <unistd.h>
#include <autoopts/options.h>
int main(int argc, char ** argv) {
char const * greeting = "Hello";
char const * greeted = "World";
tOptionValue const * pOV = configFileLoad("hello.conf");
if (pOV != NULL) {
const tOptionValue* pGetV = optionGetValue(pOV, "greeting");
if ( (pGetV != NULL)
&& (pGetV->valType == OPARG_TYPE_STRING))
greeting = strdup(pGetV->v.strVal);
‘[PROG_NAME]’
The file is partitioned by lines that contains an square open bracket ([), the
upper-cased c-variable-syntax program name and a square close bracket (]).
For example, if the prog-name program had a sectioned configuration file, then
a line containing exactly ‘[PROG_NAME]’ would be processed.
‘<?program prog-name>’
The <? marker indicates an XML directive. The program directive is interpreted
by the configuration file processor to segment the file in the same way as the
‘[PROG_NAME]’ sectioning is done. Any other XML directives are treated as
comments.
Segmentation does not apply if the config file is being parsed with the
configFileLoad(3AutoOpts) function.
Note that ‘shell’ is only useful if the output file does not already
Chapter 7: Automated Option Processing 134
exist. If it does, then the shell name and optional first argument
will be extracted from the script file.
If the script file already exists and contains Automated Option Processing
text, the second line of the file through the ending tag will be replaced
by the newly generated text. The first ‘#!’ line will be regenerated.
= = = = = = = =
#! /bin/sh
# # # # # # # # # # -- do not modify this marker --
#
# DO NOT EDIT THIS SECTION OF /local/tmp/.ag-OFuvmB/genshellopt.sh
#
# From here to the next ‘-- do not modify this marker --’,
# the text has been generated Saturday May 24, 2008 at 10:46:29 AM PDT
# From the GETDEFS option definitions
#
GETDEFS_LONGUSAGE_TEXT=’getdefs (GNU AutoGen) - AutoGen Definition Extraction Tool -
USAGE: getdefs [ <option-name>[{=| }<val>] ]...
Arg Option-Name Description
Str defs-to-get Regexp to look for after the "/*="
opt ordering Alphabetize or use named file
- disabled as --no-ordering
- enabled by default
Num first-index The first index to apply to groups
Str input Input file to search for defs
- may appear multiple times
- default option for unnamed options
Str subblock subblock definition names
- may appear multiple times
Str listattr attribute with list of values
- may appear multiple times
opt filelist Insert source file names into defs
- enabled by default
Str template Template Name
Str agarg AutoGen Argument
- prohibits these options:
output
- may appear multiple times
Str base-name Base name for output file(s)
- prohibits these options:
output
GETDEFS_DEFS_TO_GET="${GETDEFS_DEFS_TO_GET}"
GETDEFS_DEFS_TO_GET_set=false
Chapter 7: Automated Option Processing 138
export GETDEFS_DEFS_TO_GET
GETDEFS_ORDERING="${GETDEFS_ORDERING}"
GETDEFS_ORDERING_set=false
export GETDEFS_ORDERING
GETDEFS_FIRST_INDEX="${GETDEFS_FIRST_INDEX-’0’}"
GETDEFS_FIRST_INDEX_set=false
export GETDEFS_FIRST_INDEX
if test -z "${GETDEFS_INPUT}"
then
GETDEFS_INPUT_CT=0
else
GETDEFS_INPUT_CT=1
GETDEFS_INPUT_1="${GETDEFS_INPUT}"
fi
export GETDEFS_INPUT_CT
if test -z "${GETDEFS_SUBBLOCK}"
then
GETDEFS_SUBBLOCK_CT=0
else
GETDEFS_SUBBLOCK_CT=1
GETDEFS_SUBBLOCK_1="${GETDEFS_SUBBLOCK}"
fi
export GETDEFS_SUBBLOCK_CT
if test -z "${GETDEFS_LISTATTR}"
then
GETDEFS_LISTATTR_CT=0
else
GETDEFS_LISTATTR_CT=1
GETDEFS_LISTATTR_1="${GETDEFS_LISTATTR}"
fi
export GETDEFS_LISTATTR_CT
GETDEFS_FILELIST="${GETDEFS_FILELIST}"
GETDEFS_FILELIST_set=false
export GETDEFS_FILELIST
if test -z "${GETDEFS_ASSIGN}"
then
GETDEFS_ASSIGN_CT=0
else
GETDEFS_ASSIGN_CT=1
GETDEFS_ASSIGN_1="${GETDEFS_ASSIGN}"
fi
export GETDEFS_ASSIGN_CT
if test -z "${GETDEFS_COMMON_ASSIGN}"
Chapter 7: Automated Option Processing 139
then
GETDEFS_COMMON_ASSIGN_CT=0
else
GETDEFS_COMMON_ASSIGN_CT=1
GETDEFS_COMMON_ASSIGN_1="${GETDEFS_COMMON_ASSIGN}"
fi
export GETDEFS_COMMON_ASSIGN_CT
if test -z "${GETDEFS_COPY}"
then
GETDEFS_COPY_CT=0
else
GETDEFS_COPY_CT=1
GETDEFS_COPY_1="${GETDEFS_COPY}"
fi
export GETDEFS_COPY_CT
GETDEFS_SRCFILE="${GETDEFS_SRCFILE}"
GETDEFS_SRCFILE_set=false
export GETDEFS_SRCFILE
GETDEFS_LINENUM="${GETDEFS_LINENUM}"
GETDEFS_LINENUM_set=false
export GETDEFS_LINENUM
GETDEFS_OUTPUT="${GETDEFS_OUTPUT}"
GETDEFS_OUTPUT_set=false
export GETDEFS_OUTPUT
GETDEFS_AUTOGEN="${GETDEFS_AUTOGEN}"
GETDEFS_AUTOGEN_set=false
export GETDEFS_AUTOGEN
GETDEFS_TEMPLATE="${GETDEFS_TEMPLATE}"
GETDEFS_TEMPLATE_set=false
export GETDEFS_TEMPLATE
if test -z "${GETDEFS_AGARG}"
then
GETDEFS_AGARG_CT=0
else
GETDEFS_AGARG_CT=1
GETDEFS_AGARG_1="${GETDEFS_AGARG}"
fi
export GETDEFS_AGARG_CT
GETDEFS_BASE_NAME="${GETDEFS_BASE_NAME}"
GETDEFS_BASE_NAME_set=false
export GETDEFS_BASE_NAME
Chapter 7: Automated Option Processing 140
OPT_ARG="$1"
while [ $# -gt 0 ]
do
OPT_ELEMENT=’’
OPT_ARG_VAL=’’
OPT_ARG="${1}"
OPT_CODE=‘echo "X${OPT_ARG}"|sed ’s/^X-*//’‘
shift
OPT_ARG="$1"
case "${OPT_CODE}" in
’de’ | \
’def’ | \
’defs’ | \
’defs-’ | \
’defs-t’ | \
’defs-to’ | \
’defs-to-’ | \
’defs-to-g’ | \
’defs-to-ge’ | \
’defs-to-get’ )
if [ -n "${GETDEFS_DEFS_TO_GET}" ] && ${GETDEFS_DEFS_TO_GET_set} ; then
echo Error: duplicate DEFS_TO_GET option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_DEFS_TO_GET_set=true
OPT_NAME=’DEFS_TO_GET’
OPT_ARG_NEEDED=YES
;;
’or’ | \
’ord’ | \
’orde’ | \
’order’ | \
’orderi’ | \
’orderin’ | \
’ordering’ )
if [ -n "${GETDEFS_ORDERING}" ] && ${GETDEFS_ORDERING_set} ; then
echo Error: duplicate ORDERING option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
Chapter 7: Automated Option Processing 141
GETDEFS_ORDERING_set=true
OPT_NAME=’ORDERING’
eval GETDEFS_ORDERING${OPT_ELEMENT}=true
export GETDEFS_ORDERING${OPT_ELEMENT}
OPT_ARG_NEEDED=OK
;;
’no-o’ | \
’no-or’ | \
’no-ord’ | \
’no-orde’ | \
’no-order’ | \
’no-orderi’ | \
’no-orderin’ | \
’no-ordering’ )
if [ -n "${GETDEFS_ORDERING}" ] && ${GETDEFS_ORDERING_set} ; then
echo Error: duplicate ORDERING option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_ORDERING_set=true
GETDEFS_ORDERING=’no’
export GETDEFS_ORDERING
OPT_NAME=’ORDERING’
OPT_ARG_NEEDED=NO
;;
’fir’ | \
’firs’ | \
’first’ | \
’first-’ | \
’first-i’ | \
’first-in’ | \
’first-ind’ | \
’first-inde’ | \
’first-index’ )
if [ -n "${GETDEFS_FIRST_INDEX}" ] && ${GETDEFS_FIRST_INDEX_set} ; then
echo Error: duplicate FIRST_INDEX option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_FIRST_INDEX_set=true
OPT_NAME=’FIRST_INDEX’
OPT_ARG_NEEDED=YES
;;
’in’ | \
’inp’ | \
’inpu’ | \
Chapter 7: Automated Option Processing 142
’input’ )
GETDEFS_INPUT_CT=‘expr ${GETDEFS_INPUT_CT} + 1‘
OPT_ELEMENT="_${GETDEFS_INPUT_CT}"
OPT_NAME=’INPUT’
OPT_ARG_NEEDED=YES
;;
’su’ | \
’sub’ | \
’subb’ | \
’subbl’ | \
’subblo’ | \
’subbloc’ | \
’subblock’ )
GETDEFS_SUBBLOCK_CT=‘expr ${GETDEFS_SUBBLOCK_CT} + 1‘
OPT_ELEMENT="_${GETDEFS_SUBBLOCK_CT}"
OPT_NAME=’SUBBLOCK’
OPT_ARG_NEEDED=YES
;;
’lis’ | \
’list’ | \
’lista’ | \
’listat’ | \
’listatt’ | \
’listattr’ )
GETDEFS_LISTATTR_CT=‘expr ${GETDEFS_LISTATTR_CT} + 1‘
OPT_ELEMENT="_${GETDEFS_LISTATTR_CT}"
OPT_NAME=’LISTATTR’
OPT_ARG_NEEDED=YES
;;
’fil’ | \
’file’ | \
’filel’ | \
’fileli’ | \
’filelis’ | \
’filelist’ )
if [ -n "${GETDEFS_FILELIST}" ] && ${GETDEFS_FILELIST_set} ; then
echo Error: duplicate FILELIST option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_FILELIST_set=true
OPT_NAME=’FILELIST’
eval GETDEFS_FILELIST${OPT_ELEMENT}=true
export GETDEFS_FILELIST${OPT_ELEMENT}
OPT_ARG_NEEDED=OK
Chapter 7: Automated Option Processing 143
;;
’as’ | \
’ass’ | \
’assi’ | \
’assig’ | \
’assign’ )
GETDEFS_ASSIGN_CT=‘expr ${GETDEFS_ASSIGN_CT} + 1‘
OPT_ELEMENT="_${GETDEFS_ASSIGN_CT}"
OPT_NAME=’ASSIGN’
OPT_ARG_NEEDED=YES
;;
’com’ | \
’comm’ | \
’commo’ | \
’common’ | \
’common-’ | \
’common-a’ | \
’common-as’ | \
’common-ass’ | \
’common-assi’ | \
’common-assig’ | \
’common-assign’ )
GETDEFS_COMMON_ASSIGN_CT=‘expr ${GETDEFS_COMMON_ASSIGN_CT} + 1‘
OPT_ELEMENT="_${GETDEFS_COMMON_ASSIGN_CT}"
OPT_NAME=’COMMON_ASSIGN’
OPT_ARG_NEEDED=YES
;;
’cop’ | \
’copy’ )
GETDEFS_COPY_CT=‘expr ${GETDEFS_COPY_CT} + 1‘
OPT_ELEMENT="_${GETDEFS_COPY_CT}"
OPT_NAME=’COPY’
OPT_ARG_NEEDED=YES
;;
’sr’ | \
’src’ | \
’srcf’ | \
’srcfi’ | \
’srcfil’ | \
’srcfile’ )
if [ -n "${GETDEFS_SRCFILE}" ] && ${GETDEFS_SRCFILE_set} ; then
echo Error: duplicate SRCFILE option >&2
echo "$GETDEFS_USAGE_TEXT"
Chapter 7: Automated Option Processing 144
exit 1 ; fi
GETDEFS_SRCFILE_set=true
OPT_NAME=’SRCFILE’
eval GETDEFS_SRCFILE${OPT_ELEMENT}=true
export GETDEFS_SRCFILE${OPT_ELEMENT}
OPT_ARG_NEEDED=OK
;;
’lin’ | \
’line’ | \
’linen’ | \
’linenu’ | \
’linenum’ )
if [ -n "${GETDEFS_LINENUM}" ] && ${GETDEFS_LINENUM_set} ; then
echo Error: duplicate LINENUM option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_LINENUM_set=true
OPT_NAME=’LINENUM’
eval GETDEFS_LINENUM${OPT_ELEMENT}=true
export GETDEFS_LINENUM${OPT_ELEMENT}
OPT_ARG_NEEDED=OK
;;
’ou’ | \
’out’ | \
’outp’ | \
’outpu’ | \
’output’ )
if [ -n "${GETDEFS_OUTPUT}" ] && ${GETDEFS_OUTPUT_set} ; then
echo Error: duplicate OUTPUT option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_OUTPUT_set=true
OPT_NAME=’OUTPUT’
OPT_ARG_NEEDED=YES
;;
’au’ | \
’aut’ | \
’auto’ | \
’autog’ | \
’autoge’ | \
’autogen’ )
if [ -n "${GETDEFS_AUTOGEN}" ] && ${GETDEFS_AUTOGEN_set} ; then
echo Error: duplicate AUTOGEN option >&2
echo "$GETDEFS_USAGE_TEXT"
Chapter 7: Automated Option Processing 145
exit 1 ; fi
GETDEFS_AUTOGEN_set=true
OPT_NAME=’AUTOGEN’
eval GETDEFS_AUTOGEN${OPT_ELEMENT}=true
export GETDEFS_AUTOGEN${OPT_ELEMENT}
OPT_ARG_NEEDED=OK
;;
’no-a’ | \
’no-au’ | \
’no-aut’ | \
’no-auto’ | \
’no-autog’ | \
’no-autoge’ | \
’no-autogen’ )
if [ -n "${GETDEFS_AUTOGEN}" ] && ${GETDEFS_AUTOGEN_set} ; then
echo Error: duplicate AUTOGEN option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_AUTOGEN_set=true
GETDEFS_AUTOGEN=’no’
export GETDEFS_AUTOGEN
OPT_NAME=’AUTOGEN’
OPT_ARG_NEEDED=NO
;;
’te’ | \
’tem’ | \
’temp’ | \
’templ’ | \
’templa’ | \
’templat’ | \
’template’ )
if [ -n "${GETDEFS_TEMPLATE}" ] && ${GETDEFS_TEMPLATE_set} ; then
echo Error: duplicate TEMPLATE option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_TEMPLATE_set=true
OPT_NAME=’TEMPLATE’
OPT_ARG_NEEDED=YES
;;
’ag’ | \
’aga’ | \
’agar’ | \
’agarg’ )
GETDEFS_AGARG_CT=‘expr ${GETDEFS_AGARG_CT} + 1‘
Chapter 7: Automated Option Processing 146
OPT_ELEMENT="_${GETDEFS_AGARG_CT}"
OPT_NAME=’AGARG’
OPT_ARG_NEEDED=YES
;;
’ba’ | \
’bas’ | \
’base’ | \
’base-’ | \
’base-n’ | \
’base-na’ | \
’base-nam’ | \
’base-name’ )
if [ -n "${GETDEFS_BASE_NAME}" ] && ${GETDEFS_BASE_NAME_set} ; then
echo Error: duplicate BASE_NAME option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1 ; fi
GETDEFS_BASE_NAME_set=true
OPT_NAME=’BASE_NAME’
OPT_ARG_NEEDED=YES
;;
’ve’ | \
’ver’ | \
’vers’ | \
’versi’ | \
’versio’ | \
’version’ )
echo "$GETDEFS_LONGUSAGE_TEXT"
exit 0
;;
’he’ | \
’hel’ | \
’help’ )
echo "$GETDEFS_LONGUSAGE_TEXT"
exit 0
;;
’mo’ | \
’mor’ | \
’more’ | \
’more-’ | \
’more-h’ | \
’more-he’ | \
’more-hel’ | \
’more-help’ )
Chapter 7: Automated Option Processing 147
’sa’ | \
’sav’ | \
’save’ | \
’save-’ | \
’save-o’ | \
’save-op’ | \
’save-opt’ | \
’save-opts’ )
echo ’Warning: Cannot save options files’ >&2
OPT_ARG_NEEDED=OK
;;
’lo’ | \
’loa’ | \
’load’ | \
’load-’ | \
’load-o’ | \
’load-op’ | \
’load-opt’ | \
’load-opts’ )
echo ’Warning: Cannot load options files’ >&2
OPT_ARG_NEEDED=YES
;;
’no-l’ | \
’no-lo’ | \
’no-loa’ | \
’no-load’ | \
’no-load-’ | \
’no-load-o’ | \
’no-load-op’ | \
’no-load-opt’ | \
’no-load-opts’ )
echo ’Warning: Cannot suppress the loading of options files’ >&2
OPT_ARG_NEEDED=NO
;;
* )
echo Unknown option: "${OPT_CODE}" >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1
;;
esac
Chapter 7: Automated Option Processing 148
case "${OPT_ARG_NEEDED}" in
NO )
OPT_ARG_VAL=’’
;;
YES )
if [ -z "${OPT_ARG_VAL}" ]
then
if [ $# -eq 0 ]
then
echo No argument provided for ${OPT_NAME} option >&2
echo "$GETDEFS_USAGE_TEXT"
exit 1
fi
OPT_ARG_VAL="${OPT_ARG}"
shift
OPT_ARG="$1"
fi
;;
OK )
if [ -z "${OPT_ARG_VAL}" ] && [ $# -gt 0 ]
then
case "${OPT_ARG}" in -* ) ;; * )
OPT_ARG_VAL="${OPT_ARG}"
shift
OPT_ARG="$1" ;; esac
fi
;;
esac
if [ -n "${OPT_ARG_VAL}" ]
then
eval GETDEFS_${OPT_NAME}${OPT_ELEMENT}="’${OPT_ARG_VAL}’"
export GETDEFS_${OPT_NAME}${OPT_ELEMENT}
fi
done
unset OPT_PROCESS || :
unset OPT_ELEMENT || :
unset OPT_ARG || :
unset OPT_ARG_NEEDED || :
unset OPT_NAME || :
unset OPT_CODE || :
unset OPT_ARG_VAL || :
Chapter 7: Automated Option Processing 149
# # # # # # # # # #
#
# END OF AUTOMATED OPTION PROCESSING
#
# # # # # # # # # # -- do not modify this marker --
*
* what: this is the main option processing routine
* arg: + tOptions* + pOpts + program options descriptor +
* arg: + int + argc + program arg count +
* arg: + char** + argv + program arg vector +
* ret_type: int
* ret_desc: the count of the arguments processed
*
* doc: This is what it does.
* err: When it can’t, it does this.
=*/
Note the subblock and library comments. subblock is an embedded ‘getdefs’ option
(see Section 8.5.6 [getdefs subblock], page 162) that tells it how to parse the arg attribute.
The library and header entries are global definitions that apply to all the documented
functions.
‘CC’ Set this only if “cc” cannot be found in $PATH (or it is not the one you
want).
To use this, set the exported environment variables and then invoke autogen twice, in the
following order:
autogen myprog-opts.def
autogen -T getopt.tpl myprog-opts.def
and you will have three new files: ‘myprog-opts.h’, ‘myprog-opts.c’, and
‘getopt-progname.c’, where “progname” is the name specified with the global prog-name
attribute in the option definition file. You must compile and link both ‘.c’ files into your
program. If there are link failures, then you are using AutoOpts features that require the
‘libopts’ library. You must remove these features.
output
The "this, char *" string is separated at the commas, with the white space removed.
You may use characters other than commas by starting the value string with a punctuation
character other than a single or double quote character. You may also omit intermediate
values by placing the commas next to each other with no intervening white space. For
example, "+mumble++yes+" will expand to:
arg = { argname = mumble; null = "yes"; };.
• must not appear in combination with any of the following options: output.
This is a pass-through argument. It allows you to specify any arbitrary argument to be
passed to AutoGen.
This program will convert any arbitrary XML file into equivalent
AutoGen definitions, and invoke AutoGen.
The Document may include Warranty Disclaimers next to the notice which states that
this License applies to the Document. These Warranty Disclaimers are considered to
be included by reference in this License, but only as regards disclaiming warranties:
any other implication that these Warranty Disclaimers may have is void and has no
effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or
noncommercially, provided that this License, the copyright notices, and the license
notice saying this License applies to the Document are reproduced in all copies, and
that you add no other conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further copying of the copies
you make or distribute. However, you may accept compensation in exchange for copies.
If you distribute a large enough number of copies you must also follow the conditions
in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly
display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed covers) of
the Document, numbering more than 100, and the Document’s license notice requires
Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all
these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify you as the publisher
of these copies. The front cover must present the full title with all words of the title
equally prominent and visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve the title of the
Document and satisfy these conditions, can be treated as verbatim copying in other
respects.
If the required texts for either cover are too voluminous to fit legibly, you should put
the first ones listed (as many as fit reasonably) on the actual cover, and continue the
rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100,
you must either include a machine-readable Transparent copy along with each Opaque
copy, or state in or with each Opaque copy a computer-network location from which
the general network-using public has access to download using public-standard network
protocols a complete Transparent copy of the Document, free of added material. If
you use the latter option, you must take reasonably prudent steps, when you begin
distribution of Opaque copies in quantity, to ensure that this Transparent copy will
remain thus accessible at the stated location until at least one year after the last time
you distribute an Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the Document well
before redistributing any large number of copies, to give them a chance to provide you
with an updated version of the Document.
4. MODIFICATIONS
Appendix A: Copying This Manual 175
You may copy and distribute a Modified Version of the Document under the conditions
of sections 2 and 3 above, provided that you release the Modified Version under precisely
this License, with the Modified Version filling the role of the Document, thus licensing
distribution and modification of the Modified Version to whoever possesses a copy of
it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the
Document, and from those of previous versions (which should, if there were any,
be listed in the History section of the Document). You may use the same title as
a previous version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for
authorship of the modifications in the Modified Version, together with at least five
of the principal authors of the Document (all of its principal authors, if it has fewer
than five), unless they release you from this requirement.
C. State on the Title page the name of the publisher of the Modified Version, as the
publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications adjacent to the other
copyright notices.
F. Include, immediately after the copyright notices, a license notice giving the public
permission to use the Modified Version under the terms of this License, in the form
shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover
Texts given in the Document’s license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled “History”, Preserve its Title, and add to it an item
stating at least the title, year, new authors, and publisher of the Modified Version
as given on the Title Page. If there is no section Entitled “History” in the Docu-
ment, create one stating the title, year, authors, and publisher of the Document
as given on its Title Page, then add an item describing the Modified Version as
stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to
a Transparent copy of the Document, and likewise the network locations given in
the Document for previous versions it was based on. These may be placed in the
“History” section. You may omit a network location for a work that was published
at least four years before the Document itself, or if the original publisher of the
version it refers to gives permission.
K. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title
of the section, and preserve in the section all the substance and tone of each of the
contributor acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and
in their titles. Section numbers or the equivalent are not considered part of the
section titles.
M. Delete any section Entitled “Endorsements”. Such a section may not be included
in the Modified Version.
Appendix A: Copying This Manual 176
follow the rules of this License for verbatim copying of each of the documents in all
other respects.
You may extract a single document from such a collection, and distribute it individu-
ally under this License, provided you insert a copy of this License into the extracted
document, and follow this License in all other respects regarding verbatim copying of
that document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate and independent
documents or works, in or on a volume of a storage or distribution medium, is called
an “aggregate” if the copyright resulting from the compilation is not used to limit the
legal rights of the compilation’s users beyond what the individual works permit. When
the Document is included in an aggregate, this License does not apply to the other
works in the aggregate which are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document,
then if the Document is less than one half of the entire aggregate, the Document’s Cover
Texts may be placed on covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form. Otherwise they
must appear on printed covers that bracket the whole aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may distribute translations
of the Document under the terms of section 4. Replacing Invariant Sections with
translations requires special permission from their copyright holders, but you may
include translations of some or all Invariant Sections in addition to the original versions
of these Invariant Sections. You may include a translation of this License, and all the
license notices in the Document, and any Warranty Disclaimers, provided that you
also include the original English version of this License and the original versions of
those notices and disclaimers. In case of a disagreement between the translation and
the original version of this License or a notice or disclaimer, the original version will
prevail.
If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “His-
tory”, the requirement (section 4) to Preserve its Title (section 1) will typically require
changing the actual title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly
provided for under this License. Any other attempt to copy, modify, sublicense or
distribute the Document is void, and will automatically terminate your rights under
this License. However, parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such parties remain in full
compliance.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions of the GNU Free
Documentation License from time to time. Such new versions will be similar in spirit
to the present version, but may differ in detail to address new problems or concerns.
See http://www.gnu.org/copyleft/.
Appendix A: Copying This Manual 178
Each version of the License is given a distinguishing version number. If the Document
specifies that a particular numbered version of this License “or any later version”
applies to it, you have the option of following the terms and conditions either of that
specified version or of any later version that has been published (not as a draft) by
the Free Software Foundation. If the Document does not specify a version number of
this License, you may choose any version ever published (not as a draft) by the Free
Software Foundation.
Appendix A: Copying This Manual 179
Concept Index
# autogen-templ-dirs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
#assert. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 autogen-timeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
#define . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 autogen-trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
#elif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 autogen-trace-out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
#else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 autogen-undefine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
#endif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 autogen-writable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
#endmac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 AutoInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
#endshell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 AutoMan pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
#error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 automatic options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
#if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 autoopts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
#ifdef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 AutoOpts API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
#ifndef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 AutoXDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
#include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
#line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
#macdef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
C
#option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 call-proc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
#shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Columnize Input Text . . . . . . . . . . . . . . . . . . . . . . . . 155
#undef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
columns usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
columns-by-columns . . . . . . . . . . . . . . . . . . . . . . . . . . 158
. columns-col-width . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
.def file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 columns-columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
.tpl file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 columns-fill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
columns-first-indent . . . . . . . . . . . . . . . . . . . . . . . . . . 157
columns-format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
A columns-indent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
allow-errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 columns-input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Alternate Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 columns-line-separation . . . . . . . . . . . . . . . . . . . . . . . 158
arg-default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 columns-separation . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
arg-optional . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 columns-sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
arg-range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 columns-spread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
arg-type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 columns-tab-width. . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 columns-width. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
assert directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Augmenting AutoGen . . . . . . . . . . . . . . . . . . . . . . . . . 59 Common Option Attributes . . . . . . . . . . . . . . . . . . . . 88
AutoEvents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 compound definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
AutoFSM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 concat-string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
autogen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 conditional emit . . . . . . . . . . . . . . . . . . . . . . . . . . . 56, 57
AutoGen Definition Extraction Tool . . . . . . . . . . 159 config-header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
autogen usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 configuration file . . . . . . . . . . . . . . 78, 89, 99, 102, 132
autogen-base-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Configuration File . . . . . . . . . . . . . . . . . . . . . . . 128, 130
autogen-define . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Configuration File example . . . . . . . . . . . . . . . . . . . 128
autogen-definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 configuring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
autogen-equate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
autogen-lib-template . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
autogen-load-functions . . . . . . . . . . . . . . . . . . . . . . . . . 64
autogen-load-scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 D
autogen-loop-limit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 define directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
autogen-no-fmemopen . . . . . . . . . . . . . . . . . . . . . . . . . 66 define macro. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
autogen-override-tpl . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Definition Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
autogen-select-suffix . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
autogen-show-defs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 definitions file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
autogen-skip-suffix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 descrip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
autogen-source-time . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 design goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Concept Index 181
E
elif directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 H
else directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 here-string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 homerc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
enabled. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
endif directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
endmac directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
I
endshell directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
environrc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78, 128 if directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
error directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 if test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
example, simple AutoGen . . . . . . . . . . . . . . . . . . . . . . . 2 ifdef directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
example, simple AutoOpts . . . . . . . . . . . . . . . . . . . . . 76 ifndef directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
explain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 immed-disable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
expression syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 immediate action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
extract-code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
include directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
information attributes . . . . . . . . . . . . . . . . . . . . . . . . . 86
F Installing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
FDL, GNU Free Documentation License . . . . . . 172 Internationalizing AutoOpts . . . . . . . . . . . . . . . . . . 153
features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Internationalizing Options . . . . . . . . . . . . . . . . . . . . . 97
file-exists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
file-mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
finite state machine . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
flag-code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
K
flag-proc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
flags-cant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
flags-must . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
fOptState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 L
for loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 library attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
full-usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
futures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 line directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
long-opts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
looping, for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
G
getdefs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
getdefs usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 M
getdefs-agarg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 m4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
getdefs-assign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 macdef directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
getdefs-autogen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 macro syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
getdefs-base-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 macro, pseudo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
getdefs-common-assign . . . . . . . . . . . . . . . . . . . . . . . 163 main procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
getdefs-copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 man-doc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
getdefs-defs-to-get . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
getdefs-filelist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 min . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
getdefs-first-index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 must-set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
getdefs-input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
getdefs-linenum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
getdefs-listattr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 N
getdefs-ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Concept Index 182
Function Index
* DEFINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
*= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 DESC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
*=* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 DISABLE_OPT_name. . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
*== . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 dne . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
*==* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
*~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
*~* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
45
46
E
*~~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 ELIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
*~~* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
emit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
emit-string-table. . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
= ENABLED_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
=.............................................. 46 ENDDEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
=* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 ENDFOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
== . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 ENDIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
==* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 ENDWHILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
error-source-line. . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
~ ERRSKIP_OPTERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
~.............................................. 46 ERRSTOP_OPTERR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
~* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 ESAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
~~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 exist? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
~~* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 EXPR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
extract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
A F
ag-fprintf. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
ag-function? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 find-file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
agpl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 first-for?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
ao_string_tokenize . . . . . . . . . . . . . . . . . . . . . . . . . 109 FOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
autogen-version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 for-by . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
for-from . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
for-index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
B for-sep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
for-to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
28
base-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 format-arg-count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
bsd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 fprintf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
C G
c-file-line-fmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
c-string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
get-c-name. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
CASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
get-down-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
chdir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
get-up-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
CLEAR_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
gperf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
COMMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
gperf-code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
configFileLoad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
gpl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
COUNT_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
H
D HAVE_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
DEBUG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 hide-email. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
def-file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 high-lim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
def-file-line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 html-escape-encode . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Function Index 184
I out-depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
IF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 out-emit-suspended . . . . . . . . . . . . . . . . . . . . . . . . . . 31
in? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 out-line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 out-move . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
INVOKE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 out-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
ISSEL_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 out-pop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
ISUNUSED_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 out-push-add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
out-push-new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
out-resume. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
J out-suspend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
out-switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
P
K pathfind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
kr-string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
printf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
L
last-for? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 R
len . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 raw-shell-str . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
lgpl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 RESTART_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
license . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
low-lim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
S
SELECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
M set-option. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
make-gperf. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 set-writable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
make-header-guard. . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 SET_OPT_name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
makefile-script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
match-value? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 shell-str . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 shellf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
min . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 sprintf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
STACKCT_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
O STACKLST_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
OPT_ARG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 START_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
OPT_NO_XLAT_CFG_NAMES . . . . . . . . . . . . . . . . . . . . . . 105 STATE_OPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
OPT_NO_XLAT_OPT_NAMES . . . . . . . . . . . . . . . . . . . . . . 105 strequate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
OPT_VALUE_name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 streqvcmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
OPT_XLAT_CFG_NAMES . . . . . . . . . . . . . . . . . . . . . . . . . 105 streqvmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
OPT_XLAT_OPT_NAMES . . . . . . . . . . . . . . . . . . . . . . . . . 105 string->c-name! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
OPTION_CT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 string-capitalize. . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
optionFileLoad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 string-capitalize! . . . . . . . . . . . . . . . . . . . . . . . . . . 44
optionFindNextValue . . . . . . . . . . . . . . . . . . . . . . . . 111 string-contains-eqv? . . . . . . . . . . . . . . . . . . . . . . . . 44
optionFindValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 string-contains? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
optionFree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 string-downcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
optionGetValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 string-downcase! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
optionLoadLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 string-end-eqv-match? . . . . . . . . . . . . . . . . . . . . . . . 45
optionNextValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 string-end-match?. . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
optionOnlyUsage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 string-ends-eqv? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
optionProcess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 string-ends-with?. . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
optionRestore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 string-equals? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
optionSaveFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 string-eqv-match?. . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
optionSaveState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 string-eqv? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
optionUnloadNested . . . . . . . . . . . . . . . . . . . . . . . . . 116 string-has-eqv-match? . . . . . . . . . . . . . . . . . . . . . . . 46
optionVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 string-has-match?. . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
out-delete. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 string-match? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Function Index 185
string-start-eqv-match? . . . . . . . . . . . . . . . . . . . . . 46 T
string-start-match? . . . . . . . . . . . . . . . . . . . . . . . . . 47 teOptIndex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
string-starts-eqv? . . . . . . . . . . . . . . . . . . . . . . . . . . 47 tpl-file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
string-starts-with? . . . . . . . . . . . . . . . . . . . . . . . . . 47 tpl-file-line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
string-substitute. . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
string-table-add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
string-table-add-ref . . . . . . . . . . . . . . . . . . . . . . . . 48 U
string-table-new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 UNKNOWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
string-table-size. . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 USAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
string-tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
string-tr!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
string-upcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
V
string-upcase! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 VALUE_OPT_name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
VERSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
strneqvcmp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
version-compare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
strtransform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
sub-shell-str . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
suffix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 W
sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
WHICH_IDX_name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
WHICH_OPT_name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
WHILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
i
Table of Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 The Purpose of AutoGen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 A Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 csh/zsh caveat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 A User’s Perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Definitions File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1 The Identification Definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Named Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.1 Definition List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.2 Double Quote String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.3 Single Quote String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2.4 Shell Output String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.5 An Unquoted String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.6 Scheme Result String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.7 A Here String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.8 Concatenated Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Assigning an Index to a Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Dynamic Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 Controlling What Gets Processed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6 Pre-defined Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.7 Commenting Your Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.8 What it all looks like. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.9 Finite State Machine Grammar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.10 Alternate Definition Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3 Template File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.1 Format of the Pseudo Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 Naming a value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3 Macro Expression Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.1 Apply Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.3.2 Basic Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.4 AutoGen Scheme Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.1 ‘ag-function?’ - test for function . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.2 ‘base-name’ - base output name . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.3 ‘chdir’ - Change current directory. . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.4 ‘count’ - definition count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.5 ‘def-file’ - definitions file name . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.4.6 ‘def-file-line’ - get a definition file+line number . . . . . . . 26
3.4.7 ‘dne’ - "Do Not Edit" warning . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.8 ‘error’ - display message and exit . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.9 ‘exist?’ - test for value name . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
ii
5 Invoking autogen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.1 autogen usage help (-?) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.2 templ-dirs option (-L) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.3 override-tpl option (-T) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.4 lib-template option (-l) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.5 base-name option (-b) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.6 definitions option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.7 load-scheme option (-S) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.8 load-functions option (-F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.9 skip-suffix option (-s). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.10 select-suffix option (-o) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.11 source-time option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.12 no-fmemopen option (-m) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.13 equate option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.14 writable option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.15 loop-limit option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.16 timeout option (-t) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.17 trace option. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.18 trace-out option. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.19 show-defs option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.20 define option (-D) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.21 undefine option (-U) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68