Makefile revision 72847
1# 2# $FreeBSD: head/etc/mail/Makefile 72847 2001-02-22 04:17:33Z gshapiro $ 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# start - Start the sendmail daemon with the flags defined in 15# /etc/defaults/rc.conf or /etc/rc.conf 16# stop - Stop the sendmail daemon 17# restart - Restart the sendmail daemon 18# 19# Calling `make' will generate the updated versions when either the 20# aliases or one of the map files were changed. 21# 22# A `make install` is only necessary after modifying the .mc file. In 23# this case one would normally also call `make restart' to allow the 24# running sendmail to pick up the changes as well. 25# 26# ------------------------------------------------------------------------ 27# 28# This makefile uses `freebsd.mc' as the default .mc file. This can 29# be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.: 30# 31# SENDMAIL_MC=/etc/mail/myconfig.mc 32# 33# ------------------------------------------------------------------------ 34# 35# The Makefile knows about the following maps: 36# access, bitdomain, domaintable, genericstable, mailertable, userdb, 37# uucpdomain, virtusertable 38# 39 40SENDMAIL_MC?= freebsd.mc 41SENDMAIL_MC_CF= ${SENDMAIL_MC:R}.cf 42 43SENDMAIL_ALIASES?= /etc/mail/aliases 44 45# 46# This is the directory where the sendmail configuration files are 47# located. 48# 49.if exists(/usr/share/sendmail/cf) 50SENDMAIL_CF_DIR?= /usr/share/sendmail/cf 51.elif exists(/usr/src/contrib/sendmail/cf) 52SENDMAIL_CF_DIR?= /usr/src/contrib/sendmail/cf 53.endif 54 55# 56# The pid is used to stop and restart the running daemon. 57# 58SENDMAIL_PIDFILE?= /var/run/sendmail.pid 59 60# 61# Some useful programs we need. 62# 63SENDMAIL?= /usr/sbin/sendmail 64MAKEMAP?= /usr/sbin/makemap 65M4?= /usr/bin/m4 66KILL?= /bin/kill 67 68# Set a reasonable default 69.MAIN: all 70 71# 72# ------------------------------------------------------------------------ 73# 74# The Makefile picks up the list of files from SENDMAIL_MAP_SRC and 75# stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file 76# exists in the current directory. 77# 78SENDMAIL_MAP_SRC+= mailertable domaintable bitdomain uucpdomain \ 79 genericstable virtusertable access userdb 80SENDMAIL_MAP_OBJ= 81 82.for _f in ${SENDMAIL_MAP_SRC} 83.if exists(${_f}) 84SENDMAIL_MAP_OBJ+= ${_f}.db 85.endif 86.endfor 87 88# 89# The makemap command is used to generate a hashed map from the textfile. 90# 91.for _f in ${SENDMAIL_MAP_SRC} 92.if (exists(${_f}.sample) && !exists(${_f})) 93${_f}: ${_f}.sample 94 sed -e 's/^/#/' < ${.OODATE} > ${.TARGET} 95.endif 96 97${_f}.db: ${_f} 98 ${MAKEMAP} hash ${.TARGET} < ${.OODATE} 99.endfor 100 101# 102# The .cf file needs to be recreated if the templates were modified. 103# 104M4FILES!= find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print 105 106# 107# M4(1) is used to generate the .cf file from the .mc file. 108# 109.SUFFIXES: .cf .mc 110 111.mc.cf: ${M4FILES} 112 ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_CF_DIR}/m4/cf.m4 \ 113 ${@:R}.mc > ${.TARGET} 114 115${SENDMAIL_MC_CF}: ${M4FILES} 116 117# 118# Aliases are handled separately since they normally reside in /etc 119# and can be rebuild without the help of makemap. 120# 121${SENDMAIL_ALIASES}.db: ${SENDMAIL_ALIASES} 122 ${SENDMAIL} -bi 123 124# 125# ------------------------------------------------------------------------ 126# 127 128all: cf maps aliases 129 130clean: 131 132depend: 133 134cf: ${SENDMAIL_MC_CF} 135 136maps: ${SENDMAIL_MAP_OBJ} 137 138aliases: ${SENDMAIL_ALIASES}.db 139 140install: ${SENDMAIL_MC_CF} 141 ${INSTALL} -c -m ${SHAREMODE} ${SENDMAIL_MC_CF} /etc/mail/sendmail.cf 142 143start: 144 (. /etc/defaults/rc.conf; \ 145 if [ "$${sendmail_enable}" = "YES" -a -r /etc/mail/sendmail.cf ];\ 146 then \ 147 ${SENDMAIL} $${sendmail_flags}; \ 148 fi \ 149 ) 150 151stop: 152 ${KILL} -TERM `head -1 ${SENDMAIL_PIDFILE}` 153 154restart: 155 ${KILL} -HUP `head -1 ${SENDMAIL_PIDFILE}` 156