PROGRAM=	smtp
#
# ZMailer SMTP client Transport Agent makefile
#
srcdir = @srcdir@
VPATH = @srcdir@
@SET_MAKE@

SHELL=		/bin/sh
CC=		@CC@
COPTS=		@CFLAGS@
CPPFLAGS=	@CPPFLAGS@
CPPDEP=		@CPPDEP@
TOPDIR=		../..
MAILBIN=	$(prefix)@MAILBIN@
DEFS=		@DEFS@
INSTALL=	@INSTALL@
SMTPLIB=	@OPENSSLLIB@  @LIBSOCKET@ @LIBRESOLV@ $(LIBMALLOC)
SMTPINCL=	@GENINCL@   @OPENSSLINCL@ @INCLRESOLV@
#
SOURCE=		smtp.c appendlet.c smtptls.c getmxrr.c
OBJS=		smtp.o appendlet.o smtptls.o getmxrr.o
INCL=		-I$(srcdir)/$(TOPDIR)/include -I$(TOPDIR)/include -I$(TOPDIR)
CFLAGS=		$(COPTS) $(CPPFLAGS) $(DEFS) $(INCL) $(SMTPINCL)
LIBMALLOC=	@LIBMALLOC@
LIBMALLOCDEB=	$(TOPDIR)/libmalloc/libmalloc_d.a
#
LIB=		-L$(TOPDIR)/libs -lta -lzm -lzc -lsfio
LIBDEB=		$(TOPDIR)/libs/libtag $(TOPDIR)/libs/libta.a \
		$(TOPDIR)/libs/libzm.a $(TOPDIR)/libs/libzc.a \
		$(TOPDIR)/libs/libsfio.a
LINTLIB=	../libta/llib-llibta.ln

smtp-a:	smtp mprobe getmxrr-test

smtp:	$(OBJS) version.o $(LIBDEB)
	-rm -f smtp
	$(CC) $(CFLAGS) -o $@ $(OBJS) version.o $(LIB) $(SMTPLIB)

smtp.3rd: smtp
	atom -tool 3rd -o smtp.3rd smtp


getmxrr-test.o: $(srcdir)/getmxrr.c $(srcdir)/smtp.h
	$(CC) $(CFLAGS) -DTEST -c -o $@ $(srcdir)/getmxrr.c

getmxrr-test:  getmxrr-test.o
	$(CC) $(CFLAGS) -o $@ getmxrr-test.o version.o $(LIB) $(SMTPLIB)

mprobe:	mprobe.o version.o $(LIBDEB)
	-rm -f mprobe
	$(CC) $(CFLAGS) -o $@ mprobe.o version.o $(LIB) $(SMTPLIB)

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

smtp.o:      $(srcdir)/smtp.c $(srcdir)/smtp.h
smtptls.o:   $(srcdir)/smtptls.c $(srcdir)/smtp.h
appendlet.o: $(srcdir)/appendlet.c $(srcdir)/smtp.h

install:	smtp mprobe getmxrr-test
	$(INSTALL) -m 0755 smtp $(MAILBIN)/ta/smtp.x
	mv $(MAILBIN)/ta/smtp.x $(MAILBIN)/ta/smtp
	$(INSTALL) -m 0755 mprobe $(MAILBIN)/mprobe.x
	mv $(MAILBIN)/mprobe.x $(MAILBIN)/mprobe
	$(INSTALL) -m 0755 getmxrr-test $(MAILBIN)/getmxrr-test.x
	mv $(MAILBIN)/getmxrr-test.x $(MAILBIN)/getmxrr-test

clean:
	-rm -f smtp mprobe *~ *.o *.out make.log *.third *.3rd
	-rm -f getmxrr-test

distclean: clean
	-rm -f Makefile

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

../libta/llib-llibta.ln:
	cd ../libta ; $(MAKE) $(MFLAGS) lintlib

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

../libta/libta.a-a:
	cd ../libta ; $(MAKE) $(MFLAGS)
../libta/libta.a:
	cd ../libta ; $(MAKE) $(MFLAGS)

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

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


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

depend:
	$(TOPDIR)/bin/mklibdep $(CFLAGS) $(SOURCE)

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

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
