Makefile revision 90806
192512Sphk# 292512Sphk# $FreeBSD: head/etc/mail/Makefile 90806 2002-02-17 22:12:57Z gshapiro $ 392512Sphk# 492512Sphk# This Makefile provides an easy way to generate the configuration 592512Sphk# file and database maps for the sendmail(8) daemon. 692512Sphk# 792512Sphk# The user-driven targets are: 892512Sphk# 992512Sphk# all - Build cf, maps and aliases 1092512Sphk# cf - Build the .cf file from .mc file 1192512Sphk# maps - Build the feature maps 1292512Sphk# aliases - Build the sendmail aliases 1392512Sphk# install - Install the .cf file as /etc/mail/sendmail.cf 1492512Sphk# start - Start the sendmail daemon with the flags defined in 1592512Sphk# /etc/defaults/rc.conf or /etc/rc.conf 1692512Sphk# stop - Stop the sendmail daemon 1792512Sphk# restart - Restart the sendmail daemon 1892512Sphk# 1992512Sphk# Calling `make' will generate the updated versions when either the 2092512Sphk# aliases or one of the map files were changed. 2192512Sphk# 2292512Sphk# A `make install` is only necessary after modifying the .mc file. In 2392512Sphk# this case one would normally also call `make restart' to allow the 2492512Sphk# running sendmail to pick up the changes as well. 2592512Sphk# 2692512Sphk# ------------------------------------------------------------------------ 2792512Sphk# 2892512Sphk# This makefile uses `<HOSTNAME>.mc' as the default .mc file. This can 2992512Sphk# be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.: 3092512Sphk# 3192512Sphk# SENDMAIL_MC=/etc/mail/myconfig.mc 3292512Sphk# 3392512Sphk# If '<HOSTNAME>.mc' does not exist, it is created using 'freebsd.mc' 3492512Sphk# as a template. 3592512Sphk# ------------------------------------------------------------------------ 3692512Sphk# 3792512Sphk# The Makefile knows about the following maps: 3892512Sphk# access, bitdomain, domaintable, genericstable, mailertable, userdb, 3992512Sphk# uucpdomain, virtusertable 4092512Sphk# 4192512Sphk 4292512Sphk.ifndef SENDMAIL_MC 4392512SphkSENDMAIL_MC!= hostname 4492512SphkSENDMAIL_MC:= ${SENDMAIL_MC}.mc 4592512Sphk 4692512Sphk${SENDMAIL_MC}: 4792512Sphk cp freebsd.mc ${SENDMAIL_MC} 4892512Sphk.endif 4992512Sphk 5092512SphkINSTALL_CF= ${SENDMAIL_MC:R}.cf 5192512Sphk 5292512SphkSENDMAIL_ALIASES?= /etc/mail/aliases 5392512Sphk 5492512Sphk# 5592512Sphk# This is the directory where the sendmail configuration files are 5692512Sphk# located. 5792512Sphk# 5892512Sphk.if exists(/usr/share/sendmail/cf) 5992512SphkSENDMAIL_CF_DIR?= /usr/share/sendmail/cf 6092512Sphk.elif exists(/usr/src/contrib/sendmail/cf) 6192512SphkSENDMAIL_CF_DIR?= /usr/src/contrib/sendmail/cf 6292512Sphk.endif 6392512Sphk 6492512Sphk# 6592512Sphk# The pid is used to stop and restart the running daemon. 6692512Sphk# 6792512SphkSENDMAIL_PIDFILE?= /var/run/sendmail.pid 6892512Sphk 6992512Sphk# 7092512Sphk# Some useful programs we need. 7192512Sphk# 7292512SphkSENDMAIL?= /usr/sbin/sendmail 7392512SphkMAKEMAP?= /usr/sbin/makemap 7492512SphkM4?= /usr/bin/m4 7592512SphkKILL?= /bin/kill 7692512Sphk 7792512Sphk# Set a reasonable default 7892512Sphk.MAIN: all 7992512Sphk 8092512Sphk# 8192512Sphk# ------------------------------------------------------------------------ 8292512Sphk# 8392512Sphk# The Makefile picks up the list of files from SENDMAIL_MAP_SRC and 8492512Sphk# stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file 8592512Sphk# exists in the current directory. SENDMAIL_MAP_TYPE is the database 8692512Sphk# type to use when calling makemap. 8792512Sphk# 8892512SphkSENDMAIL_MAP_SRC+= mailertable domaintable bitdomain uucpdomain \ 8992512Sphk genericstable virtusertable access 9092512SphkSENDMAIL_MAP_OBJ= 9192512SphkSENDMAIL_MAP_TYPE?= hash 9292512Sphk 9392512Sphk.for _f in ${SENDMAIL_MAP_SRC} userdb 9492512Sphk.if exists(${_f}) 9592512SphkSENDMAIL_MAP_OBJ+= ${_f}.db 9692512Sphk.endif 9792512Sphk.endfor 9892512Sphk 9992512Sphk# 10092512Sphk# The makemap command is used to generate a hashed map from the textfile. 10192512Sphk# 10292512Sphk.for _f in ${SENDMAIL_MAP_SRC} 10392512Sphk.if (exists(${_f}.sample) && !exists(${_f})) 10492512Sphk${_f}: ${_f}.sample 10592512Sphk sed -e 's/^/#/' < ${.OODATE} > ${.TARGET} 10692512Sphk.endif 10792512Sphk 10892512Sphk${_f}.db: ${_f} 10992512Sphk ${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE} 11092512Sphk.endfor 11192512Sphk 11292512Sphkuserdb.db: userdb 11392512Sphk ${MAKEMAP} btree ${.TARGET} < ${.OODATE} 11492512Sphk 11592512Sphk 11692512Sphk# 11792512Sphk# The .cf file needs to be recreated if the templates were modified. 11892512Sphk# 11992512SphkM4FILES!= find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print 12092512Sphk 12192512Sphk# 12292512Sphk# M4(1) is used to generate the .cf file from the .mc file. 12392512Sphk# 12492512Sphk.SUFFIXES: .cf .mc 12592512Sphk 12692512Sphk.mc.cf: ${M4FILES} 12792512Sphk ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \ 12892512Sphk ${SENDMAIL_CF_DIR}/m4/cf.m4 ${@:R}.mc > ${.TARGET} 12992512Sphk 13092512Sphk# 13192512Sphk# Aliases are handled separately since they normally reside in /etc 13292512Sphk# and can be rebuild without the help of makemap. 13392512Sphk# 13492512Sphk${SENDMAIL_ALIASES}.db: ${SENDMAIL_ALIASES} 13592512Sphk ${SENDMAIL} -bi 13692512Sphk 13792512Sphk# 13892512Sphk# ------------------------------------------------------------------------ 13992512Sphk# 14092512Sphk 14192512Sphkall: cf maps aliases 14292512Sphk 14392512Sphkclean: 14492512Sphk 14592512Sphkdepend: 14692512Sphk 14792512Sphkcf: ${INSTALL_CF} 14892512Sphk 14992512Sphksubmit.cf: submit.mc 15092512Sphk.ifdef SENDMAIL_SET_USER_ID 15192512Sphk @echo ">>> ERROR: You should not create a submit.cf file if you are using a" 15292512Sphk @echo " set-user-ID sendmail binary (SENDMAIL_SET_USER_ID is set" 15392512Sphk @echo " in make.conf)." 15492512Sphk @false 15592512Sphk.endif 15692512Sphk 15792512Sphkmaps: ${SENDMAIL_MAP_OBJ} 15892512Sphk 15992512Sphkaliases: ${SENDMAIL_ALIASES}.db 16092512Sphk 16192512Sphkinstall: ${INSTALL_CF} 16292512Sphk.if ${INSTALL_CF} != /etc/mail/sendmail.cf 16392512Sphk ${INSTALL} -c -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf 16492512Sphk.endif 16592512Sphk 16692512Sphkstart: 16792512Sphk (. /etc/defaults/rc.conf; source_rc_confs; \ 16892512Sphk case "$${sendmail_enable}" in \ 16992512Sphk [Yy][Ee][Ss]) \ 17092512Sphk /usr/sbin/sendmail $${sendmail_flags} \ 17192512Sphk ;; \ 17292512Sphk *) \ 17392512Sphk case "$${sendmail_outbound_enable}" in \ 17492512Sphk [Yy][Ee][Ss]) \ 17592512Sphk /usr/sbin/sendmail $${sendmail_outbound_flags} \ 17692512Sphk ;; \ 17792512Sphk esac \ 17892512Sphk ;; \ 17992512Sphk esac \ 18092512Sphk ) 18192512Sphk 18292512Sphkstop: 18392512Sphk ${KILL} -TERM `head -1 ${SENDMAIL_PIDFILE}` 18492512Sphk 18592512Sphkrestart: 18692512Sphk ${KILL} -HUP `head -1 ${SENDMAIL_PIDFILE}` 18792512Sphk 18892512Sphk# User defined targets 18992512Sphk.if exists(Makefile.local) 19092512Sphk.include "Makefile.local" 19192512Sphk.endif 19292512Sphk