Makefile revision 75073
199727Sbenno# 299727Sbenno# $FreeBSD: head/etc/mail/Makefile 75073 2001-04-01 22:48:07Z gshapiro $ 399727Sbenno# 499727Sbenno# This Makefile provides an easy way to generate the configuration 599727Sbenno# file and database maps for the sendmail(8) daemon. 699727Sbenno# 799727Sbenno# The user-driven targets are: 899727Sbenno# 999727Sbenno# all - Build cf, maps and aliases 1099727Sbenno# cf - Build the .cf file from .mc file 1199727Sbenno# maps - Build the feature maps 1299727Sbenno# aliases - Build the sendmail aliases 1399727Sbenno# install - Install the .cf file as /etc/mail/sendmail.cf 1499727Sbenno# start - Start the sendmail daemon with the flags defined in 1599727Sbenno# /etc/defaults/rc.conf or /etc/rc.conf 1699727Sbenno# stop - Stop the sendmail daemon 1799727Sbenno# restart - Restart the sendmail daemon 1899727Sbenno# 1999727Sbenno# Calling `make' will generate the updated versions when either the 2099727Sbenno# aliases or one of the map files were changed. 2199727Sbenno# 2299727Sbenno# A `make install` is only necessary after modifying the .mc file. In 2399727Sbenno# this case one would normally also call `make restart' to allow the 2499727Sbenno# running sendmail to pick up the changes as well. 2599727Sbenno# 2699727Sbenno# ------------------------------------------------------------------------ 2799727Sbenno# 2899727Sbenno# This makefile uses `freebsd.mc' as the default .mc file. This can 29124139Sobrien# be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.: 30124139Sobrien# 31124139Sobrien# SENDMAIL_MC=/etc/mail/myconfig.mc 3299727Sbenno# 3399727Sbenno# ------------------------------------------------------------------------ 3499727Sbenno# 3599727Sbenno# The Makefile knows about the following maps: 36263005Sroyger# access, bitdomain, domaintable, genericstable, mailertable, userdb, 37279799Snwhitehorn# uucpdomain, virtusertable 3899727Sbenno# 3999727Sbenno 4099727SbennoSENDMAIL_MC?= freebsd.mc 4199727SbennoINSTALL_CF= ${SENDMAIL_MC:R}.cf 4299727Sbenno 4399727SbennoSENDMAIL_ALIASES?= /etc/mail/aliases 4499727Sbenno 4599727Sbenno# 4699727Sbenno# This is the directory where the sendmail configuration files are 4799727Sbenno# located. 4899727Sbenno# 4999727Sbenno.if exists(/usr/share/sendmail/cf) 5099727SbennoSENDMAIL_CF_DIR?= /usr/share/sendmail/cf 5199727Sbenno.elif exists(/usr/src/contrib/sendmail/cf) 5299727SbennoSENDMAIL_CF_DIR?= /usr/src/contrib/sendmail/cf 5399727Sbenno.endif 5499727Sbenno 5599727Sbenno# 5699727Sbenno# The pid is used to stop and restart the running daemon. 5799727Sbenno# 5899727SbennoSENDMAIL_PIDFILE?= /var/run/sendmail.pid 5999727Sbenno 6099727Sbenno# 6199727Sbenno# Some useful programs we need. 6299727Sbenno# 6399727SbennoSENDMAIL?= /usr/sbin/sendmail 6499727SbennoMAKEMAP?= /usr/sbin/makemap 6599727SbennoM4?= /usr/bin/m4 6699727SbennoKILL?= /bin/kill 6799727Sbenno 6899727Sbenno# Set a reasonable default 6999727Sbenno.MAIN: all 7099727Sbenno 7199727Sbenno# 7299727Sbenno# ------------------------------------------------------------------------ 7399727Sbenno# 7499727Sbenno# The Makefile picks up the list of files from SENDMAIL_MAP_SRC and 7599727Sbenno# stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file 7699727Sbenno# exists in the current directory. 7799727Sbenno# 7899727SbennoSENDMAIL_MAP_SRC+= mailertable domaintable bitdomain uucpdomain \ 7999727Sbenno genericstable virtusertable access 8099727SbennoSENDMAIL_MAP_OBJ= 8199727Sbenno 82150469Sru.for _f in ${SENDMAIL_MAP_SRC} userdb 83150469Sru.if exists(${_f}) 84150469SruSENDMAIL_MAP_OBJ+= ${_f}.db 8599727Sbenno.endif 8699727Sbenno.endfor 8799727Sbenno 8899727Sbenno# 8999727Sbenno# The makemap command is used to generate a hashed map from the textfile. 9099727Sbenno# 9199727Sbenno.for _f in ${SENDMAIL_MAP_SRC} 9299727Sbenno.if (exists(${_f}.sample) && !exists(${_f})) 9399727Sbenno${_f}: ${_f}.sample 9499727Sbenno sed -e 's/^/#/' < ${.OODATE} > ${.TARGET} 9599727Sbenno.endif 9699727Sbenno 9799727Sbenno${_f}.db: ${_f} 9899727Sbenno ${MAKEMAP} hash ${.TARGET} < ${.OODATE} 9999727Sbenno.endfor 10099727Sbenno 10199727Sbennouserdb.db: userdb 10299727Sbenno ${MAKEMAP} btree ${.TARGET} < ${.OODATE} 10399727Sbenno 10499727Sbenno 10599727Sbenno# 10699727Sbenno# The .cf file needs to be recreated if the templates were modified. 10799727Sbenno# 10899727SbennoM4FILES!= find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print 10999727Sbenno 11099727Sbenno# 11199727Sbenno# M4(1) is used to generate the .cf file from the .mc file. 11299727Sbenno# 11399727Sbenno.SUFFIXES: .cf .mc 11499727Sbenno 11599727Sbenno.mc.cf: ${M4FILES} 11699727Sbenno ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_CF_DIR}/m4/cf.m4 \ 11799727Sbenno ${@:R}.mc > ${.TARGET} 11899727Sbenno 11999727Sbenno# 12099727Sbenno# Aliases are handled separately since they normally reside in /etc 12199727Sbenno# and can be rebuild without the help of makemap. 12299727Sbenno# 12399727Sbenno${SENDMAIL_ALIASES}.db: ${SENDMAIL_ALIASES} 12499727Sbenno ${SENDMAIL} -bi 12599727Sbenno 12699727Sbenno# 12799727Sbenno# ------------------------------------------------------------------------ 12899727Sbenno# 12999727Sbenno 13099727Sbennoall: cf maps aliases 13199727Sbenno 13299727Sbennoclean: 13399727Sbenno 13499727Sbennodepend: 13599727Sbenno 13699727Sbennocf: ${INSTALL_CF} 13799727Sbenno 13899727Sbennomaps: ${SENDMAIL_MAP_OBJ} 13999727Sbenno 14099727Sbennoaliases: ${SENDMAIL_ALIASES}.db 14199727Sbenno 14299727Sbennoinstall: ${INSTALL_CF} 14399727Sbenno ${INSTALL} -c -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf 14499727Sbenno 14599727Sbennostart: 14699727Sbenno (. /etc/defaults/rc.conf; source_rc_confs; \ 14799727Sbenno if [ "$${sendmail_enable}" = "YES" -a -r /etc/mail/sendmail.cf ];\ 14899727Sbenno then \ 14999727Sbenno ${SENDMAIL} $${sendmail_flags}; \ 15099727Sbenno fi \ 15199727Sbenno ) 15299727Sbenno 15399727Sbennostop: 15499727Sbenno ${KILL} -TERM `head -1 ${SENDMAIL_PIDFILE}` 15599727Sbenno 156209920Snwhitehornrestart: 157209920Snwhitehorn ${KILL} -HUP `head -1 ${SENDMAIL_PIDFILE}` 158209920Snwhitehorn