172847Sgshapiro# 250472Speter# $FreeBSD: releng/10.3/etc/mail/Makefile 130157 2004-06-06 17:28:31Z gshapiro $ 372847Sgshapiro# 472847Sgshapiro# This Makefile provides an easy way to generate the configuration 572847Sgshapiro# file and database maps for the sendmail(8) daemon. 672847Sgshapiro# 772847Sgshapiro# The user-driven targets are: 872847Sgshapiro# 972847Sgshapiro# all - Build cf, maps and aliases 1072847Sgshapiro# cf - Build the .cf file from .mc file 1172847Sgshapiro# maps - Build the feature maps 1272847Sgshapiro# aliases - Build the sendmail aliases 1372847Sgshapiro# install - Install the .cf file as /etc/mail/sendmail.cf 1493315Sgshapiro# 1593853Sgshapiro# For acting on both the MTA daemon and MSP queue running daemon: 1693853Sgshapiro# start - Start both the sendmail MTA daemon and MSP queue running 1793853Sgshapiro# daemon with the flags defined in /etc/defaults/rc.conf or 1893853Sgshapiro# /etc/rc.conf 1993853Sgshapiro# stop - Stop both the sendmail MTA daemon and MSP queue running 2093853Sgshapiro# daemon 2193853Sgshapiro# restart - Restart both the sendmail MTA daemon and MSP queue running 2293853Sgshapiro# daemon 2372847Sgshapiro# 2493853Sgshapiro# For acting on just the MTA daemon: 2593853Sgshapiro# start-mta - Start the sendmail MTA daemon with the flags defined in 2693853Sgshapiro# /etc/defaults/rc.conf or /etc/rc.conf 2793853Sgshapiro# stop-mta - Stop the sendmail MTA daemon 2893853Sgshapiro# restart-mta - Restart the sendmail MTA daemon 2993853Sgshapiro# 3093853Sgshapiro# For acting on just the MSP queue running daemon: 3193315Sgshapiro# start-mspq - Start the sendmail MSP queue running daemon with the 3293315Sgshapiro# flags defined in /etc/defaults/rc.conf or /etc/rc.conf 3393315Sgshapiro# stop-mspq - Stop the sendmail MSP queue running daemon 3493315Sgshapiro# restart-mspq - Restart the sendmail MSP queue running daemon 3593315Sgshapiro# 3672847Sgshapiro# Calling `make' will generate the updated versions when either the 3772847Sgshapiro# aliases or one of the map files were changed. 3872847Sgshapiro# 3972847Sgshapiro# A `make install` is only necessary after modifying the .mc file. In 4072847Sgshapiro# this case one would normally also call `make restart' to allow the 4172847Sgshapiro# running sendmail to pick up the changes as well. 4272847Sgshapiro# 4372847Sgshapiro# ------------------------------------------------------------------------ 4494676Sgshapiro# This Makefile uses `<HOSTNAME>.mc' as the default MTA .mc file. This 4594676Sgshapiro# can be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.: 4672847Sgshapiro# 47117286Sgshapiro# SENDMAIL_MC=/etc/mail/myconfig.mc 4872847Sgshapiro# 4976622Sgshapiro# If '<HOSTNAME>.mc' does not exist, it is created using 'freebsd.mc' 5076622Sgshapiro# as a template. 5194676Sgshapiro# 52117291Sgshapiro# It also uses '<HOSTNAME>.submit.mc' as the default mail submission .mc 53117291Sgshapiro# file. This can be changed by defining SENDMAIL_SUBMIT_MC in 54117291Sgshapiro# /etc/make.conf, e.g.: 5594676Sgshapiro# 56117286Sgshapiro# SENDMAIL_SUBMIT_MC=/etc/mail/mysubmit.mc 57117291Sgshapiro# 58117291Sgshapiro# If '<HOSTNAME>.submit.mc' does not exist, it is created using 59117291Sgshapiro# 'freebsd.submit.mc' as a template. 6072847Sgshapiro# ------------------------------------------------------------------------ 6172847Sgshapiro# 6272847Sgshapiro# The Makefile knows about the following maps: 6372847Sgshapiro# access, bitdomain, domaintable, genericstable, mailertable, userdb, 6472847Sgshapiro# uucpdomain, virtusertable 6572847Sgshapiro# 6639146Sbrian 6776622Sgshapiro.ifndef SENDMAIL_MC 6876622SgshapiroSENDMAIL_MC!= hostname 6976622SgshapiroSENDMAIL_MC:= ${SENDMAIL_MC}.mc 7076622Sgshapiro 7184684Sgshapiro${SENDMAIL_MC}: 7276622Sgshapiro cp freebsd.mc ${SENDMAIL_MC} 7376622Sgshapiro.endif 7476622Sgshapiro 75117291Sgshapiro.ifndef SENDMAIL_SUBMIT_MC 76117291SgshapiroSENDMAIL_SUBMIT_MC!= hostname 77130157SgshapiroSENDMAIL_SUBMIT_MC:= ${SENDMAIL_SUBMIT_MC}.submit.mc 7894676Sgshapiro 79117291Sgshapiro${SENDMAIL_SUBMIT_MC}: 80117291Sgshapiro cp freebsd.submit.mc ${SENDMAIL_SUBMIT_MC} 81117291Sgshapiro.endif 82117291Sgshapiro 8373209SgshapiroINSTALL_CF= ${SENDMAIL_MC:R}.cf 8430581Sjmb 8594676Sgshapiro.ifndef SENDMAIL_SET_USER_ID 8694676SgshapiroINSTALL_SUBMIT_CF= ${SENDMAIL_SUBMIT_MC:R}.cf 8794676Sgshapiro.endif 8894676Sgshapiro 8972847SgshapiroSENDMAIL_ALIASES?= /etc/mail/aliases 9057947Srwatson 9172847Sgshapiro# 9272847Sgshapiro# This is the directory where the sendmail configuration files are 9372847Sgshapiro# located. 9472847Sgshapiro# 9572847Sgshapiro.if exists(/usr/share/sendmail/cf) 9672847SgshapiroSENDMAIL_CF_DIR?= /usr/share/sendmail/cf 9793765Sru.elif exists(/usr/src/contrib/sendmail/cf) 9893765SruSENDMAIL_CF_DIR?= /usr/src/contrib/sendmail/cf 9972847Sgshapiro.endif 10057947Srwatson 10172847Sgshapiro# 10293853Sgshapiro# The sendmail startup script 10372847Sgshapiro# 10493853SgshapiroSENDMAIL_START_SCRIPT?= /etc/rc.sendmail 10557947Srwatson 10672847Sgshapiro# 10772847Sgshapiro# Some useful programs we need. 10872847Sgshapiro# 10972847SgshapiroSENDMAIL?= /usr/sbin/sendmail 11072847SgshapiroMAKEMAP?= /usr/sbin/makemap 11172847SgshapiroM4?= /usr/bin/m4 11264567Sgshapiro 11397200Sgshapiro# Permissions for generated maps 11497200SgshapiroSENDMAIL_MAP_PERMS?= 0640 11597200Sgshapiro 11672847Sgshapiro# Set a reasonable default 117117286Sgshapiro.MAIN: all 11857947Srwatson 11972847Sgshapiro# 12072847Sgshapiro# ------------------------------------------------------------------------ 12172847Sgshapiro# 12272847Sgshapiro# The Makefile picks up the list of files from SENDMAIL_MAP_SRC and 12372847Sgshapiro# stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file 12475074Sgshapiro# exists in the current directory. SENDMAIL_MAP_TYPE is the database 12575074Sgshapiro# type to use when calling makemap. 12672847Sgshapiro# 12772847SgshapiroSENDMAIL_MAP_SRC+= mailertable domaintable bitdomain uucpdomain \ 12875073Sgshapiro genericstable virtusertable access 12972847SgshapiroSENDMAIL_MAP_OBJ= 13075074SgshapiroSENDMAIL_MAP_TYPE?= hash 13157947Srwatson 13275073Sgshapiro.for _f in ${SENDMAIL_MAP_SRC} userdb 13372847Sgshapiro.if exists(${_f}) 13472847SgshapiroSENDMAIL_MAP_OBJ+= ${_f}.db 13572847Sgshapiro.endif 13672847Sgshapiro.endfor 13757947Srwatson 13872847Sgshapiro# 13972847Sgshapiro# The makemap command is used to generate a hashed map from the textfile. 14072847Sgshapiro# 14172847Sgshapiro.for _f in ${SENDMAIL_MAP_SRC} 14272847Sgshapiro.if (exists(${_f}.sample) && !exists(${_f})) 143117286Sgshapiro${_f}: ${_f}.sample 14472847Sgshapiro sed -e 's/^/#/' < ${.OODATE} > ${.TARGET} 14572847Sgshapiro.endif 14672847Sgshapiro 147117286Sgshapiro${_f}.db: ${_f} 14875074Sgshapiro ${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE} 14997200Sgshapiro chmod ${SENDMAIL_MAP_PERMS} ${.TARGET} 15072847Sgshapiro.endfor 15172847Sgshapiro 152117286Sgshapirouserdb.db: userdb 15375073Sgshapiro ${MAKEMAP} btree ${.TARGET} < ${.OODATE} 15497200Sgshapiro chmod ${SENDMAIL_MAP_PERMS} ${.TARGET} 15575073Sgshapiro 15675073Sgshapiro 15772847Sgshapiro# 15872847Sgshapiro# The .cf file needs to be recreated if the templates were modified. 15972847Sgshapiro# 16072847SgshapiroM4FILES!= find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print 16172847Sgshapiro 16272847Sgshapiro# 16372847Sgshapiro# M4(1) is used to generate the .cf file from the .mc file. 16472847Sgshapiro# 165117286Sgshapiro.SUFFIXES: .cf .mc 16672847Sgshapiro 167117286Sgshapiro.mc.cf: ${M4FILES} 16880175Sgshapiro ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \ 169117286Sgshapiro ${SENDMAIL_CF_DIR}/m4/cf.m4 ${@:R}.mc > ${.TARGET} 17072847Sgshapiro 17172847Sgshapiro# 17272847Sgshapiro# Aliases are handled separately since they normally reside in /etc 17372847Sgshapiro# and can be rebuild without the help of makemap. 17472847Sgshapiro# 175110576Sgshapiro.for _f in ${SENDMAIL_ALIASES} 176117286Sgshapiro${_f}.db: ${_f} 177110576Sgshapiro ${SENDMAIL} -bi -OAliasFile=${.ALLSRC} 17897200Sgshapiro chmod ${SENDMAIL_MAP_PERMS} ${.TARGET} 179110576Sgshapiro.endfor 18072847Sgshapiro 18172847Sgshapiro# 18272847Sgshapiro# ------------------------------------------------------------------------ 18372847Sgshapiro# 18472847Sgshapiro 185117286Sgshapiroall: cf maps aliases 18672847Sgshapiro 18757947Srwatsonclean: 18872847Sgshapiro 18972847Sgshapirodepend: 19072847Sgshapiro 191117286Sgshapirocf: ${INSTALL_CF} ${INSTALL_SUBMIT_CF} 19272847Sgshapiro 19390806Sgshapiro.ifdef SENDMAIL_SET_USER_ID 19494676Sgshapiroinstall: install-cf 19594676Sgshapiro.else 19694676Sgshapiroinstall: install-cf install-submit-cf 19794676Sgshapiro.endif 19894676Sgshapiro 199117286Sgshapiroinstall-cf: ${INSTALL_CF} 20094676Sgshapiro.if ${INSTALL_CF} != /etc/mail/sendmail.cf 201100872Sru ${INSTALL} -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf 20294676Sgshapiro.endif 20394676Sgshapiro 20494676Sgshapiro 205117286Sgshapiroinstall-submit-cf: ${INSTALL_SUBMIT_CF} 20694676Sgshapiro.ifdef SENDMAIL_SET_USER_ID 20790806Sgshapiro @echo ">>> ERROR: You should not create a submit.cf file if you are using a" 20890806Sgshapiro @echo " set-user-ID sendmail binary (SENDMAIL_SET_USER_ID is set" 20990806Sgshapiro @echo " in make.conf)." 21090806Sgshapiro @false 21194676Sgshapiro.else 21294676Sgshapiro.if ${INSTALL_SUBMIT_CF} != /etc/mail/submit.cf 213100872Sru ${INSTALL} -m ${SHAREMODE} ${INSTALL_SUBMIT_CF} /etc/mail/submit.cf 21490806Sgshapiro.endif 21594676Sgshapiro.endif 21690806Sgshapiro 217117286Sgshapiroaliases: ${SENDMAIL_ALIASES:%=%.db} 21872847Sgshapiro 219117286Sgshapiromaps: ${SENDMAIL_MAP_OBJ} 22072847Sgshapiro 22193853Sgshapirostart start-mta start-mspq: 22293853Sgshapiro @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \ 22393853Sgshapiro echo -n 'Starting:'; \ 22493853Sgshapiro sh ${SENDMAIL_START_SCRIPT} $@; \ 22593853Sgshapiro echo '.'; \ 22693853Sgshapiro fi 22772847Sgshapiro 22893853Sgshapirostop stop-mta stop-mspq: 22993853Sgshapiro @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \ 23093853Sgshapiro echo -n 'Stopping:'; \ 23193853Sgshapiro sh ${SENDMAIL_START_SCRIPT} $@; \ 23293853Sgshapiro echo '.'; \ 23393853Sgshapiro fi 23472847Sgshapiro 23593853Sgshapirorestart restart-mta restart-mspq: 23693853Sgshapiro @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \ 23793853Sgshapiro echo -n 'Restarting:'; \ 23893853Sgshapiro sh ${SENDMAIL_START_SCRIPT} $@; \ 23993853Sgshapiro echo '.'; \ 24093853Sgshapiro fi 24176623Sgshapiro 24276623Sgshapiro# User defined targets 24376623Sgshapiro.if exists(Makefile.local) 24476623Sgshapiro.include "Makefile.local" 24576623Sgshapiro.endif 24695317Sgshapiro 24795317Sgshapiro# For the definition of $SHAREMODE 24895317Sgshapiro.include <bsd.own.mk> 249