xref: /dragonfly/etc/sendmail/Makefile.4install (revision a361ab31)
1#
2# $FreeBSD: src/etc/mail/Makefile,v 1.9.2.23 2003/02/12 03:57:52 gshapiro Exp $
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#
15# For acting on both the MTA daemon and MSP queue running daemon:
16# start        - Start both the sendmail MTA daemon and MSP queue running
17#                daemon with the flags defined in /etc/defaults/rc.conf or
18#                /etc/rc.conf
19# stop         - Stop both the sendmail MTA daemon and MSP queue running
20#                daemon
21# restart      - Restart both the sendmail MTA daemon and MSP queue running
22#                daemon
23#
24# For acting on just the MTA daemon:
25# start-mta    - Start the sendmail MTA daemon with the flags defined in
26#                /etc/defaults/rc.conf or /etc/rc.conf
27# stop-mta     - Stop the sendmail MTA daemon
28# restart-mta  - Restart the sendmail MTA daemon
29#
30# For acting on just the MSP queue running daemon:
31# start-mspq   - Start the sendmail MSP queue running daemon with the
32#                flags defined in /etc/defaults/rc.conf or /etc/rc.conf
33# stop-mspq    - Stop the sendmail MSP queue running daemon
34# restart-mspq - Restart the sendmail MSP queue running daemon
35#
36# Calling `make' will generate the updated versions when either the
37# aliases or one of the map files were changed.
38#
39# A `make install` is only necessary after modifying the .mc file. In
40# this case one would normally also call `make restart' to allow the
41# running sendmail to pick up the changes as well.
42#
43# ------------------------------------------------------------------------
44# This Makefile uses `<HOSTNAME>.mc' as the default MTA .mc file.  This
45# can be changed by defining SENDMAIL_MC in /etc/make.conf, e.g.:
46#
47#		   SENDMAIL_MC=/etc/mail/myconfig.mc
48#
49# If '<HOSTNAME>.mc' does not exist, it is created using 'dragonfly.mc'
50# as a template.
51#
52# It also uses '<HOSTNAME>.submit.mc' as the default mail submission .mc
53# file. This can be changed by defining SENDMAIL_SUBMIT_MC in
54# /etc/make.conf, e.g.:
55#
56#		   SENDMAIL_SUBMIT_MC=/etc/mail/mysubmit.mc
57#
58# If '<HOSTNAME>.submit.mc' does not exist, it is created using
59# 'dragonfly.submit.mc' as a template.
60# ------------------------------------------------------------------------
61#
62# The Makefile knows about the following maps:
63# access, bitdomain, domaintable, genericstable, mailertable, userdb,
64# uucpdomain, virtusertable
65#
66
67.ifndef SENDMAIL_MC
68SENDMAIL_MC!=           hostname
69SENDMAIL_MC:=           ${SENDMAIL_MC}.mc
70
71${SENDMAIL_MC}:
72	cp dragonfly.mc ${SENDMAIL_MC}
73.endif
74
75.ifndef SENDMAIL_SUBMIT_MC
76SENDMAIL_SUBMIT_MC!=	hostname
77SENDMAIL_SUBMIT_MC:=	${SENDMAIL_SUBMIT_MC}.submit.mc
78
79${SENDMAIL_SUBMIT_MC}:
80	cp dragonfly.submit.mc ${SENDMAIL_SUBMIT_MC}
81.endif
82
83INSTALL_CF=		${SENDMAIL_MC:R}.cf
84INSTALL_SUBMIT_CF=	${SENDMAIL_SUBMIT_MC:R}.cf
85
86SENDMAIL_ALIASES?=	/etc/mail/aliases
87
88#
89# The sendmail startup script
90#
91SENDMAIL_START_SCRIPT?=	/etc/rc.sendmail
92
93#
94# Permissions set on various generated databases such as alias and map
95#
96SENDMAIL_MAP_PERMS?=	640
97
98#
99# Template location of m4 files used for cf file regeneration
100#
101SENDMAIL_CF_DIR?=	/usr/local/share/sendmail/cf
102
103#
104# Some useful programs we need.
105#
106SENDMAIL?=		/usr/local/sbin/sendmail
107MAKEMAP?=		/usr/local/sbin/makemap
108M4?=			/usr/bin/m4
109
110# Set a reasonable default
111.MAIN:	all
112
113#
114# ------------------------------------------------------------------------
115#
116# The Makefile picks up the list of files from SENDMAIL_MAP_SRC and
117# stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file
118# exists in the current directory.  SENDMAIL_MAP_TYPE is the database
119# type to use when calling makemap.
120#
121SENDMAIL_MAP_SRC+=	mailertable domaintable bitdomain uucpdomain \
122			genericstable virtusertable access
123SENDMAIL_MAP_OBJ=
124SENDMAIL_MAP_TYPE?=	hash
125
126.for _f in ${SENDMAIL_MAP_SRC} userdb
127.if exists(${_f})
128SENDMAIL_MAP_OBJ+=	${_f}.db
129.endif
130.endfor
131
132#
133# The makemap command is used to generate a hashed map from the textfile.
134#
135.for _f in ${SENDMAIL_MAP_SRC}
136.if (exists(${_f}.sample) && !exists(${_f}))
137${_f}:		${_f}.sample
138	sed -e 's/^/#/' < ${.OODATE} > ${.TARGET}
139.endif
140
141${_f}.db:	${_f}
142	${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE}
143	chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
144.endfor
145
146userdb.db:	userdb
147	${MAKEMAP} btree ${.TARGET} < ${.OODATE}
148	chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
149
150
151#
152# The .cf file needs to be recreated if the templates were modified.
153#
154M4FILES!=	find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print
155
156#
157# M4(1) is used to generate the .cf file from the .mc file.
158#
159.SUFFIXES:	.cf .mc
160
161.mc.cf:		${M4FILES}
162	${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \
163		${SENDMAIL_CF_DIR}/m4/cf.m4 ${@:R}.mc > ${.TARGET}
164
165#
166# Aliases are handled separately since they normally reside in /etc
167# and can be rebuild without the help of makemap.
168#
169.for _f in ${SENDMAIL_ALIASES}
170${_f}.db:	${_f}
171	${SENDMAIL} -bi -OAliasFile=${.ALLSRC}
172	chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
173.endfor
174
175#
176# ------------------------------------------------------------------------
177#
178
179all:		cf maps aliases
180
181clean:
182
183depend:
184
185cf:		${INSTALL_CF} ${INSTALL_SUBMIT_CF}
186
187install: install-cf install-submit-cf
188
189install-cf:	${INSTALL_CF}
190.if ${INSTALL_CF} != /etc/mail/sendmail.cf
191	${INSTALL} -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf
192.endif
193
194
195install-submit-cf:	${INSTALL_SUBMIT_CF}
196.if ${INSTALL_SUBMIT_CF} != /etc/mail/submit.cf
197	${INSTALL} -m ${SHAREMODE} ${INSTALL_SUBMIT_CF} /etc/mail/submit.cf
198.endif
199
200aliases:	${SENDMAIL_ALIASES:%=%.db}
201
202maps:		${SENDMAIL_MAP_OBJ}
203
204start start-mta start-mspq:
205	@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
206		echo -n 'Starting:'; \
207		sh ${SENDMAIL_START_SCRIPT} $@; \
208		echo '.'; \
209	fi
210
211stop stop-mta stop-mspq:
212	@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
213		echo -n 'Stopping:'; \
214		sh ${SENDMAIL_START_SCRIPT} $@; \
215		echo '.'; \
216	fi
217
218restart restart-mta restart-mspq:
219	@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
220		echo -n 'Restarting:'; \
221		sh ${SENDMAIL_START_SCRIPT} $@; \
222		echo '.'; \
223	fi
224
225# For the definition of $SHAREMODE
226.include <bsd.own.mk>
227