########################################################################
# This program is Copyright (C) 1986-1996 by Jonathan Payne.  JOVE is  #
# provided to you without charge, and with no warranty.  You may give  #
# away copies of JOVE, including sources, provided that this notice is #
# included in all the files.                                           #
########################################################################

# TMPDIR is where the tmp files get stored, usually /tmp or /usr/tmp.  If
# your system, or reboot, removes files in /tmp, but not those in /usr/tmp,
# then it makes sense to make TMPDIR be /usr/tmp.
# But if you want to recover buffers on system crashes, you should create a
# directory that doesn't get cleaned upon reboot, and use that instead.
# You would probably want to clean out that directory periodically with
# /etc/cron.
# RECDIR is the directory in which RECOVER looks for JOVE's tempfiles.
#
# JOVEHOME is the directory in which pieces of JOVE are kept.  It is only used
#	in the default definitions of SHAREDIR, LIBDIR, BINDIR, and MANDIR.
# SHAREDIR is for online documentation, and the system-wide jove.rc file.
# LIBDIR is for the PORTSRV and RECOVER programs.
# BINDIR is where to put the executables JOVE and TEACHJOVE.
# MANDIR is where the manual pages go for JOVE, RECOVER and TEACHJOVE.
# MANEXT is the extension for the man pages, e.g., jove.1 or jove.l or jove.m.
# DFLTSHELL is the default shell invoked by JOVE and TEACHJOVE.
#
# If they don't exist, this makefile will try to create the directories
# LIBDIR and SHAREDIR.  All others must already exist.

SHAREDIR = /usr/local/lib/jove
LIBDIR = /usr/local/lib/jove
BINDIR = /usr/local/bin
MANDIR = /usr/local/man/man1

# you should not have to change anything below this line

INSTALLFLAGS = -g wheel -o root
XINSTALL=/bin/install $(INSTALLFLAGS) -c -m 755 # -s
TINSTALL=/bin/install $(INSTALLFLAGS) -c -m 644

# These should all just be right if the above ones are.
# You will confuse JOVE if you move anything from LIBDIR or SHAREDIR.

JOVE = $(BINDIR)/jove
TEACHJOVE = $(BINDIR)/teachjove
RECOVER = $(LIBDIR)/recover
PORTSRV = $(LIBDIR)/portsrv
JOVERC = $(SHAREDIR)/jove.rc
TERMSDIR = $(SHAREDIR)
CMDS.DOC = $(SHAREDIR)/cmds.doc
TEACH-JOVE = $(SHAREDIR)/teach-jove
JOVEM = $(MANDIR)/jove.1
TEACHJOVEM = $(MANDIR)/teachjove.1

NROFF = nroff
TROFF = troff -Tpost
TROFFPOST = | /usr/lib/lp/postscript/dpost - >troff.out.ps

MANUALS = $(JOVEM) $(TEACHJOVEM)

DOCTERMS =	doc/jove.rc.sun doc/keychart.sun \
	doc/jove.rc.st52 doc/jove.rc.stv52 \
	doc/jove.rc.sun-cmd doc/keychart.sun-cmd \
	doc/jove.rc.vt100 doc/keychart.vt100 \
	doc/jove.rc.wyse doc/keychart.wyse \
	doc/jove.rc.xterm doc/keychart.xterm \
	doc/jove.rc.z29 doc/keychart.z29 \
	doc/jove.rc.3022 doc/keychart.3022 \
	doc/keychart. \
	doc/XTermresource

DOCS =	doc/README doc/teach-jove doc/jove.qref \
	doc/intro.nr doc/cmds.macros.nr doc/cmds.nr doc/contents.nr \
	doc/jove.nr doc/teachjove.nr doc/xjove.nr doc/jovetool.nr \
	doc/jove.rc doc/example.rc $(DOCTERMS)


install: $(LIBDIR) $(SHAREDIR) \
	 $(TEACH-JOVE) $(CMDS.DOC) $(TERMSDIR)docs \
	 $(PORTSRV) $(RECOVER) $(JOVE) $(TEACHJOVE) $(MANUALS)
	$(TINSTALL) doc/jove.rc $(JOVERC)
	@echo See the README about changes to /etc/rc or /etc/rc.local
	@echo so that the system recovers jove files on reboot after a crash

$(LIBDIR)::
	test -d $(LIBDIR) || mkdir $(LIBDIR)

$(SHAREDIR)::
	test -d $(SHAREDIR) || mkdir $(SHAREDIR)

$(TEACH-JOVE)::
	$(TINSTALL) doc/teach-jove $(TEACH-JOVE)

$(CMDS.DOC)::
	$(TINSTALL) doc/cmds.doc $(CMDS.DOC)

$(TERMSDIR)docs::
	$(TINSTALL) $(DOCTERMS) $(TERMSDIR)

$(PORTSRV)::
	$(XINSTALL) portsrv $(PORTSRV)

$(RECOVER)::
	$(XINSTALL) recover $(RECOVER)

$(JOVE)::
	$(XINSTALL) jjove $(JOVE)

$(TEACHJOVE)::
	$(XINSTALL) teachjove $(TEACHJOVE)

$(JOVEM): doc/jove.nr
	@sed -e 's;<TMPDIR>;/usr/tmp;' \
	     -e 's;<LIBDIR>;$(LIBDIR);' \
	     -e 's;<SHAREDIR>;$(SHAREDIR);' \
	     -e 's;<SHELL>;/bin/sh;' doc/jove.nr > /tmp/jove.nr
	$(TINSTALL) /tmp/jove.nr $(JOVEM)
	rm /tmp/jove.nr

$(TEACHJOVEM): doc/teachjove.nr
	@sed -e 's;<TMPDIR>;/usr/tmp;' \
	     -e 's;<LIBDIR>;$(LIBDIR);' \
	     -e 's;<SHAREDIR>;$(SHAREDIR);' \
	     -e 's;<SHELL>;/bin/sh;' doc/teachjove.nr > /tmp/teachjove.nr
	$(TINSTALL) /tmp/teachjove.nr $(TEACHJOVEM)
	rm /tmp/teachjove.nr
