m4: Preprocessor features
2.2 Command line options for preprocessor features
==================================================
Several options allow 'm4' to behave more like a preprocessor. Macro
definitions and deletions can be made on the command line, the search
path can be altered, and the output file can track where the input came
from. These features occur with the following options:
'-D NAME[=VALUE]'
'--define=NAME[=VALUE]'
This enters NAME into the symbol table. If '=VALUE' is missing,
the value is taken to be the empty string. The VALUE can be any
string, and the macro can be defined to take arguments, just as if
it was defined from within the input. This option may be given
more than once; order with respect to file names is significant,
and redefining the same NAME loses the previous value.
'-I DIRECTORY'
'--include=DIRECTORY'
Make 'm4' search DIRECTORY for included files that are not found in
the current working directory. ⇒Search Path, for more
details. This option may be given more than once.
'-s'
'--synclines'
Generate synchronization lines, for use by the C preprocessor or
other similar tools. Order is significant with respect to file
names. This option is useful, for example, when 'm4' is used as a
front end to a compiler. Source file name and line number
information is conveyed by directives of the form '#line LINENUM
"FILE"', which are inserted as needed into the middle of the
output. Such directives mean that the following line originated or
was expanded from the contents of input file FILE at line LINENUM.
The '"FILE"' part is often omitted when the file name did not
change from the previous directive.
Synchronization directives are always given on complete lines by
themselves. When a synchronization discrepancy occurs in the
middle of an output line, the associated synchronization directive
is delayed until the next newline that does not occur in the middle
of a quoted string or comment.
define(`twoline', `1
2')
=>#line 2 "stdin"
=>
changecom(`/*', `*/')
=>
define(`comment', `/*1
2*/')
=>#line 5
=>
dnl no line
hello
=>#line 7
=>hello
twoline
=>1
=>#line 8
=>2
comment
=>/*1
=>2*/
one comment `two
three'
=>#line 10
=>one /*1
=>2*/ two
=>three
goodbye
=>#line 12
=>goodbye
'-U NAME'
'--undefine=NAME'
This deletes any predefined meaning NAME might have. Obviously,
only predefined macros can be deleted in this way. This option may
be given more than once; undefining a NAME that does not have a
definition is silently ignored. Order is significant with respect
to file names.