19. V8 m4 Configuration
Contents:
V8 sendmail provides an easy way to create a custom configuration file for your site. In the cf subdirectory of the V8 sendmail source distribution you will find a file named README . It contains easy-to-understand, step-by-step instructions that allow you to create a custom configuration file for your site. This chapter supplements that file. 19.1 The m4 PreprocessorCreating a configuration file with m4 (1) is simplicity itself. The m4 (1) program is a macro preprocessor that produces a sendmail configuration file by processing a file whose name ends in .mc (for m acro c onfiguration). That is, it processes (reads) its input and gathers definitions of macros, then replaces those macros with their values and outputs the result. This use of macros is much the same as that described in Section 7.1, "Overview" , except that m4 's rules are different. With m4 , macros are defined (given values) like this:
define(
Here, the
There must be no space between the To illustrate, consider this one-line m4 source file named /tmp/x :
input text to be converted define(A,B)A the m4 definition
When
m4
is run to process this file, the output produced shows
that
%
19.1.1 m4 is greedy
The
m4
program is greedy. That is, if a
define(A,B) define(A,C) A B
Here, the first line assigns the value
C C To prevent this kind of greedy behavior (and to prevent the confusion it can create), you may quote an item to prevent m4 from interpreting it. zzz You quote with m4 by surrounding each item with left and right single quotes:
define(A,B) define(`A',C) A B
Here, the first line defines
C B
Although it is not strictly necessary,
we recommend that all
define(`A',`B') define(`A',`C') A B This is the form that we use when illustrating m4 throughout this book. 19.1.2 m4 and dnl
Another problem with
m4
is that it replaces its commands
with empty lines. The above
a blank line a blank line A B
To suppress this insertion of blank lines, you can use the special
m4
command
define(`A',`B')
You can use 19.1.3 m4 and arguments
When an
m4
macro name is immediately followed by a right parenthesis,
it is treated like a function call. Arguments given to it in that role
are used to replace
define(`CONCAT',`$1$2$3')dnl and then later used like this:
CONCAT(`host', `.', `domain')
The result will be that
host.domain Macro arguments are used to create such techniques as FEATURE() and OSTYPE(), which are described later in this chapter. 19.1.4 m4 diversions
One of the
m4
program's strengths is its ability to divide its input
into different parts and to later reassemble them in a more logical
fashion. Consider, for example, the desire to output all options together.
One way to do this is with the
m4
program's
divert(1)dnl O ALIASFILE=/etc/aliases divert(2)dnl Pfirst-class=0 divert(1)dnl O OperatorChars=.:%@!^/[]+ undivert(1)dnl undivert(2)dnl
Here, the
The
O ALIASFILE=/etc/aliases O OperatorChars=.:%@!^/[]+ Pfirst-class=0 The diversions used by sendmail 's m4 technique are listed in Table 19.1 . In general, the macros listed should be used in place of diversion numbers because the meaning of those numbers may be changed in future versions of sendmail .
|
|