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.3 2005/07/25 00:24:31 gshapiro 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 'dragonfly.mc'
53 # It also uses '<HOSTNAME>.submit.mc' as the default mail submission .mc
54 # file. This can be changed by defining SENDMAIL_SUBMIT_MC in
55 # /etc/make.conf, e.g.:
57 # SENDMAIL_SUBMIT_MC=/etc/mail/mysubmit.mc
59 # If '<HOSTNAME>.submit.mc' does not exist, it is created using
60 # 'dragonfly.submit.mc' as a template.
61 # ------------------------------------------------------------------------
63 # The Makefile knows about the following maps:
64 # access, bitdomain, domaintable, genericstable, mailertable, userdb,
65 # uucpdomain, virtusertable
69 SENDMAIL_MC
!= hostname
70 SENDMAIL_MC
:= ${SENDMAIL_MC}.mc
73 cp dragonfly.mc
${SENDMAIL_MC}
76 .
ifndef SENDMAIL_SUBMIT_MC
77 SENDMAIL_SUBMIT_MC
!= hostname
78 SENDMAIL_SUBMIT_MC
:= ${SENDMAIL_SUBMIT_MC}.submit.mc
80 ${SENDMAIL_SUBMIT_MC}:
81 cp dragonfly.submit.mc
${SENDMAIL_SUBMIT_MC}
84 INSTALL_CF
= ${SENDMAIL_MC
:R
}.cf
86 .
ifndef SENDMAIL_SET_USER_ID
87 INSTALL_SUBMIT_CF
= ${SENDMAIL_SUBMIT_MC
:R
}.cf
90 SENDMAIL_ALIASES?
= /etc
/mail
/aliases
93 # This is the directory where the sendmail configuration files are
96 .if exists
(/usr
/share
/sendmail
/cf
)
97 SENDMAIL_CF_DIR?
= /usr
/share
/sendmail
/cf
98 .elif exists
(/usr
/src
/contrib
/sendmail
/cf
)
99 SENDMAIL_CF_DIR?
= /usr
/src
/contrib
/sendmail
/cf
103 # The sendmail startup script
105 SENDMAIL_START_SCRIPT?
= /etc
/rc.sendmail
108 # Some useful programs we need.
110 SENDMAIL?
= /usr
/sbin
/sendmail
111 MAKEMAP?
= /usr
/sbin
/makemap
114 # Permissions for generated maps
115 SENDMAIL_MAP_PERMS?
= 0640
117 # Set a reasonable default
121 # ------------------------------------------------------------------------
123 # The Makefile picks up the list of files from SENDMAIL_MAP_SRC and
124 # stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file
125 # exists in the current directory. SENDMAIL_MAP_TYPE is the database
126 # type to use when calling makemap.
128 SENDMAIL_MAP_SRC
+= mailertable domaintable bitdomain uucpdomain \
129 genericstable virtusertable access
131 SENDMAIL_MAP_TYPE?
= hash
133 .for _f in
${SENDMAIL_MAP_SRC} userdb
135 SENDMAIL_MAP_OBJ
+= ${_f}.db
140 # The makemap command is used to generate a hashed map from the textfile.
142 .for _f in
${SENDMAIL_MAP_SRC}
143 .if
(exists
(${_f}.sample
) && !exists
(${_f}))
145 sed
-e
's/^/#/' < ${.OODATE
} > ${.TARGET
}
149 ${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET
} < ${.OODATE
}
150 chmod
${SENDMAIL_MAP_PERMS} ${.TARGET
}
154 ${MAKEMAP} btree
${.TARGET
} < ${.OODATE
}
155 chmod
${SENDMAIL_MAP_PERMS} ${.TARGET
}
159 # The .cf file needs to be recreated if the templates were modified.
161 M4FILES
!= find
${SENDMAIL_CF_DIR} -type f
-name
'*.m4' -print
164 # M4(1) is used to generate the .cf file from the .mc file.
169 ${M4} -D_CF_DIR_
=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \
170 ${SENDMAIL_CF_DIR}/m4
/cf.m4
${@
:R
}.mc
> ${.TARGET
}
173 # Aliases are handled separately since they normally reside in /etc
174 # and can be rebuild without the help of makemap.
176 .for _f in
${SENDMAIL_ALIASES}
178 ${SENDMAIL} -bi
-OAliasFile
=${.ALLSRC
}
179 chmod
${SENDMAIL_MAP_PERMS} ${.TARGET
}
183 # ------------------------------------------------------------------------
192 cf
: ${INSTALL_CF} ${INSTALL_SUBMIT_CF}
194 .
ifdef SENDMAIL_SET_USER_ID
197 install: install-cf install-submit-cf
200 install-cf
: ${INSTALL_CF}
201 .if
${INSTALL_CF} != /etc
/mail
/sendmail.cf
202 ${INSTALL} -m
${SHAREMODE} ${INSTALL_CF} /etc
/mail
/sendmail.cf
206 install-submit-cf
: ${INSTALL_SUBMIT_CF}
207 .
ifdef SENDMAIL_SET_USER_ID
208 @echo
">>> ERROR: You should not create a submit.cf file if you are using a"
209 @echo
" set-user-ID sendmail binary (SENDMAIL_SET_USER_ID is set"
210 @echo
" in make.conf)."
213 .if
${INSTALL_SUBMIT_CF} != /etc
/mail
/submit.cf
214 ${INSTALL} -m
${SHAREMODE} ${INSTALL_SUBMIT_CF} /etc
/mail
/submit.cf
218 aliases
: ${SENDMAIL_ALIASES
:%=%.db
}
220 maps
: ${SENDMAIL_MAP_OBJ}
222 start start-mta start-mspq
:
223 @if
[ -r
${SENDMAIL_START_SCRIPT} ]; then \
224 echo
-n
'Starting:'; \
225 sh
${SENDMAIL_START_SCRIPT} $@
; \
229 stop stop-mta stop-mspq
:
230 @if
[ -r
${SENDMAIL_START_SCRIPT} ]; then \
231 echo
-n
'Stopping:'; \
232 sh
${SENDMAIL_START_SCRIPT} $@
; \
236 restart restart-mta restart-mspq
:
237 @if
[ -r
${SENDMAIL_START_SCRIPT} ]; then \
238 echo
-n
'Restarting:'; \
239 sh
${SENDMAIL_START_SCRIPT} $@
; \
243 # User defined targets
244 .if exists
(Makefile.local
)
245 .
include "Makefile.local"
248 # For the definition of $SHAREMODE
249 .
include <bsd.own.mk
>