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.
Creating 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:
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
is run to process this file, the output produced shows
define(A,B) define(A,C) A B
Here, the first line assigns the value
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
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.
Another problem with
is that it replaces its commands
with empty lines. The above
a blank line a blank line A B
You can use
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
and then later used like this:
CONCAT(`host', `.', `domain')
The result will be that
Macro arguments are used to create such techniques as FEATURE() and OSTYPE(), which are described later in this chapter.
One of the
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
divert(1)dnl O ALIASFILE=/etc/aliases divert(2)dnl Pfirst-class=0 divert(1)dnl O OperatorChars=.:%@!^/+ undivert(1)dnl undivert(2)dnl
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 .