1# 2# $FreeBSD$ 3# 4# This Makefile provides an easy way to generate the configuration 5# file and database maps for the sendmail(8) daemon. 6# 7# The user-driven targets are: 8# 9# all - Build cf, maps and aliases 10# cf - Build the .cf file from .mc file 11# maps - Build the feature maps 12# aliases - Build the sendmail aliases 13# install - Install the .cf file as /etc/mail/sendmail.cf 14# 15# For acting on both the MTA daemon and MSP queue running daemon: 16# start - Start both the sendmail MTA daemon and MSP queue running 17# daemon with the flags defined in /etc/defaults/rc.conf or 18# /etc/rc.conf 19# stop - Stop both the sendmail MTA daemon and MSP queue running 20# daemon 21# restart - Restart both the sendmail MTA daemon and MSP queue running 22# daemon 23# 24# For acting on just the MTA daemon: 25# start-mta - Start the sendmail MTA daemon with the flags defined in 26# /etc/defaults/rc.conf or /etc/rc.conf 27# stop-mta - Stop the sendmail MTA daemon 28# restart-mta - Restart the sendmail MTA daemon 29# 30# For acting on just the MSP queue running daemon: 31# start-mspq - Start the sendmail MSP queue running daemon with the 32# flags defined in /etc/defaults/rc.conf or /etc/rc.conf 33# stop-mspq - Stop the sendmail MSP queue running daemon 34# restart-mspq - Restart the sendmail MSP queue running daemon 35# 36# Calling `make' will generate the updated versions when either the 37# aliases or one of the map files were changed. 38# 39# A `make install` is only necessary after modifying the .mc file. In 40# this case one would normally also call `make restart' to allow the 41# running sendmail to pick up the changes as well. 42# 43# ------------------------------------------------------------------------ 44# This Makefile uses `<HOSTNAME>.mc' as the default MTA .mc file. This 45# can be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.: 46# 47# SENDMAIL_MC=/etc/mail/myconfig.mc 48# 49# If '<HOSTNAME>.mc' does not exist, it is created using 'freebsd.mc' 50# as a template. 51# 52# It also uses '<HOSTNAME>.submit.mc' as the default mail submission .mc 53# file. This can be changed by defining SENDMAIL_SUBMIT_MC in 54# /etc/make.conf, e.g.: 55# 56# SENDMAIL_SUBMIT_MC=/etc/mail/mysubmit.mc 57# 58# If '<HOSTNAME>.submit.mc' does not exist, it is created using 59# 'freebsd.submit.mc' as a template. 60# ------------------------------------------------------------------------ 61# 62# The Makefile knows about the following maps: 63# access, bitdomain, domaintable, genericstable, mailertable, userdb, 64# uucpdomain, virtusertable 65# 66 67.ifndef SENDMAIL_MC 68SENDMAIL_MC!= hostname 69SENDMAIL_MC:= ${SENDMAIL_MC}.mc 70 71${SENDMAIL_MC}: 72 cp -f freebsd.mc ${SENDMAIL_MC} 73.endif 74 75.ifndef SENDMAIL_SUBMIT_MC 76SENDMAIL_SUBMIT_MC!= hostname 77SENDMAIL_SUBMIT_MC:= ${SENDMAIL_SUBMIT_MC}.submit.mc 78 79${SENDMAIL_SUBMIT_MC}: 80 cp -f freebsd.submit.mc ${SENDMAIL_SUBMIT_MC} 81.endif 82 83INSTALL_CF= ${SENDMAIL_MC:R}.cf 84 85.ifndef SENDMAIL_SET_USER_ID 86INSTALL_SUBMIT_CF= ${SENDMAIL_SUBMIT_MC:R}.cf 87.endif 88 89SENDMAIL_ALIASES?= /etc/mail/aliases 90 91# 92# This is the directory where the sendmail configuration files are 93# located. 94# 95.if exists(/usr/share/sendmail/cf) 96SENDMAIL_CF_DIR?= /usr/share/sendmail/cf 97.elif exists(/usr/src/contrib/sendmail/cf) 98SENDMAIL_CF_DIR?= /usr/src/contrib/sendmail/cf 99.endif 100 101# 102# The sendmail startup script 103# 104SENDMAIL_START_SCRIPT?= /etc/rc.sendmail 105 106# 107# Some useful programs we need. 108# 109SENDMAIL?= /usr/sbin/sendmail 110MAKEMAP?= /usr/sbin/makemap 111M4?= /usr/bin/m4 112 113# Permissions for generated maps 114SENDMAIL_MAP_PERMS?= 0640 115 116# Set a reasonable default 117.MAIN: all 118 119# 120# ------------------------------------------------------------------------ 121# 122# The Makefile picks up the list of files from SENDMAIL_MAP_SRC and 123# stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file 124# exists in the current directory. SENDMAIL_MAP_TYPE is the database 125# type to use when calling makemap. 126# 127SENDMAIL_MAP_SRC+= mailertable domaintable bitdomain uucpdomain \ 128 genericstable virtusertable access 129SENDMAIL_MAP_OBJ= 130SENDMAIL_MAP_TYPE?= hash 131 132.for _f in ${SENDMAIL_MAP_SRC} userdb 133.if exists(${_f}) 134SENDMAIL_MAP_OBJ+= ${_f}.db 135.endif 136.endfor 137 138# 139# The makemap command is used to generate a hashed map from the textfile. 140# 141.for _f in ${SENDMAIL_MAP_SRC} 142.if (exists(${_f}.sample) && !exists(${_f})) 143${_f}: ${_f}.sample 144 sed -e 's/^/#/' < ${.OODATE} > ${.TARGET} 145.endif 146 147${_f}.db: ${_f} 148 ${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE} 149 chmod ${SENDMAIL_MAP_PERMS} ${.TARGET} 150.endfor 151 152userdb.db: userdb 153 ${MAKEMAP} btree ${.TARGET} < ${.OODATE} 154 chmod ${SENDMAIL_MAP_PERMS} ${.TARGET} 155 156 157# 158# The .cf file needs to be recreated if the templates were modified. 159# 160M4FILES!= find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print 161 162# 163# M4(1) is used to generate the .cf file from the .mc file. 164# 165.SUFFIXES: .cf .mc 166 167.mc.cf: ${M4FILES} 168 ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \ 169 ${SENDMAIL_CF_DIR}/m4/cf.m4 ${@:R}.mc > ${.TARGET} 170 171# 172# Aliases are handled separately since they normally reside in /etc 173# and can be rebuild without the help of makemap. 174# 175.for _f in ${SENDMAIL_ALIASES} 176${_f}.db: ${_f} 177 ${SENDMAIL} -bi -OAliasFile=${.ALLSRC} 178 chmod ${SENDMAIL_MAP_PERMS} ${.TARGET} 179.endfor 180 181# 182# ------------------------------------------------------------------------ 183# 184 185all: cf maps aliases 186 187clean: 188 189depend: 190 191cf: ${INSTALL_CF} ${INSTALL_SUBMIT_CF} 192 193.ifdef SENDMAIL_SET_USER_ID 194install: install-cf 195.else 196install: install-cf install-submit-cf 197.endif 198 199install-cf: ${INSTALL_CF} 200.if ${INSTALL_CF} != /etc/mail/sendmail.cf 201 ${INSTALL} -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf 202.endif 203 204 205install-submit-cf: ${INSTALL_SUBMIT_CF} 206.ifdef SENDMAIL_SET_USER_ID 207 @echo ">>> ERROR: You should not create a submit.cf file if you are using a" 208 @echo " set-user-ID sendmail binary (SENDMAIL_SET_USER_ID is set" 209 @echo " in make.conf)." 210 @false 211.else 212.if ${INSTALL_SUBMIT_CF} != /etc/mail/submit.cf 213 ${INSTALL} -m ${SHAREMODE} ${INSTALL_SUBMIT_CF} /etc/mail/submit.cf 214.endif 215.endif 216 217aliases: ${SENDMAIL_ALIASES:%=%.db} 218 219maps: ${SENDMAIL_MAP_OBJ} 220 221start start-mta start-mspq: 222 @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \ 223 echo -n 'Starting:'; \ 224 sh ${SENDMAIL_START_SCRIPT} $@; \ 225 echo '.'; \ 226 fi 227 228stop stop-mta stop-mspq: 229 @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \ 230 echo -n 'Stopping:'; \ 231 sh ${SENDMAIL_START_SCRIPT} $@; \ 232 echo '.'; \ 233 fi 234 235restart restart-mta restart-mspq: 236 @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \ 237 echo -n 'Restarting:'; \ 238 sh ${SENDMAIL_START_SCRIPT} $@; \ 239 echo '.'; \ 240 fi 241 242# User defined targets 243.if exists(Makefile.local) 244.include "Makefile.local" 245.endif 246 247# For the definition of $SHAREMODE 248.include <bsd.own.mk> 249