PROGRAM=	smtpserver
#
# ZMailer SMTP server makefile

srcdir = @srcdir@
VPATH = @srcdir@
@SET_MAKE@

#
SHELL=		/bin/sh
CC=		@CC@
COPTS=		@CFLAGS@
CPPDEP=		@CPPDEP@
TOPDIR=		..
prefix=		@prefix@
exec_prefix=	@exec_prefix@
MAILBIN=	@MAILBIN@
DEFS=		@DEFS@
INSTALL=	@INSTALL@
SMTPSERVER_INCL= @INCLRESOLV@ @INCLWRAP@
SMTPSERVER_LIB=	 @LIBDBMS@ @LIBWRAP@ @LIBLOADAVER@ @LIBRESOLV@ @LIBSOCKET@
#   Above the  LIBSOCKET (for SysVR4) must be last
#
INCL=		-I$(TOPDIR) -I$(TOPDIR)/include
CFLAGS=		$(COPTS) $(DEFS) $(INCL) $(SMTPSERVER_INCL)
LIBMALLOC=	@LIBMALLOC@
LIBMALLOCDEB=	$(TOPDIR)/libmalloc/libmalloc_d.a-a
LIB=		-L$(TOPDIR)/libs -lz -lzc -lident -lta $(LIBMALLOC)
LIBDEB=		$(TOPDIR)/libs/libtag
LINTLIB=	$(TOPDIR)/lib/llib-llibz.ln $(TOPDIR)/libc/llib-llibzc.ln $(TOPDIR)/libident/llib-llibident.ln
OBJS=		$(PROGRAM).o version.o rfc821scn.o debugreport.o loadaver.o \
		fdstatfs.o wantconn.o policytest.o cfgread.o smtpdata.o \
		smtpcmds.o smtphelp.o smtprouter.o smtpchild.o

SOURCE=		$(PROGRAM).c rfc821scn.c debugreport.c loadaver.c fdstatfs.c \
		wantconn.c policytest.c  cfgread.c smtpdata.c \
		smtpcmds.c smtphelp.c smtprouter.c smtpchild.c

all: $(PROGRAM)-a

smtpserver.o: smtpserver.c smtpserver.h policytest.h
cfgread.o:    cfgread.c smtpserver.h
smtpcmds.o:   smtpcmds.c smtpserver.h policytest.h
smtpdata.o:   smtpdata.c smtpserver.h
smtphelp.o:   smtphelp.c smtpserver.h
smtprouter.o: smtprouter.c smtpserver.h
policytest.o:  policytest.c policytest.h # ignored: smtpserver.h


$(PROGRAM)-a:	$(LIBDEB) $(PROGRAM)

$(PROGRAM):	$(OBJS) $(LIBDEB)
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIB) $(SMTPSERVER_LIB)

version.c: $(PROGRAM).c
	@$(MAKE) $(MFLAGS) -f $(TOPDIR)/Makefile $@


install:	$(PROGRAM)
	$(INSTALL) -m 0755 $(PROGRAM) $(MAILBIN)/$(PROGRAM).x
	mv $(MAILBIN)/$(PROGRAM).x $(MAILBIN)/$(PROGRAM)

clean:
	-rm -f $(PROGRAM) make.log *.o *.out *~ fdstatfs-test

distclean: clean
	-rm -f Makefile

fdstatfs-test: fdstatfs-test.o fdstatfs.o
	$(CC) $(CFLAGS) -o $@ fdstatfs-test.o fdstatfs.o

lint:	$(LINTLIB)
	lint $(DEFS) $(INCL) $(LINTLIB) $(PROGRAM).c

depend:	$(SOURCE)
	CPPDEP="${CPPDEP}" $(TOPDIR)/bin/mkdep -f Makefile $(CFLAGS) $(SOURCE)

$(TOPDIR)/libs/libtag:
	cd $(TOPDIR)/libs ; $(MAKE) $(MFLAGS) libtag

$(TOPDIR)/libc/llib-llibzc.ln:
	cd $(TOPDIR)/libc ; $(MAKE) $(MFLAGS) lintlib

$(TOPDIR)/lib/llib-llibz.ln:
	cd $(TOPDIR)/lib ; $(MAKE) $(MFLAGS) lintlib

$(TOPDIR)/libident/llib-llibident.ln:
	cd $(TOPDIR)/libident ; $(MAKE) $(MFLAGS) lintlib

$(TOPDIR)/libc/libzc.a-a:
	cd $(TOPDIR)/libc ; $(MAKE) $(MFLAGS)
$(TOPDIR)/libc/libzc.a:
	cd $(TOPDIR)/libc ; $(MAKE) $(MFLAGS)

$(TOPDIR)/lib/libz.a-a:
	cd $(TOPDIR)/lib ; $(MAKE) $(MFLAGS)
$(TOPDIR)/lib/libz.a:
	cd $(TOPDIR)/lib ; $(MAKE) $(MFLAGS)


$(TOPDIR)/libident/libident.a-a:
	cd $(TOPDIR)/libident ; $(MAKE) $(MFLAGS)
$(TOPDIR)/libident/libident.a:
	cd $(TOPDIR)/libidentes ; $(MAKE) $(MFLAGS)

$(TOPDIR)/libmalloc/libmalloc_d.a-a:
	cd $(TOPDIR)/libs ; $(MAKE) $(MFLAGS) libmalloc_d.a
$(TOPDIR)/libmalloc/libmalloc_d.a:
	cd $(TOPDIR)/libs ; $(MAKE) $(MFLAGS) libmalloc_d.a


# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
