home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


sendmail

sendmailSearch this book
Previous: 19.1 The m4 Preprocessor Chapter 19
V8 m4 Configuration
Next: 19.3 The Minimal mc File
 

19.2 Build with m4

The process of building a sendmail configuration file begins by creating a file of m4 statements. Traditionally, the suffix for such files is .mc . The cf/cf directory contains examples of many mc files. Of special interest are those that begin with generic , for these can serve as boilerplates in developing your own mc files:

generic-bsd4.4.mc       generic-solaris2.mc
generic-hpux10.mc       generic-sunos4.1.mc
generic-hpux9.mc        generic-ultrix4.mc
generic-osf1.mc

All mc files require specific minimal statements. For a SunOS 4.1.4 site on the Internet, for example, the following are minimal:

OSTYPE(sunos4.1)dnl	
<- see 
Section 19.3.1, "OSTYPE()"


MAILER(local)dnl		
<- see 
Section 19.3.2


MAILER(smtp)dnl		
<- see 
Section 19.3.2

To build a configuration file from these statements, you would place them into a file, say localsun.mc , then run the following command:

% 

m4  ../m4/cf.m4 localsun.mc > sendmail.cf

Here, the ../m4/cf.m4 tells m4 where to look for its default configuration file information.

If you are using an old version of m4 , the following error message will be printed:

You need a newer version of M4, at least as new as
System V or GNU
m4: file not found: NoSuchFile

Just as the messages says, you need a newer version of m4 . (The third line is just a result of forcing m4 to fail and may be safely ignored.) In our localsun.mc example we would need to rerun it as

% 

/usr/5bin/m4  ../m4/cf.m4 localsun.mc > sendmail.cf


  
-^

  
System V version of m4

Another cause of failure could be that the ../m4/cf.m4 file was not where you thought it was. Various versions of m4 print this error in different ways:

/usr/5bin/m4:-:1 can't open file                 
<- SysV m4

m4: ../m4/cf.m4: No such file or directory       
<- GNU m4

m4: file not found: ../m4/cf.m4                  
<- BSD m4

One possible reason for this error might be that you are developing your mc file somewhere other than in the cf/cf directory. [1] The solution is to use a full pathname to cf.m4 or to replace that expression on the command line with a shell variable.

[1] This is actually a good idea. It prevents new sendmail distributions from clobbering your mc files.

After you have successfully produced a "first draft" of your configuration file, you can edit localsun.mc and add features as you need them. Many possibilities are described in the rest of this chapter.

19.2.1 Maintain local files with _CF_DIR_

It can be advantageous to maintain all the files that make up your local m4 configuration separately from the sendmail distribution. This prevents new releases of sendmail from clobbering your source files. It also allows you to maintain configuration information more conveniently (perhaps under rcs (1) control) and to use programs like make (1) to simplify configuring and installation.

Most modern versions of m4 allow you to define macros on the command line, and one such macro is recognized internally by the m4 technique:

_CF_DIR_

This macro tells m4 where the m4/cf.m4 file described above is located. This macro needs to be set to the cf directory under the sendmail source distribution, and it needs to end in a slash character. For example, GNU m4 version 1.2 allows this:

% 

setenv CFDIR /usr/local/src/mail/sendmail/cf/


% 

/usr/local/gnu/bin/m4 -D_CF_DIR_=${CFDIR} ${CFDIR}m4/cf.m4 localsun.mc \


    > sendmail.cf

Notice that we store the value for _CF_DIR_ in an environmental variable. [2] If your version of m4 lacks this ability, you should consider upgrading.

[2] Note that gnu m4 can figure out the _CF_DIR_ path itself from the path of the cf.m4 file. We include _CF_DIR_ here for example purposes.

By using the _CF_DIR_ macro, configuration and installation can be further simplified by using make (1). To illustrate, consider the following few lines from a Makefile on a SunOS system:

M4=/usr/local/gnu/bin/m4
CFDIR=/usr/local/src/mail/sendmail/cf/
localsun: localsun.mc
        $(M4) -D_CF_DIR_=$(CFDIR) $(CFDIR)/m4/cf.m4 localsun.mc > sendmail.cf

With this Makefile the above two complex command lines are reduced to a single, simple command line:

% 

make


Previous: 19.1 The m4 Preprocessor sendmail Next: 19.3 The Minimal mc File
19.1 The m4 Preprocessor Book Index 19.3 The Minimal mc File