xref: /dragonfly/etc/sendmail/Makefile.4install (revision 896f2e3a)
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# Some useful programs we need.
95#
96SENDMAIL?=		/usr/local/sbin/sendmail
97MAKEMAP?=		/usr/local/sbin/makemap
98M4?=			/usr/bin/m4
99
100# Set a reasonable default
101.MAIN:	all
102
103#
104# ------------------------------------------------------------------------
105#
106# The Makefile picks up the list of files from SENDMAIL_MAP_SRC and
107# stores the matching .db filenames in SENDMAIL_MAP_OBJ if the file
108# exists in the current directory.  SENDMAIL_MAP_TYPE is the database
109# type to use when calling makemap.
110#
111SENDMAIL_MAP_SRC+=	mailertable domaintable bitdomain uucpdomain \
112			genericstable virtusertable access
113SENDMAIL_MAP_OBJ=
114SENDMAIL_MAP_TYPE?=	hash
115
116.for _f in ${SENDMAIL_MAP_SRC} userdb
117.if exists(${_f})
118SENDMAIL_MAP_OBJ+=	${_f}.db
119.endif
120.endfor
121
122#
123# The makemap command is used to generate a hashed map from the textfile.
124#
125.for _f in ${SENDMAIL_MAP_SRC}
126.if (exists(${_f}.sample) && !exists(${_f}))
127${_f}:		${_f}.sample
128	sed -e 's/^/#/' < ${.OODATE} > ${.TARGET}
129.endif
130
131${_f}.db:	${_f}
132	${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE}
133	chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
134.endfor
135
136userdb.db:	userdb
137	${MAKEMAP} btree ${.TARGET} < ${.OODATE}
138	chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
139
140
141#
142# The .cf file needs to be recreated if the templates were modified.
143#
144M4FILES!=	find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print
145
146#
147# M4(1) is used to generate the .cf file from the .mc file.
148#
149.SUFFIXES:	.cf .mc
150
151.mc.cf:		${M4FILES}
152	${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \
153		${SENDMAIL_CF_DIR}/m4/cf.m4 ${@:R}.mc > ${.TARGET}
154
155#
156# Aliases are handled separately since they normally reside in /etc
157# and can be rebuild without the help of makemap.
158#
159.for _f in ${SENDMAIL_ALIASES}
160${_f}.db:	${_f}
161	${SENDMAIL} -bi -OAliasFile=${.ALLSRC}
162	chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
163.endfor
164
165#
166# ------------------------------------------------------------------------
167#
168
169all:		cf maps aliases
170
171clean:
172
173depend:
174
175cf:		${INSTALL_CF} ${INSTALL_SUBMIT_CF}
176
177install: install-cf install-submit-cf
178
179install-cf:	${INSTALL_CF}
180.if ${INSTALL_CF} != /etc/mail/sendmail.cf
181	${INSTALL} -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf
182.endif
183
184
185install-submit-cf:	${INSTALL_SUBMIT_CF}
186.if ${INSTALL_SUBMIT_CF} != /etc/mail/submit.cf
187	${INSTALL} -m ${SHAREMODE} ${INSTALL_SUBMIT_CF} /etc/mail/submit.cf
188.endif
189
190aliases:	${SENDMAIL_ALIASES:%=%.db}
191
192maps:		${SENDMAIL_MAP_OBJ}
193
194start start-mta start-mspq:
195	@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
196		echo -n 'Starting:'; \
197		sh ${SENDMAIL_START_SCRIPT} $@; \
198		echo '.'; \
199	fi
200
201stop stop-mta stop-mspq:
202	@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
203		echo -n 'Stopping:'; \
204		sh ${SENDMAIL_START_SCRIPT} $@; \
205		echo '.'; \
206	fi
207
208restart restart-mta restart-mspq:
209	@if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
210		echo -n 'Restarting:'; \
211		sh ${SENDMAIL_START_SCRIPT} $@; \
212		echo '.'; \
213	fi
214
215# For the definition of $SHAREMODE
216.include <bsd.own.mk>
217