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
|
2002-03-28 03:30:27 +00:00
|
|
|
#
|
2002-04-05 02:30:49 +00:00
|
|
|
# For acting on both the MTA daemon and MSP queue running daemon:
|
|
|
|
# start - Start both the sendmail MTA daemon and MSP queue running
|
|
|
|
# daemon with the flags defined in /etc/defaults/rc.conf or
|
|
|
|
# /etc/rc.conf
|
|
|
|
# stop - Stop both the sendmail MTA daemon and MSP queue running
|
|
|
|
# daemon
|
|
|
|
# restart - Restart both the sendmail MTA daemon and MSP queue running
|
|
|
|
# daemon
|
|
|
|
#
|
|
|
|
# For acting on just the MTA daemon:
|
|
|
|
# start-mta - Start the sendmail MTA daemon with the flags defined in
|
|
|
|
# /etc/defaults/rc.conf or /etc/rc.conf
|
|
|
|
# stop-mta - Stop the sendmail MTA daemon
|
|
|
|
# restart-mta - Restart the sendmail MTA daemon
|
|
|
|
#
|
|
|
|
# For acting on just the MSP queue running daemon:
|
2002-03-28 03:30:27 +00:00
|
|
|
# start-mspq - Start the sendmail MSP queue running daemon with the
|
|
|
|
# flags defined in /etc/defaults/rc.conf or /etc/rc.conf
|
|
|
|
# stop-mspq - Stop the sendmail MSP queue running daemon
|
|
|
|
# restart-mspq - Restart the sendmail MSP queue running daemon
|
|
|
|
#
|
2001-02-22 04:17:33 +00:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------
|
2002-04-14 19:20:26 +00:00
|
|
|
# This Makefile uses `<HOSTNAME>.mc' as the default MTA .mc file. This
|
|
|
|
# can be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.:
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
2003-07-06 18:07:06 +00:00
|
|
|
# SENDMAIL_MC=/etc/mail/myconfig.mc
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
2001-05-15 16:01:40 +00:00
|
|
|
# If '<HOSTNAME>.mc' does not exist, it is created using 'freebsd.mc'
|
|
|
|
# as a template.
|
2002-04-14 19:20:26 +00:00
|
|
|
#
|
2003-07-06 19:17:04 +00:00
|
|
|
# It also uses '<HOSTNAME>.submit.mc' as the default mail submission .mc
|
|
|
|
# file. This can be changed by defining SENDMAIL_SUBMIT_MC in
|
|
|
|
# /etc/make.conf, e.g.:
|
2002-04-14 19:20:26 +00:00
|
|
|
#
|
2003-07-06 18:07:06 +00:00
|
|
|
# SENDMAIL_SUBMIT_MC=/etc/mail/mysubmit.mc
|
2003-07-06 19:17:04 +00:00
|
|
|
#
|
|
|
|
# If '<HOSTNAME>.submit.mc' does not exist, it is created using
|
|
|
|
# 'freebsd.submit.mc' as a template.
|
2001-02-22 04:17:33 +00:00
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# The Makefile knows about the following maps:
|
2019-02-04 02:18:27 +00:00
|
|
|
# access, authinfo, bitdomain, domaintable, genericstable, mailertable,
|
|
|
|
# userdb, uucpdomain, virtusertable
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
1997-10-19 16:40:10 +00:00
|
|
|
|
2001-05-15 16:01:40 +00:00
|
|
|
.ifndef SENDMAIL_MC
|
|
|
|
SENDMAIL_MC!= hostname
|
|
|
|
SENDMAIL_MC:= ${SENDMAIL_MC}.mc
|
|
|
|
|
2001-10-08 22:35:24 +00:00
|
|
|
${SENDMAIL_MC}:
|
2015-01-16 21:39:08 +00:00
|
|
|
${CP} freebsd.mc ${SENDMAIL_MC}
|
2001-05-15 16:01:40 +00:00
|
|
|
.endif
|
|
|
|
|
2003-07-06 19:17:04 +00:00
|
|
|
.ifndef SENDMAIL_SUBMIT_MC
|
|
|
|
SENDMAIL_SUBMIT_MC!= hostname
|
2004-06-06 17:28:31 +00:00
|
|
|
SENDMAIL_SUBMIT_MC:= ${SENDMAIL_SUBMIT_MC}.submit.mc
|
2003-07-06 19:17:04 +00:00
|
|
|
|
|
|
|
${SENDMAIL_SUBMIT_MC}:
|
2015-01-16 21:39:08 +00:00
|
|
|
${CP} freebsd.submit.mc ${SENDMAIL_SUBMIT_MC}
|
2003-07-06 19:17:04 +00:00
|
|
|
.endif
|
2002-04-14 19:20:26 +00:00
|
|
|
|
2001-02-28 04:03:51 +00:00
|
|
|
INSTALL_CF= ${SENDMAIL_MC:R}.cf
|
1997-10-19 16:40:10 +00:00
|
|
|
|
2002-04-14 19:20:26 +00:00
|
|
|
.ifndef SENDMAIL_SET_USER_ID
|
|
|
|
INSTALL_SUBMIT_CF= ${SENDMAIL_SUBMIT_MC:R}.cf
|
|
|
|
.endif
|
|
|
|
|
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
|
2002-04-04 07:42:12 +00:00
|
|
|
.elif exists(/usr/src/contrib/sendmail/cf)
|
|
|
|
SENDMAIL_CF_DIR?= /usr/src/contrib/sendmail/cf
|
2001-02-22 04:17:33 +00:00
|
|
|
.endif
|
2000-03-12 22:08:35 +00:00
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
2002-04-05 02:30:49 +00:00
|
|
|
# The sendmail startup script
|
2001-02-22 04:17:33 +00:00
|
|
|
#
|
2022-11-15 08:08:07 +00:00
|
|
|
SENDMAIL_START_SCRIPT?= /etc/rc.d/sendmail
|
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
|
2000-08-12 22:39:25 +00:00
|
|
|
|
2002-05-24 01:46:39 +00:00
|
|
|
# Permissions for generated maps
|
|
|
|
SENDMAIL_MAP_PERMS?= 0640
|
|
|
|
|
2001-02-22 04:17:33 +00:00
|
|
|
# Set a reasonable default
|
2003-07-06 18:07:06 +00:00
|
|
|
.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 \
|
2019-02-04 02:18:27 +00:00
|
|
|
genericstable virtusertable access authinfo
|
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}))
|
2003-07-06 18:07:06 +00:00
|
|
|
${_f}: ${_f}.sample
|
2001-02-22 04:17:33 +00:00
|
|
|
sed -e 's/^/#/' < ${.OODATE} > ${.TARGET}
|
|
|
|
.endif
|
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
${_f}.db: ${_f}
|
2001-04-01 22:54:15 +00:00
|
|
|
${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE}
|
2002-05-24 01:46:39 +00:00
|
|
|
chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
|
2001-02-22 04:17:33 +00:00
|
|
|
.endfor
|
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
userdb.db: userdb
|
2001-04-01 22:48:07 +00:00
|
|
|
${MAKEMAP} btree ${.TARGET} < ${.OODATE}
|
2002-05-24 01:46:39 +00:00
|
|
|
chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
|
2001-04-01 22:48:07 +00:00
|
|
|
|
|
|
|
|
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.
|
|
|
|
#
|
2003-07-06 18:07:06 +00:00
|
|
|
.SUFFIXES: .cf .mc
|
2001-02-22 04:17:33 +00:00
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
.mc.cf: ${M4FILES}
|
2001-07-23 01:33:54 +00:00
|
|
|
${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \
|
2003-07-06 18:07:06 +00:00
|
|
|
${SENDMAIL_CF_DIR}/m4/cf.m4 ${@:R}.mc > ${.TARGET}
|
2001-02-22 04:17:33 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Aliases are handled separately since they normally reside in /etc
|
|
|
|
# and can be rebuild without the help of makemap.
|
|
|
|
#
|
2003-02-08 21:55:31 +00:00
|
|
|
.for _f in ${SENDMAIL_ALIASES}
|
2003-07-06 18:07:06 +00:00
|
|
|
${_f}.db: ${_f}
|
2003-02-08 21:55:31 +00:00
|
|
|
${SENDMAIL} -bi -OAliasFile=${.ALLSRC}
|
2002-05-24 01:46:39 +00:00
|
|
|
chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
|
2003-02-08 21:55:31 +00:00
|
|
|
.endfor
|
2001-02-22 04:17:33 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
all: cf maps aliases
|
2000-03-12 22:08:35 +00:00
|
|
|
|
|
|
|
clean:
|
2001-02-22 04:17:33 +00:00
|
|
|
|
|
|
|
depend:
|
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
cf: ${INSTALL_CF} ${INSTALL_SUBMIT_CF}
|
2001-02-22 04:17:33 +00:00
|
|
|
|
2002-04-14 19:20:26 +00:00
|
|
|
.ifdef SENDMAIL_SET_USER_ID
|
|
|
|
install: install-cf
|
|
|
|
.else
|
|
|
|
install: install-cf install-submit-cf
|
|
|
|
.endif
|
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
install-cf: ${INSTALL_CF}
|
2002-04-14 19:20:26 +00:00
|
|
|
.if ${INSTALL_CF} != /etc/mail/sendmail.cf
|
2002-07-29 09:40:17 +00:00
|
|
|
${INSTALL} -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf
|
2002-04-14 19:20:26 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
install-submit-cf: ${INSTALL_SUBMIT_CF}
|
2002-02-17 22:12:57 +00:00
|
|
|
.ifdef SENDMAIL_SET_USER_ID
|
|
|
|
@echo ">>> ERROR: You should not create a submit.cf file if you are using a"
|
|
|
|
@echo " set-user-ID sendmail binary (SENDMAIL_SET_USER_ID is set"
|
|
|
|
@echo " in make.conf)."
|
|
|
|
@false
|
2002-04-14 19:20:26 +00:00
|
|
|
.else
|
|
|
|
.if ${INSTALL_SUBMIT_CF} != /etc/mail/submit.cf
|
2002-07-29 09:40:17 +00:00
|
|
|
${INSTALL} -m ${SHAREMODE} ${INSTALL_SUBMIT_CF} /etc/mail/submit.cf
|
2002-04-14 19:20:26 +00:00
|
|
|
.endif
|
2002-02-17 22:12:57 +00:00
|
|
|
.endif
|
2001-02-22 04:17:33 +00:00
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
aliases: ${SENDMAIL_ALIASES:%=%.db}
|
2001-02-22 04:17:33 +00:00
|
|
|
|
2003-07-06 18:07:06 +00:00
|
|
|
maps: ${SENDMAIL_MAP_OBJ}
|
2001-02-22 04:17:33 +00:00
|
|
|
|
2002-04-05 02:30:49 +00:00
|
|
|
start start-mta start-mspq:
|
|
|
|
@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
|
|
|
|
echo -n 'Starting:'; \
|
|
|
|
sh ${SENDMAIL_START_SCRIPT} $@; \
|
|
|
|
echo '.'; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
stop stop-mta stop-mspq:
|
|
|
|
@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
|
|
|
|
echo -n 'Stopping:'; \
|
|
|
|
sh ${SENDMAIL_START_SCRIPT} $@; \
|
|
|
|
echo '.'; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
restart restart-mta restart-mspq:
|
|
|
|
@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
|
|
|
|
echo -n 'Restarting:'; \
|
|
|
|
sh ${SENDMAIL_START_SCRIPT} $@; \
|
|
|
|
echo '.'; \
|
|
|
|
fi
|
2002-03-28 03:30:27 +00:00
|
|
|
|
2001-05-15 16:03:54 +00:00
|
|
|
# User defined targets
|
|
|
|
.if exists(Makefile.local)
|
|
|
|
.include "Makefile.local"
|
|
|
|
.endif
|
2002-04-23 17:08:08 +00:00
|
|
|
|
|
|
|
# For the definition of $SHAREMODE
|
|
|
|
.include <bsd.own.mk>
|