SHELL=		/bin/sh
TOPDIR=		..
PZCONFIG=	$(TOPDIR)/zmailer.Config
INSTALL=	@INSTALL@
MAILBIN=	$(prefix)@MAILBIN@

srcdir=         @srcdir@
VPATH=          @srcdir@

CC=		@CC@
COPTS=		@CFLAGS@
CPPFLAGS=	@CPPFLAGS@
CPPDEP=		@CPPDEP@
TOPDIR=		..
MAILBIN=	$(prefix)@MAILBIN@
DEFS=		@DEFS@
MD5SUM=		@MD5SUM@
INSTALL=	@INSTALL@
#
INCL=		-I$(srcdir)/$(TOPDIR)/include -I$(TOPDIR)/include -I$(TOPDIR) -I$(srcdir)/$(TOPDIR)/libsh -I$(TOPDIR)/libsh -I.
CFLAGS=		$(COPTS) $(CPPFLAGS) $(DEFS) $(ROUTER_INCL) $(INCL)
LIBMALLOC=	@LIBMALLOC@
LIBMALLOCDEB=	$(TOPDIR)/libmalloc/libmalloc_d.a-a
#
LIB=		-L$(TOPDIR)/libs -lzmdb -lsh -lzm -lzc @LIBRESOLV@ @LIBSOCKET@ $(LIBMALLOC)
LIBDEB=		$(TOPDIR)/libs/libtag

BINS=	autoanswer.pl policy-builder.sh rotate-logs.sh		\
	$(srcdir)/make-incore.sh $(srcdir)/bitbucket md5sum	\
	smtpserver-log-parser.pl

all:	listexpand md5sum
	cd makedb ; $(MAKE) $(MFLAGS)
	cd vacation ; $(MAKE) $(MFLAGS)

install:
	@for BIN in $(BINS); do					\
		if [ ! -f $(MAILBIN)/$$BIN ] ; then		\
			$(INSTALL) -m 755 $$BIN  $(MAILBIN) ;	\
		else						\
			echo "*** No overwrite of $$BIN, already exists!" ; \
			$(INSTALL) -m 755 $$BIN  $(MAILBIN)/$$BIN.new ;	\
		fi ;						\
	done
	@$(INSTALL) -m 755 $(srcdir)/bitbucket $(MAILBIN)/ta
	@$(INSTALL) -m 755 listexpand $(MAILBIN)/ta
	@cd makedb ; $(MAKE) $(MFLAGS) install
	@cd vacation ; $(MAKE) $(MFLAGS) install

.c.o:
	$(CC) $(CFLAGS) -c $<

listexpand:	listexpand.o
	$(CC) $(CFLAGS) -o $@.x listexpand.o $(LIB)
	mv $@.x $@

md5sum: md5sum.o $(LIBDEB)
	$(CC) $(CFLAGS) -o $@.x md5sum.o $(LIB)
	mv $@.x $@

FRC:

clean:	FRC
	rm -f ./+* *~ *.o listexpand md5sum
	cd vacation ; $(MAKE) $(MFLAGS) clean
	cd makedb ; $(MAKE) $(MFLAGS) clean

distclean: clean
	rm -f Makefile autoanswer.pl policy-builder.sh zmailer.init.sh
	rm -f rotate-logs.sh smtpserver-log-parser.pl
	cd vacation ; $(MAKE) $(MFLAGS) distclean
	cd makedb ; $(MAKE) $(MFLAGS) distclean

depend:
