PROGRAM=	errormail
#
# ZMailer Error mail 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@
ERRORMAIL_INCL=	@GENINCL@
ERRORMAIL_LIB=	@LIBRESOLV@ @LIBSOCKET@
#
SOURCE=		errormail.c
INCL=		-I$(srcdir)/$(TOPDIR)/include -I$(TOPDIR)/include -I$(TOPDIR)
CFLAGS=		$(COPTS) $(CPPFLAGS) $(DEFS) $(ERRORMAIL_INCL) $(INCL)
LIBMALLOC=	@LIBMALLOC@
LIBMALLOCDEB=	$(TOPDIR)/libmalloc/libmalloc_d.a-a
LIB=		-L$(TOPDIR)/libs -lta -lzm -lzc $(LIBMALLOC)
#LIB=		$(TOPDIR)/lib/libzm.a $(TOPDIR)/libc/libzc.a ../libta/libta.a $(LIBMALLOC)
LIBDEB=		$(TOPDIR)/libs/libtag
#LIBDEB=		$(TOPDIR)/lib/libzm.a-a $(TOPDIR)/libc/libzc.a-a ../libta/libta.a-a $(LIBMALLOCDEB)
LINTLIB=	../libta/llib-llibta.ln $(TOPDIR)/libc/llib-llibzc.ln

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

$(PROGRAM):	$(PROGRAM).o version.o $(LIBDEB)
	$(CC) $(CFLAGS) -o $@ $(PROGRAM).o version.o $(LIB) $(ERRORMAIL_LIB)

$(PROGRAM).o: $(srcdir)/$(PROGRAM).c

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

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

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

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

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

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

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

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

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

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

../libta/llib-llibta.ln:
	cd ../libta ; make lintlib

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

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

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