/* Imakefile for batmail package

	Batmail provides a gnu-emacs front-end to Andrew mail

    installs these files in $DESTDIR
	/bin/     robin batmail.sh
	/help/    ${HELPFILES}
	/lib/el/  batmail.el prompt.el
	/lib/ml/  batmail.ml prompt.ml
	/etc/	  intro intro.small initscreen
*/

/* ----------------------------------- */
#ifndef GNUEMACS
#define GNUEMACS gnu-emacs
#endif
/* ----------------------------------- */
batmail.sh: batmail.sh.tpl
	sed s%@EMACSNAME@%GNUEMACS% batmail.sh.tpl > batmail.sh


BATCAVE =   ${DESTDIR}

BATDIRS=    $(BATCAVE) $(BATCAVE)/bin $(BATCAVE)/etc \
	$(BATCAVE)/lib   $(BATCAVE)/lib/ml $(BATCAVE)/lib/el \
	$(BATCAVE)/help 

OBJS=       robin.o lispint.o driver.o date.o headfilter.o unscribe.o \
	hash.o wrap.o xsqiggle.o split.o vprintf.o lcstring.o \
	parseaddr.o falias.o death.o lock.o hshbuf.o rewrite.o fakedom.o 

HELPFILES =  batmail.1 overview.gnu  files.both  variables.gnu hooks.gnu \
	variables.gos hooks.gos commands.gos mcommands.gos


NormalObjectRule()
NormalATKRule()
NormalHelpRule()

ATKLIB =    $(DESTDIR)/lib
LIBRXP=	    ${ATKLIB}/librxp.a
LIBCUIN=    $(ATKLIB)/libcui.a $(ATKLIB)/libcuin.a
LIBMSN=	    $(ATKLIB)/libmssrv.a $(ATKLIB)/libmsshr.a
LIBMAIL=    $(ATKLIB)/libmail.a
LIBFLAME=   ${ATKLIB}/libeli.a
LIBPARSER=  ${ATKLIB}/libcparser.a
AMSLIBS =  $(LIBRXP) $(LIBCUIN) $(LIBMSN) $(LIBMAIL) $(LIBFLAME)  $(ATKLIB)/liberrors.a  ${LIBPARSER}

LOCALINCLUDES = -I$(DESTDIR)/include/ams

ProgramTarget(robin,$(OBJS),$(AMSLIBS) $(UTILLIB) ${PRSLIB},) 


/* ------------------------- */

tests.time: testre testdate testdeath unscribe testhf
	touch tests.time

TestProgramTarget(testre,testre.o,,$(DESTDIR)/lib/librxp.a)
TestProgramTarget(testdate,testdate.o date.o lcstring.o,,$(UTILLIB))
TestProgramTarget(testdeath,testdeath.o ${OBJS},,$(UTILLIB))
TestProgramTarget(unscribe,unscribemain.o unscribe.o hash.o lcstring.o,,)
TestProgramTarget(testhf,testhf.o headfilter.o hash.o split.o lcstring.o,,)

/* ------------------------- */

/* Installation */
MkdirTarget($(BATDIRS))
InstallPrograms(robin,${BATCAVE}/bin)
InstallDocs($(HELPFILES),$(BATCAVE)/help)
InstallHelpAlias(batmail,batmail robin)
InstallFiles(intro intro.small initscreen, $(INSTAPPFLAGS), $(BATCAVE)/etc)
InstallShScript(batmail.sh, $(BATCAVE)/bin/batmail)
InstallFiles(batmail.ml prompt.ml, $(INSTAPPFLAGS), $(BATCAVE)/lib/ml)
InstallFiles(batmail.el prompt.el, $(INSTAPPFLAGS), $(BATCAVE)/lib/el)

install:: $(BATCAVE)/lib/el/batmail.elc $(BATCAVE)/lib/el/prompt.elc
$(BATCAVE)/lib/el/batmail.elc: $(BATCAVE)/lib/el/batmail.el
	(cd $(BATCAVE)/lib/el ; \
	  GNUEMACS -batch -f batch-byte-compile *.el )
$(BATCAVE)/lib/el/prompt.elc: $(BATCAVE)/lib/el/prompt.el
	(cd $(BATCAVE)/lib/el ; \
	  GNUEMACS -batch -f batch-byte-compile prompt.el )

DependTarget()
CleanTarget(batmail.sh)
