1# Copyright (c) 1995-1999 Hannah Schroeter <hannah@mamba.pond.sub.org>
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions
5# are met:
6#  1. Redistributions of source code must retain the above copyright
7#     notice, this list of conditions and the following disclaimer,
8#     either in a separate file included with the distribution, or
9#     copied into the source files.
10#  2. Redistributions in binary form must reproduce the above copyright
11#     notice, this list of conditions and the following disclaimer in the
12#     documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND HIS CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR HIS CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25
26CC=@CC@
27CFLAGS=@CFLAGS@
28install=@INSTALL@
29queuedir=@QUEUEDIR@
30#oldsendmail=@OLDSENDMAIL@  # not used anymore
31installmailer=@INSTALLMAILER@
32mailerversion=@MAILERVERSION@
33bingrp = @BINGRP@
34binusr = @BINUSR@
35privbin = @PRIVBINDIR@
36pubbin = @PUBBINDIR@
37mailerdir = @MAILERDIR@
38rcsmtpalias = cbsmtp crsmtp rgsmtp
39rsmtpalias = bsmtp
40transmitters = c-cbsmtp c-rcsmtp g-rcsmtp g-rgsmtp n-rsmtp
41conffiles = batcher bsmtp.c bsmtp.m4.8.6 bsmtp.m4.8.7 rcsmtp rsmtp \
42  transmitter.c-cbsmtp transmitter.c-rcsmtp transmitter.g-rcsmtp \
43  transmitter.g-rgsmtp transmitter.n-rsmtp rsmtp.wrapper.c bqueue _bqueue.c \
44  batcher.c bsmtp.m4.8.8 contrib/andyr/deliver.pl bsmtp.m4.8.9
45queueowner=@DAEMONUSER@
46queuegid=@DAEMONGID@
47perl=@PERL@
48lockdefine=@LOCKDEFINE@
49batcher=@BATCHER@
50
51all: bsmtp rsmtp.wrapper _bqueue $(batcher)
52
53reallyall: bsmtp rsmtp.wrapper _bqueue batcher batcher.new
54
55# This should not happen, but just to be sure.
56batcher: batcher.in
57	touch batcher
58
59bsmtp: bsmtp.c
60	$(CC) $(CFLAGS) $(lockdefine) -o bsmtp bsmtp.c
61
62batcher.new: batcher.c
63	$(CC) $(CFLAGS) $(lockdefine) -o batcher.new batcher.c
64
65rsmtp.wrapper: rsmtp.wrapper.c
66	$(CC) $(CFLAGS) -o rsmtp.wrapper rsmtp.wrapper.c
67
68_bqueue: _bqueue.c
69	$(CC) $(CFLAGS) -o _bqueue _bqueue.c
70
71# Note hack for install programs that insist on a directory as
72# last argument, and thus don't support on the fly renaming
73# of installed files. This is needed, because we install either
74# batcher or batcher.new as $(privbin)/batcher
75install: all
76	@if [ ! -d $(pubbin) ]; then \
77	  echo Making $(pubbin) ; \
78	  set -x ; \
79	  mkdir -p $(pubbin) || mkdir $(pubbin) || exit 0 ; \
80	  chown $(binusr) $(pubbin) ; \
81	  chgrp $(bingrp) $(pubbin) ; \
82	  chmod 755 $(pubbin) ; \
83	fi
84	@if [ ! -d $(privbin) ]; then \
85	  echo Making $(privbin) ; \
86	  set -x ; \
87	  mkdir -p $(privbin) || mkdir $(privbin) || exit 0 ; \
88	  chown $(binusr) $(privbin) ; \
89	  chgrp $(bingrp) $(privbin) ; \
90	  chmod 755 $(privbin) ; \
91	fi
92	@if [ ! -d $(queuedir) ]; then \
93	  echo Making $(queuedir) ; \
94	  set -x ; \
95	  mkdir -p $(queuedir) || mkdir $(queuedir) || exit 0 ; \
96	  chown $(queueowner) $(queuedir) ; \
97	  chgrp $(queuegid) $(queuedir) ; \
98	  chmod 770 $(queuedir) ; \
99	fi
100	@if [ ! -d $(mailerdir) ]; then \
101	  echo Making $(mailerdir) ; \
102	  set -x ; \
103	  mkdir -p $(mailerdir) || mkdir $(mailerdir) || exit 0 ; \
104	  chown $(binusr) $(mailerdir) ; \
105	  chgrp $(bingrp) $(mailerdir) ; \
106	  chmod 644 $(mailerdir) ; \
107	fi
108	$(install) -c -o $(binusr) -g $(bingrp) -m 555 $(batcher) \
109	  $(privbin)/batcher || ( cp $(batcher) /tmp/batcher && \
110	    $(install) -o $(binusr) -g $(bingrp) -m 555 /tmp/batcher \
111	    $(privbin) )
112	$(install) -s -c -o root -g $(bingrp) -m 4111 bsmtp $(privbin)
113	if [ $(installmailer) = true ]; then \
114	  $(install) -c -o $(binusr) -g $(bingrp) -m 444 \
115	    bsmtp.m4.$(mailerversion) $(mailerdir)/bsmtp.m4 || \
116	    ( cp bsmtp.m4.$(mailerversion) /tmp/bsmtp.m4 && \
117	      $(install) -o $(binusr) -g $(bingrp) -m 444 /tmp/bsmtp.m4 \
118	      $(mailerdir) ); \
119	fi
120	$(install) -c -o $(binusr) -g $(bingrp) -m 555 rcsmtp $(pubbin)
121	cd $(pubbin); set $(rcsmtpalias); while [ $$# -ne 0 ]; do \
122	  echo ln -s -f rcsmtp $$1; ln -s -f rcsmtp $$1; shift; done
123	$(install) -s -c -o $(binusr) -g $(bingrp) -m 555 rsmtp.wrapper \
124	  $(pubbin)/rsmtp
125	$(install) -c -o $(binusr) -g $(bingrp) -m 555 rsmtp $(privbin)
126	cd $(pubbin); set $(rsmtpalias); while [ $$# -ne 0 ]; do \
127	  echo ln -s -f rsmtp $$1; ln -s -f rsmtp $$1; shift; done
128	set $(transmitters); while [ $$# -ne 0 ]; do \
129	  $(install) -c -o $(binusr) -g $(bingrp) -m 555 transmitter.$$1 \
130	    $(privbin); \
131	  shift; \
132	done
133	$(install) -c -o $(queueowner) -g $(bingrp) -m 4111 _bqueue $(pubbin)
134	$(install) -c -o $(binusr) -g $(bingrp) -m 555 bqueue $(pubbin)
135
136clean:
137	rm -f batcher.new bsmtp rsmtp.wrapper _bqueue core *.o *.core
138
139mostlyclean: clean
140	rm -f $(conffiles)
141
142distclean: mostlyclean
143	rm -f config.sed
144	rm -f Makefile
145
146reconfig:
147	$(perl) ./configure --redo
148