Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / etc / mail / Makefile
1 #
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 $
4 #
5 # This Makefile provides an easy way to generate the configuration
6 # file and database maps for the sendmail(8) daemon.
7 #
8 # The user-driven targets are:
9 #
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
15 #
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
19 #                /etc/rc.conf
20 # stop         - Stop both the sendmail MTA daemon and MSP queue running
21 #                daemon
22 # restart      - Restart both the sendmail MTA daemon and MSP queue running
23 #                daemon
24 #
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
30 #
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
36 #
37 # Calling `make' will generate the updated versions when either the
38 # aliases or one of the map files were changed.
39 #
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.
43 #
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.:
47 #
48 #                  SENDMAIL_MC=/etc/mail/myconfig.mc
49 #
50 # If '<HOSTNAME>.mc' does not exist, it is created using 'freebsd.mc'
51 # as a template.
52 #
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,
55 # e.g.:
56 #
57 #                  SENDMAIL_SUBMIT_MC=/etc/mail/mysubmit.mc
58 # ------------------------------------------------------------------------
59 #
60 # The Makefile knows about the following maps:
61 # access, bitdomain, domaintable, genericstable, mailertable, userdb,
62 # uucpdomain, virtusertable
63 #
64
65 .ifndef SENDMAIL_MC
66 SENDMAIL_MC!=           hostname
67 SENDMAIL_MC:=           ${SENDMAIL_MC}.mc
68
69 ${SENDMAIL_MC}:
70         cp freebsd.mc ${SENDMAIL_MC}
71 .endif
72
73 SENDMAIL_SUBMIT_MC?=    freebsd.submit.mc
74
75 INSTALL_CF=             ${SENDMAIL_MC:R}.cf
76
77 .ifndef SENDMAIL_SET_USER_ID
78 INSTALL_SUBMIT_CF=      ${SENDMAIL_SUBMIT_MC:R}.cf
79 .endif
80
81 SENDMAIL_ALIASES?=      /etc/mail/aliases
82
83 #
84 # This is the directory where the sendmail configuration files are
85 # located.
86 #
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
91 .endif
92
93 #
94 # The sendmail startup script
95 #
96 SENDMAIL_START_SCRIPT?= /etc/rc.sendmail
97
98 #
99 # Some useful programs we need.
100 #
101 SENDMAIL?=              /usr/sbin/sendmail
102 MAKEMAP?=               /usr/sbin/makemap
103 M4?=                    /usr/bin/m4
104
105 # Permissions for generated maps
106 SENDMAIL_MAP_PERMS?=    0640
107
108 # Set a reasonable default
109 .MAIN:  all
110
111 #
112 # ------------------------------------------------------------------------
113 #
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.
118 #
119 SENDMAIL_MAP_SRC+=      mailertable domaintable bitdomain uucpdomain \
120                         genericstable virtusertable access
121 SENDMAIL_MAP_OBJ=
122 SENDMAIL_MAP_TYPE?=     hash
123
124 .for _f in ${SENDMAIL_MAP_SRC} userdb
125 .if exists(${_f})
126 SENDMAIL_MAP_OBJ+=      ${_f}.db
127 .endif
128 .endfor
129
130 #
131 # The makemap command is used to generate a hashed map from the textfile.
132 #
133 .for _f in ${SENDMAIL_MAP_SRC}
134 .if (exists(${_f}.sample) && !exists(${_f}))
135 ${_f}:          ${_f}.sample
136         sed -e 's/^/#/' < ${.OODATE} > ${.TARGET}
137 .endif
138
139 ${_f}.db:       ${_f}
140         ${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE}
141         chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
142 .endfor
143
144 userdb.db:      userdb
145         ${MAKEMAP} btree ${.TARGET} < ${.OODATE}
146         chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
147
148
149 #
150 # The .cf file needs to be recreated if the templates were modified.
151 #
152 M4FILES!=       find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print
153
154 #
155 # M4(1) is used to generate the .cf file from the .mc file.
156 #
157 .SUFFIXES:      .cf .mc
158
159 .mc.cf:         ${M4FILES}
160         ${M4} -D_CF_DIR_=${SENDMAIL_CF_DIR}/ ${SENDMAIL_M4_FLAGS} \
161                 ${SENDMAIL_CF_DIR}/m4/cf.m4 ${@:R}.mc > ${.TARGET}
162
163 #
164 # Aliases are handled separately since they normally reside in /etc
165 # and can be rebuild without the help of makemap.
166 #
167 .for _f in ${SENDMAIL_ALIASES}
168 ${_f}.db:       ${_f}
169         ${SENDMAIL} -bi -OAliasFile=${.ALLSRC}
170         chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
171 .endfor
172
173 #
174 # ------------------------------------------------------------------------
175 #
176
177 all:            cf maps aliases
178
179 clean:
180
181 depend:
182
183 cf:             ${INSTALL_CF} ${INSTALL_SUBMIT_CF}
184
185 .ifdef SENDMAIL_SET_USER_ID
186 install: install-cf
187 .else
188 install: install-cf install-submit-cf
189 .endif
190
191 install-cf:     ${INSTALL_CF}
192 .if ${INSTALL_CF} != /etc/mail/sendmail.cf
193         ${INSTALL} -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf
194 .endif
195
196
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)."
202         @false
203 .else
204 .if ${INSTALL_SUBMIT_CF} != /etc/mail/submit.cf
205         ${INSTALL} -m ${SHAREMODE} ${INSTALL_SUBMIT_CF} /etc/mail/submit.cf
206 .endif
207 .endif
208
209 aliases:        ${SENDMAIL_ALIASES:%=%.db}
210
211 maps:           ${SENDMAIL_MAP_OBJ}
212
213 start start-mta start-mspq:
214         @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
215                 echo -n 'Starting:'; \
216                 sh ${SENDMAIL_START_SCRIPT} $@; \
217                 echo '.'; \
218         fi
219
220 stop stop-mta stop-mspq:
221         @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
222                 echo -n 'Stopping:'; \
223                 sh ${SENDMAIL_START_SCRIPT} $@; \
224                 echo '.'; \
225         fi
226
227 restart restart-mta restart-mspq:
228         @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
229                 echo -n 'Restarting:'; \
230                 sh ${SENDMAIL_START_SCRIPT} $@; \
231                 echo '.'; \
232         fi
233
234 # User defined targets
235 .if exists(Makefile.local)
236 .include "Makefile.local"
237 .endif
238
239 # For the definition of $SHAREMODE
240 .include <bsd.own.mk>