#
# Makefile for TkMail
#
# Paul Raines (raines@bohr.physics.upenn.edu)
# 		Hacked from Makefile for TkMan from Tom Phelps
#

# This Makefile includes the most critical and site specific
# settings needed to run TkMail. See the SETTINGS section at
# the top of the tkmail file for other settings.

# # # SITE SETTINGS # # #

# wish must be compiled with Tcl 6.7/Tk 3.2 or later
WISH = /usr/local/bin/wish

# directory to put *.tk support scripts
# the only library that must be at this location is disjoint.tk
# as long as the others are at locations in the auto_path with
# appropriate tclIndex files, they will be found
LIBDIR = /usr/local/lib/tkmail

# directory to put tkmail executable script
BINDIR = /usr/local/bin

# # # BSD MAIL SETTINGS # # #

# BSD style mail command
MAILCMD = Mail

# sendmail style mail delivery agent
# the -t options makes it parse the message for delivery info
DELIVER = /usr/lib/sendmail -bm -t
 
# name of users mbox (the file Mail automatically moves new mail
# messages to after read in the system inbox). This name is
# relative to the user home directory
MBOX = mbox

# directory where system inboxes reside. User's login name will 
# be appended
SYSTEM = /usr/spool/mail

# Mail command that will cause Mail not to page output
# the following works on SUN, IBM, and Linux
NOPAGING = "set screen=10000"
# the following is needed for SGI
# NOPAGING = "unset crt"

# # # ISPELL SETTINGS # # #

# whether you have ispell (not GNU ispell!). Set to 1 if you do, 0 if not.
# Read the top of ispell.tk file for more info. If you set this to 0,
# there is no need to change the two below.
HAVEISPELL = 1

# Location of ispell hash files
ISPELLLIB = /usr/local/lib/ispell

# whether your version of ispell puts out an initial version line
# when you start it with 'ispell -a'. Set to 1 if you do, 0 if not.
ISPELLNEW = 1

# # # MISC SETTINGS # # #

# ascii text print command for your site (%F is place holder for filename)
PRINTCMD = lpr %F

# temporary file directory to use
TEMPDIR = /usr/tmp

# bitmap directory containing flagdown, flagup, and letters
BITMAPDIR = /usr/include/X11/bitmaps


#--------------------------------------------------
#
# you shouldn't modify anything below here
#
#--------------------------------------------------

version = 1.4p3
srcs = tkmail
objs = settings
libs = compose.tk mail.tk utils.tk ispell.tk \
	altedit.tk disjoint.tk bindings.tk tclIndex
aux = example.tkmail README disjoint.test
bitmaps = 
distrib = $(srcs) $(libs) $(bitmaps) $(aux) test Makefile


all: ispell mail


mail: settings tkmail $(libs) Makefile
	mv tkmail tkmail.src
	echo '#!$(WISH) -f' > tkmail
	echo 'global mf mfp' >> tkmail
	echo 'set mfp(tkmaillib) $(LIBDIR)' >> tkmail
	echo 'set mfp(globalset) $(LIBDIR)/settings' >> tkmail
	tail +5 tkmail.src >> tkmail
	chmod +x tkmail
	rm tkmail.src

ispell: Makefile
	mv ispell.tk ispell.tk.src
	echo 'global tkisp' > ispell.tk
	echo 'set tkisp(ispell_lib) $(ISPELLLIB)' >> ispell.tk
	echo 'set tkisp(have_new) $(ISPELLNEW)' >> ispell.tk
	tail +4 ispell.tk.src >> ispell.tk
	rm ispell.tk.src

tests: test/mtest test/mtest.box Makefile
	rm -f mtest
	echo '#!$(WISH) -f' > mtest
	echo 'global mfp' >> mtest
	echo 'set user [exec whoami]' >> mtest
	echo 'set mcmd "$(MAILCMD)"' >> mtest
	echo 'set systemf $(SYSTEM)/[exec whoami]' >> mtest
	echo 'set mbox $$env(HOME)/$(MBOX)' >> mtest
	tail +7 test/mtest >> mtest
	chmod +x mtest
	mv -f mtest test/mtest
	(cd test; ./mtest)

settings: Makefile
	rm -f settings
	echo '# TkMail global settings file' > settings
	echo 'global mf mfp env' >> settings
	echo '' >> settings
	echo '# BSD style mail command (do not put options here!)' >> settings
	echo 'set mf(cmd) "$(MAILCMD)"' >> settings
	echo '# name of mail delivery command' >> settings
	echo 'set mf(deliver) "$(DELIVER)"' >> settings
	echo '# name of main MBOX' >> settings
	echo 'set mf(mbox) $$env(HOME)/$(MBOX)' >> settings
	echo '# name of system inbox' >> settings
	echo 'set mf(system) $(SYSTEM)/[exec whoami]' >> settings
	echo '# how to stop mail paging' >> settings
	echo 'set mf(nopaging) $(NOPAGING)' >> settings
	echo '' >> settings
	echo '# whether or not you have ispell' >> settings
	echo 'set mf(ispell) $(HAVEISPELL)' >> settings
	echo '# print command (%F is file placeholder)' >> settings
	echo 'set mf(print) "$(PRINTCMD)"' >> settings
	echo '# temporary directory' >> settings
	echo 'set mf(tmp) $(TEMPDIR)' >> settings
	echo '# bitmaps' >> settings
	echo 'set mf(fdownbmp) $(BITMAPDIR)/flagdown' >> settings
	echo 'set mf(fupbmp) $(BITMAPDIR)/flagup' >> settings
	echo 'set mf(writebmp) $(BITMAPDIR)/letters' >> settings

install: settings tkmail $(libs) $(aux) Makefile
	@if [ -d $(BINDIR) ]; then set +x; \
	else (set -x; mkdir $(BINDIR)); fi
	cp tkmail $(BINDIR)
	@if [ -d $(LIBDIR) ]; then set +x; \
	else (set -x; mkdir $(LIBDIR)); fi
	cp $(libs) $(aux) settings $(LIBDIR)

clean:
	rm -f $(objs) test/mtest2.box test/mtest3.box

tar:
	rm -f tkmail*.tar.[zZ]*
	mkdir tkmail-$(version)
	cp -R $(distrib) tkmail-$(version)
	rm -rf tkmail-$(version)/test/CVS
	tar chvf tkmail-$(version).tar tkmail-$(version)
	compress tkmail-$(version).tar
#	gzip -9v tkmail-$(version).tar
	rm -rf tkmail-$(version)
	@echo "*** Did you remember to cvs commit first?"

uu: tar
	uuencode tkmail-$(version).tar.Z tkmail-$(version).tar.Z > tkmail-$(version).tar.Z.uu
