<errno.h>: Generally include <sys/cdefs.h>.
[dragonfly.git] / etc / sendmail / Makefile.4install
blobbbee651898417184c03039ec35fd645561e60afe
2 # $FreeBSD: src/etc/mail/Makefile,v 1.9.2.23 2003/02/12 03:57:52 gshapiro Exp $
4 # This Makefile provides an easy way to generate the configuration
5 # file and database maps for the sendmail(8) daemon.
7 # The user-driven targets are:
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
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
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
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
36 # Calling `make' will generate the updated versions when either the
37 # aliases or one of the map files were changed.
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.
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.:
47 #                  SENDMAIL_MC=/etc/mail/myconfig.mc
49 # If '<HOSTNAME>.mc' does not exist, it is created using 'dragonfly.mc'
50 # as a template.
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.:
56 #                  SENDMAIL_SUBMIT_MC=/etc/mail/mysubmit.mc
58 # If '<HOSTNAME>.submit.mc' does not exist, it is created using
59 # 'dragonfly.submit.mc' as a template.
60 # ------------------------------------------------------------------------
62 # The Makefile knows about the following maps:
63 # access, bitdomain, domaintable, genericstable, mailertable, userdb,
64 # uucpdomain, virtusertable
67 .ifndef SENDMAIL_MC
68 SENDMAIL_MC!=           hostname
69 SENDMAIL_MC:=           ${SENDMAIL_MC}.mc
71 ${SENDMAIL_MC}:
72         cp dragonfly.mc ${SENDMAIL_MC}
73 .endif
75 .ifndef SENDMAIL_SUBMIT_MC
76 SENDMAIL_SUBMIT_MC!=    hostname
77 SENDMAIL_SUBMIT_MC:=    ${SENDMAIL_SUBMIT_MC}.submit.mc
79 ${SENDMAIL_SUBMIT_MC}:
80         cp dragonfly.submit.mc ${SENDMAIL_SUBMIT_MC}
81 .endif
83 INSTALL_CF=             ${SENDMAIL_MC:R}.cf
84 INSTALL_SUBMIT_CF=      ${SENDMAIL_SUBMIT_MC:R}.cf
86 SENDMAIL_ALIASES?=      /etc/mail/aliases
89 # The sendmail startup script
91 SENDMAIL_START_SCRIPT?= /etc/rc.sendmail
94 # Permissions set on various generated databases such as alias and map
96 SENDMAIL_MAP_PERMS?=    640
99 # Template location of m4 files used for cf file regeneration
101 SENDMAIL_CF_DIR?=       /usr/local/share/sendmail/cf
104 # Some useful programs we need.
106 SENDMAIL?=              /usr/local/sbin/sendmail
107 MAKEMAP?=               /usr/local/sbin/makemap
108 M4?=                    /usr/bin/m4
110 # Set a reasonable default
111 .MAIN:  all
114 # ------------------------------------------------------------------------
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.
121 SENDMAIL_MAP_SRC+=      mailertable domaintable bitdomain uucpdomain \
122                         genericstable virtusertable access
123 SENDMAIL_MAP_OBJ=
124 SENDMAIL_MAP_TYPE?=     hash
126 .for _f in ${SENDMAIL_MAP_SRC} userdb
127 .if exists(${_f})
128 SENDMAIL_MAP_OBJ+=      ${_f}.db
129 .endif
130 .endfor
133 # The makemap command is used to generate a hashed map from the textfile.
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
141 ${_f}.db:       ${_f}
142         ${MAKEMAP} ${SENDMAIL_MAP_TYPE} ${.TARGET} < ${.OODATE}
143         chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
144 .endfor
146 userdb.db:      userdb
147         ${MAKEMAP} btree ${.TARGET} < ${.OODATE}
148         chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
152 # The .cf file needs to be recreated if the templates were modified.
154 M4FILES!=       find ${SENDMAIL_CF_DIR} -type f -name '*.m4' -print
157 # M4(1) is used to generate the .cf file from the .mc file.
159 .SUFFIXES:      .cf .mc
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}
166 # Aliases are handled separately since they normally reside in /etc
167 # and can be rebuild without the help of makemap.
169 .for _f in ${SENDMAIL_ALIASES}
170 ${_f}.db:       ${_f}
171         ${SENDMAIL} -bi -OAliasFile=${.ALLSRC}
172         chmod ${SENDMAIL_MAP_PERMS} ${.TARGET}
173 .endfor
176 # ------------------------------------------------------------------------
179 all:            cf maps aliases
181 clean:
183 depend:
185 cf:             ${INSTALL_CF} ${INSTALL_SUBMIT_CF}
187 install: install-cf install-submit-cf
189 install-cf:     ${INSTALL_CF}
190 .if ${INSTALL_CF} != /etc/mail/sendmail.cf
191         ${INSTALL} -m ${SHAREMODE} ${INSTALL_CF} /etc/mail/sendmail.cf
192 .endif
195 install-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
200 aliases:        ${SENDMAIL_ALIASES:%=%.db}
202 maps:           ${SENDMAIL_MAP_OBJ}
204 start start-mta start-mspq:
205         @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
206                 echo -n 'Starting:'; \
207                 sh ${SENDMAIL_START_SCRIPT} $@; \
208                 echo '.'; \
209         fi
211 stop stop-mta stop-mspq:
212         @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
213                 echo -n 'Stopping:'; \
214                 sh ${SENDMAIL_START_SCRIPT} $@; \
215                 echo '.'; \
216         fi
218 restart restart-mta restart-mspq:
219         @if [ -r ${SENDMAIL_START_SCRIPT} ]; then \
220                 echo -n 'Restarting:'; \
221                 sh ${SENDMAIL_START_SCRIPT} $@; \
222                 echo '.'; \
223         fi
225 # For the definition of $SHAREMODE
226 .include <bsd.own.mk>