2 # $FreeBSD: src/etc/mail/Makefile,v 1.9.2.23 2003/02/12 03:57:52 gshapiro Exp $
3 # $DragonFly: src/etc/mail/Makefile,v 1.2 2003/06/17 04:24:47 dillon Exp $
5 # This Makefile provides an easy way to generate the configuration
6 # file and database maps for the sendmail(8) daemon.
8 # The user-driven targets are:
10 # all - Build cf, maps and aliases
11 # cf - Build the .cf file from .mc file
12 # maps - Build the feature maps
13 # aliases - Build the sendmail aliases
14 # install - Install the .cf file as /etc/mail/sendmail.cf
16 # For acting on both the MTA daemon and MSP queue running daemon:
17 # start - Start both the sendmail MTA daemon and MSP queue running
18 # daemon with the flags defined in /etc/defaults/rc.conf or
20 # stop - Stop both the sendmail MTA daemon and MSP queue running
22 # restart - Restart both the sendmail MTA daemon and MSP queue running
25 # For acting on just the MTA daemon:
26 # start-mta - Start the sendmail MTA daemon with the flags defined in
27 # /etc/defaults/rc.conf or /etc/rc.conf
28 # stop-mta - Stop the sendmail MTA daemon
29 # restart-mta - Restart the sendmail MTA daemon
31 # For acting on just the MSP queue running daemon:
32 # start-mspq - Start the sendmail MSP queue running daemon with the
33 # flags defined in /etc/defaults/rc.conf or /etc/rc.conf
34 # stop-mspq - Stop the sendmail MSP queue running daemon
35 # restart-mspq - Restart the sendmail MSP queue running daemon
37 # Calling `make' will generate the updated versions when either the
38 # aliases or one of the map files were changed.
40 # A `make install` is only necessary after modifying the .mc file. In
41 # this case one would normally also call `make restart' to allow the
42 # running sendmail to pick up the changes as well.
44 # ------------------------------------------------------------------------
45 # This Makefile uses `<HOSTNAME>.mc' as the default MTA .mc file. This
46 # can be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.:
48 # SENDMAIL_MC=/etc/mail/myconfig.mc
50 # If '<HOSTNAME>.mc' does not exist, it is created using 'freebsd.mc'
53 # It also uses 'freebsd.submit.mc' as the default mail submission .mc file.
54 # This can be changed by defining SENDMAIL_SUBMIT_MC in /etc/make.conf,
57 # SENDMAIL_SUBMIT_MC=/etc/mail/mysubmit.mc
58 # ------------------------------------------------------------------------
60 # The Makefile knows about the following maps:
61 # access, bitdomain, domaintable, genericstable, mailertable, userdb,
62 # uucpdomain, virtusertable
66 SENDMAIL_MC!= hostname
67 SENDMAIL_MC:= ${SENDMAIL_MC}.mc
70 cp freebsd.mc ${SENDMAIL_MC}
73 SENDMAIL_SUBMIT_MC?= freebsd.submit.mc
75 INSTALL_CF= ${SENDMAIL_MC:R}.cf
77 .ifndef SENDMAIL_SET_USER_ID
78 INSTALL_SUBMIT_CF= ${SENDMAIL_SUBMIT_MC:R}.cf
81 SENDMAIL_ALIASES?= /etc/mail/aliases
84 # This is the directory where the sendmail configuration files are
87 .if exists(/usr/share/sendmail/cf)
88 SENDMAIL_CF_DIR?= /usr/share/sendmail/cf
89 .elif exists(/usr/src/contrib/sendmail/cf)
90 SENDMAIL_CF_DIR?= /usr/src/contrib/sendmail/cf
94 # The sendmail startup script
96 SENDMAIL_START_SCRIPT?= /etc/rc.sendmail
99 # Some useful programs we need.
101 SENDMAIL?= /usr/sbin/sendmail
102 MAKEMAP?= /usr/sbin/makemap
105 # Permissions for generated maps
106 SENDMAIL_MAP_PERMS?= 0640
108 # Set a reasonable default
112 # ------------------------------------------------------------------------
114 # The Makefile picks up the list of files from SENDMAIL_MAP_SRC and
115 # stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file
116 # exists in the current directory. SENDMAIL_MAP_TYPE is the database
117 # type to use when calling makemap.
119 SENDMAIL_MAP_SRC+= mailertable domaintable bitdomain uucpdomain \
120 genericstable virtusertable access
122 SENDMAIL_MAP_TYPE?= hash
124 .for _f in ${SENDMAIL_MAP_SRC} userdb
126 SENDMAIL_MAP_OBJ+= ${_f}.db
131 # The makemap command is used to generate a hashed map from the textfile.
133 .for _f in ${SENDMAIL_MAP_SRC}
134 .if (exists(${_f}.sample) && !exists(${_f}))
136 sed -e 's/^/#/' < ${.OODATE} > ${.TARGET}
140 ${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE}
141 chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
145 ${MAKEMAP} btree ${.TARGET} < ${.OODATE}
146 chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
150 # The .cf file needs to be recreated if the templates were modified.
152 M4FILES!= find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print
155 # M4(1) is used to generate the .cf file from the .mc file.
160 ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \
161 ${SENDMAIL_CF_DIR}/m4/cf.m4 ${@:R}.mc > ${.TARGET}
164 # Aliases are handled separately since they normally reside in /etc
165 # and can be rebuild without the help of makemap.
167 .for _f in ${SENDMAIL_ALIASES}
169 ${SENDMAIL} -bi -OAliasFile=${.ALLSRC}
170 chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
174 # ------------------------------------------------------------------------
183 cf: ${INSTALL_CF} ${INSTALL_SUBMIT_CF}
185 .ifdef SENDMAIL_SET_USER_ID
188 install: install-cf install-submit-cf
191 install-cf: ${INSTALL_CF}
192 .if ${INSTALL_CF} != /etc/mail/sendmail.cf
193 ${INSTALL} -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf
197 install-submit-cf: ${INSTALL_SUBMIT_CF}
198 .ifdef SENDMAIL_SET_USER_ID
199 @echo ">>> ERROR: You should not create a submit.cf file if you are using a"
200 @echo " set-user-ID sendmail binary (SENDMAIL_SET_USER_ID is set"
201 @echo " in make.conf)."
204 .if ${INSTALL_SUBMIT_CF} != /etc/mail/submit.cf
205 ${INSTALL} -m ${SHAREMODE} ${INSTALL_SUBMIT_CF} /etc/mail/submit.cf
209 aliases: ${SENDMAIL_ALIASES:%=%.db}
211 maps: ${SENDMAIL_MAP_OBJ}
213 start start-mta start-mspq:
214 @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
215 echo -n 'Starting:'; \
216 sh ${SENDMAIL_START_SCRIPT} $@; \
220 stop stop-mta stop-mspq:
221 @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
222 echo -n 'Stopping:'; \
223 sh ${SENDMAIL_START_SCRIPT} $@; \
227 restart restart-mta restart-mspq:
228 @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
229 echo -n 'Restarting:'; \
230 sh ${SENDMAIL_START_SCRIPT} $@; \
234 # User defined targets
235 .if exists(Makefile.local)
236 .include "Makefile.local"
239 # For the definition of $SHAREMODE
240 .include <bsd.own.mk>