Полезная информация


sendmailSearch this book
Previous: 18.3 Obtain the SourceChapter 18
Compile and Install sendmail
Next: 18.5 Run Make

18.4 Tuning Makefile

The make(1) program is used to compile and install sendmail. The makesendmail script not only created an obj.* working directory, it also copied an appropriate Makefile into that directory. [4] Before changing anything in Makefile, you should cd into your object directory and change the permissions of Makefile so that it is writable by you:

[4] Actually, it created a symbolic link called Makefile that points to the appropriate file in the ../Makefiles directory.

% cd obj.*
% mv Makefile Makefile.orig
% cp Makefile.orig Makefile
% chmod 644 Makefile

Makefile is tuned by defining or redefining directives (shown in Table 18.1 that begin lines in that file.

Table 18.1: Makefile Directives That You May Customize
DBMDEF=Section 18.4.1, "DBMDEF="Which database libraries to use
ENVDEF=Section 18.4.2, "ENVDEF="Compiler -D switches, such as -D_AIX3
INCDIRS=Section 18.4.3, "INCDIRS="Compiler -I switches, such as -I../db/include
LDOPTS=Section 18.4.4, "LDOPTS="Linker options, such as -Bstatic for SunOS
LIBDIRS=Section 18.4.5, "LIBDIRS="Linker -L switches, such as -L/usr/local/lib
LIBS=Section 18.4.6, "LIBS="Linker -l libraries, such as -ldbm
BINDIR=Section 18.4.7, "BINDIR="Where to install sendmail
STDIR=Section 18.4.8, "STDIR="Where the sendmail.st file goes
HFDIR=Section 18.4.9, "HFDIR="Where the sendmail.hf file goes
OBJADD=Section 18.4.10, "OBJADD="Object files that need to be linked in

We will discuss each of these macros shortly but first note that, in general, you should never have to modify anything after the "end" line (shown in the following example). The only exception might be special requirements created by porting sendmail to a new platform.

###################  end of user configuration flags  ######################

Finally, before changing anything inside Makefile, be sure to read src/READ_ME. It always contains the latest information about building sendmail. In this book we are forced to speak in generalities, whereas the src/READ_ME file discusses operating systems, compilers, and hardware in specific detail.

18.4.1 DBMDEF=

The DBMDEF= directive defines the database library support you want. The currently available choices are listed in Table 18.2. Details are given in the indicated section.

Table 18.2: Define for Database Support
AUTO_NIS_ALIASESSection 18.8.1, AUTO-NIS-ALIASESYesAdd fallback alias techniques
HESIODSection 18.8.10, HESIODYesSupport hesiod database maps
LDAPMAPSection 18.8.15, LDAPMAPNoEnable use of ldap databases
NDBMSection 18.8.24, NDBMYesSupport UNIX ndbm(3) Databases[6]
NETINFOSection 18.8.27, NETINFOYesSupport NeXT netinfo(3) databases
NEWDBSection 18.8.28, NEWDBYesSupport db(3), both hash and btree forms
NISSection 18.8.29, NISYesSupport nis maps
NISPLUSSection 18.8.30, NISPLUSYesSupport nisplus maps
OLD_NEWDBSection 18.8.33, OLD-NEWDBn/aSupport the old form of db(3)
UDB_DEFAULT_SPECSection 18.8.53, UDB-DEFAULT-SPECn/aDefault User Database location
USERDBSection 18.8.54, USERDBn/aSupport the User Database

[5] Note that the old dbm(3) form of database is no longer supported.

[6] If yes, this database format supports aliasing.

Either NDBM or NEWDB must be defined, or sendmail will read the aliases into its symbol table every time it starts. This will make sendmail crawl and is not recommended.

External databases can be extremely valuable, especially in providing easy solutions for complex problems. Therefore we recommend that you include a definition for all databases that your system supports, even if you don't immediately foresee a need for them.

Below, we illustrate the selection of two forms of database:


When these two forms are selected, old databases are read by using NDBM, but new databases are created by using NEWDB. Read src/READ_ME for details about, and exceptions to, this transition process.

18.4.2 ENVDEF=

The ENVDEF= directive is used primarily to specify code that should either be specially included or excluded. The following example shows support for identd(8) being excluded from the compiled binary:


Note that, once excluded, support cannot easily be included later by using options. But it may be better to turn some facilities, such as identd(8), off and on with options rather than compiling them out (see Section, "Timeout.ident" for a description of the TimeOut.ident option). In Table 18.3 (see Section 18.8) the third column indicates whether it is appropriate to redefine a particular macro in your Makefile. Where appropriate, most will be defined with this ENVDEF= directive.

The ENVDEF= directive can also be used to define operating specific support. For example,


Here, support for Sun's Solaris 2.5.1 operating system is being included. In general, operating support is already included in the Makefile selected for your system. You will have only to redefine this if you are porting to a completely new operating system.

18.4.3 INCDIRS=

The INCDIRS= directive defines the directories searched (using the compiler's -I switch) for #include files. In general this will be empty unless you are using libraries that are not normally used. For example, you may have installed the db(3) library in /usr/local/lib and its corresponding include files in /usr/local/include/db. In this case you would define


The -I will be passed to the C compiler. The -L will be passed to the loader.

Many Makefiles specify /usr/sww in these lines. If you don't need local include files or libraries, you can leave the /usr/sww in place without harm. [7]

[7] The sww stands for SoftWare Warehouse. This scheme was used at U.C. Berkeley as a large centrally maintained /usr/local partition.

18.4.4 LDOPTS=

The LDOPTS= directive defines operating system-specific loader options. For example, on SunOS machines the following is recommended:

LDOPTS=      -Bstatic

This tells the loader to exclude dynamic library support for better security.

18.4.5 LIBDIRS=

The LIBDIRS= directive defines the directories searched (using the loader's -L switch). The libraries in these directories are searched before the standard system libraries. An example of its use is given in Section 18.4.3 above.

18.4.6 LIBS=

The LIBS= directive lists additional libraries by name (using the loader's -l switch) to link against. All Makefile files have a default for this line. The one for Ultrix looks like this:

LIBS=   -ldb -lresolv -l44bsd

It is likely that you will have to add or change libraries in this list depending on your architecture and operating system. To discover which you need, run make(1) (see the next section) and observe which routines the linker reports as missing. The -l44bsd is required only if you are using Paul Vixie's version of -lresolv as supplied with BIND 4.9.

18.4.7 BINDIR=

The BINDIR= directive defines the location (directory) where the sendmail binary will be installed. It is very unlikely that you will ever have to change this from the value predefined for you in your Makefile. One exception might be if you are installing a new sendmail in parallel with the existing one. In that instance you might use

ENVDEF= -D_PATH_SENDMAILCF=/usr/tests/sendmail.cf \

The STDIR= and HFDIR= are described below. The ENVDEF= tells sendmail where its configuration and pid files will be found (see Section 18.8.34, PATH...).

18.4.8 STDIR=

The STDIR= directive defines the location (directory) where the sendmail program's statistics file will be found (see Section 26.2.1, "The sendmail.st File" for a description of this file). It is very unlikely that you will ever have to change this from the value that is predefined for you in your Makefile.

18.4.9 HFDIR=

The HFDIR= directive defines the location (directory) where the sendmail program's SMTP-help file will be found (see Section 34.8.28, HelpFile (H) for a description of the HelpFile option and this file). It is very unlikely that you will ever have to change this from the value that is predefined for you in your Makefile.

18.4.10 OBJADD=

The OBJADD= directive defines additional object files that need to be included in the sendmail program. It is very unlikely that you will ever have to change this from the value that is predefined for you in your Makefile. One exception might be if you need to replace a standard C library function with one that was customized to satisfy some local need. For example, consider a replacement for the syslog(3) routine. First place a copy of syslog.c in the src directory. Then run:

% makesendmail -n

which will create an obj.* directory and populate it with symbolic links. [8] Finally, edit your Makefile and syslog.o to the OBJADD= directive:

[8] If you have already run makesendmail, running it again will not create the link. Instead, you will need to soft-link it by hand yourself.


This will cause the syslog.c file to be compiled to produce the needed syslog.o and will cause that syslog.o to be linked in with the sendmail binary.

Previous: 18.3 Obtain the SourcesendmailNext: 18.5 Run Make
18.3 Obtain the SourceBook Index18.5 Run Make