2001-02-22 04:17:33 +00:00
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
|
|
|
# This Makefile provides an easy way to generate the configuration
|
|
|
|
# file and database maps for the sendmail(8) daemon.
|
|
|
|
#
|
|
|
|
# The user-driven targets are:
|
|
|
|
#
|
|
|
|
# all - Build cf, maps and aliases
|
|
|
|
# cf - Build the .cf file from .mc file
|
|
|
|
# maps - Build the feature maps
|
|
|
|
# aliases - Build the sendmail aliases
|
|
|
|
# install - Install the .cf file as /etc/mail/sendmail.cf
|
|
|
|
# start - Start the sendmail daemon with the flags defined in
|
|
|
|
# /etc/defaults/rc.conf or /etc/rc.conf
|
|
|
|
# stop - Stop the sendmail daemon
|
|
|
|
# restart - Restart the sendmail daemon
|
|
|
|
#
|
|
|
|
# Calling `make' will generate the updated versions when either the
|
|
|
|
# aliases or one of the map files were changed.
|
|
|
|
#
|
|
|
|
# A `make install` is only necessary after modifying the .mc file. In
|
|
|
|
# this case one would normally also call `make restart' to allow the
|
|
|
|
# running sendmail to pick up the changes as well.
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# This makefile uses `freebsd.mc' as the default .mc file. This can
|
|
|
|
# be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.:
|
|
|
|
#
|
|
|
|
# SENDMAIL_MC=/etc/mail/myconfig.mc
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# The Makefile knows about the following maps:
|
|
|
|
# access, bitdomain, domaintable, genericstable, mailertable, userdb,
|
|
|
|
# uucpdomain, virtusertable
|
|
|
|
#
|
1997-10-19 16:40:10 +00:00
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
SENDMAIL_MC?= freebsd.mc
|
2001-02-28 04:03:51 +00:00
|
|
|
INSTALL_CF= ${SENDMAIL_MC:R}.cf
|
1997-10-19 16:40:10 +00:00
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
SENDMAIL_ALIASES?= /etc/mail/aliases
|
2000-03-12 22:08:35 +00:00
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
|
|
|
# This is the directory where the sendmail configuration files are
|
|
|
|
# located.
|
|
|
|
#
|
|
|
|
.if exists(/usr/share/sendmail/cf)
|
|
|
|
SENDMAIL_CF_DIR?= /usr/share/sendmail/cf
|
|
|
|
.elif exists(/usr/src/contrib/sendmail/cf)
|
|
|
|
SENDMAIL_CF_DIR?= /usr/src/contrib/sendmail/cf
|
|
|
|
.endif
|
2000-03-12 22:08:35 +00:00
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
|
|
|
# The pid is used to stop and restart the running daemon.
|
|
|
|
#
|
|
|
|
SENDMAIL_PIDFILE?= /var/run/sendmail.pid
|
2000-03-12 22:08:35 +00:00
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
|
|
|
# Some useful programs we need.
|
|
|
|
#
|
|
|
|
SENDMAIL?= /usr/sbin/sendmail
|
|
|
|
MAKEMAP?= /usr/sbin/makemap
|
|
|
|
M4?= /usr/bin/m4
|
|
|
|
KILL?= /bin/kill
|
2000-08-12 22:39:25 +00:00
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
# Set a reasonable default
|
|
|
|
.MAIN: all
|
2000-03-12 22:08:35 +00:00
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# The Makefile picks up the list of files from SENDMAIL_MAP_SRC and
|
|
|
|
# stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file
|
2001-04-01 22:54:15 +00:00
|
|
|
# exists in the current directory. SENDMAIL_MAP_TYPE is the database
|
|
|
|
# type to use when calling makemap.
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
|
|
|
SENDMAIL_MAP_SRC+= mailertable domaintable bitdomain uucpdomain \
|
2001-04-01 22:48:07 +00:00
|
|
|
genericstable virtusertable access
|
2001-02-22 04:17:33 +00:00
|
|
|
SENDMAIL_MAP_OBJ=
|
2001-04-01 22:54:15 +00:00
|
|
|
SENDMAIL_MAP_TYPE?= hash
|
2000-03-12 22:08:35 +00:00
|
|
|
|
2001-04-01 22:48:07 +00:00
|
|
|
.for _f in ${SENDMAIL_MAP_SRC} userdb
|
2001-02-22 04:17:33 +00:00
|
|
|
.if exists(${_f})
|
|
|
|
SENDMAIL_MAP_OBJ+= ${_f}.db
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
#
|
|
|
|
# The makemap command is used to generate a hashed map from the textfile.
|
|
|
|
#
|
|
|
|
.for _f in ${SENDMAIL_MAP_SRC}
|
|
|
|
.if (exists(${_f}.sample) && !exists(${_f}))
|
|
|
|
${_f}: ${_f}.sample
|
|
|
|
sed -e 's/^/#/' < ${.OODATE} > ${.TARGET}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
${_f}.db: ${_f}
|
2001-04-01 22:54:15 +00:00
|
|
|
${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE}
|
2001-02-22 04:17:33 +00:00
|
|
|
.endfor
|
|
|
|
|
2001-04-01 22:48:07 +00:00
|
|
|
userdb.db: userdb
|
|
|
|
${MAKEMAP} btree ${.TARGET} < ${.OODATE}
|
|
|
|
|
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
|
|
|
# The .cf file needs to be recreated if the templates were modified.
|
|
|
|
#
|
|
|
|
M4FILES!= find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print
|
|
|
|
|
|
|
|
#
|
|
|
|
# M4(1) is used to generate the .cf file from the .mc file.
|
|
|
|
#
|
|
|
|
.SUFFIXES: .cf .mc
|
|
|
|
|
|
|
|
.mc.cf: ${M4FILES}
|
|
|
|
${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_CF_DIR}/m4/cf.m4 \
|
|
|
|
${@:R}.mc > ${.TARGET}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Aliases are handled separately since they normally reside in /etc
|
|
|
|
# and can be rebuild without the help of makemap.
|
|
|
|
#
|
|
|
|
${SENDMAIL_ALIASES}.db: ${SENDMAIL_ALIASES}
|
|
|
|
${SENDMAIL} -bi
|
|
|
|
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
|
|
|
|
all: cf maps aliases
|
2000-03-12 22:08:35 +00:00
|
|
|
|
|
|
|
clean:
|
2001-02-22 04:17:33 +00:00
|
|
|
|
|
|
|
depend:
|
|
|
|
|
2001-02-28 04:03:51 +00:00
|
|
|
cf: ${INSTALL_CF}
|
2001-02-22 04:17:33 +00:00
|
|
|
|
|
|
|
maps: ${SENDMAIL_MAP_OBJ}
|
|
|
|
|
|
|
|
aliases: ${SENDMAIL_ALIASES}.db
|
|
|
|
|
2001-02-28 04:03:51 +00:00
|
|
|
install: ${INSTALL_CF}
|
|
|
|
${INSTALL} -c -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf
|
2001-02-22 04:17:33 +00:00
|
|
|
|
|
|
|
start:
|
2001-03-13 20:58:39 +00:00
|
|
|
(. /etc/defaults/rc.conf; source_rc_confs; \
|
2001-02-22 04:17:33 +00:00
|
|
|
if [ "$${sendmail_enable}" = "YES" -a -r /etc/mail/sendmail.cf ];\
|
|
|
|
then \
|
|
|
|
${SENDMAIL} $${sendmail_flags}; \
|
|
|
|
fi \
|
|
|
|
)
|
|
|
|
|
|
|
|
stop:
|
|
|
|
${KILL} -TERM `head -1 ${SENDMAIL_PIDFILE}`
|
|
|
|
|
|
|
|
restart:
|
|
|
|
${KILL} -HUP `head -1 ${SENDMAIL_PIDFILE}`
|