##################################################
# directories and modes
##################################################

PERLLIB=/local/usr/lib/perl
BINDIR=/usr/staff/bin
LIBMODE=755
BINMODE=755

##################################################
# programs used
##################################################

NROFF=nroff
TROFF=lroff
LATEX=latex
GREP=grep
UNDUMP=undump
PATH_NAME_PERL=/local/bin/perl

##################################################
# for author only
##################################################

SHAR=shar
SHELL=/bin/sh
BCKDIR=../back
ARCH=pink
FTPDIR=/users/ftp/UNIX
FTPMODE=644

SHS=Jjoin Jlist Jproject Jreport Jsort r2j
PLS=jinx.shell jinx.pl curses.pl menus.pl screen.pl
MAN=jinx.1
DOC=jinx.tex
TOOLS=testCurses
ALL=README Makefile jinx ${PLS} ${SHS} ${MAN} ${DOC}

all:
	@echo 'usage: make dump'
	@echo 'usage: make dump-install'
	@echo 'or:    make install'
	@echo 'and:   make doc'
	@echo 'and:   make man'
	@echo 'and:   make clean'
dump-install: dump
	mv -f ${BINDIR}/jinx ${BINDIR}/jinx.old
	cp dump ${BINDIR}/jinx
	cp ${SHS} ${BINDIR}
	cd ${BINDIR} ; chmod ${BINMODE} jinx ${SHS}
	cp jinx ${PLS} ${PERLLIB}
	cd ${PERLLIB} ; chmod ${LIBMODE} jinx ${PLS}
	rm -f ${BINDIR}/jinx.old
	@echo install man page jinx.1 by hand
install:
	cp jinx ${SHS} ${BINDIR}
	cd ${BINDIR} ; chmod ${BINMODE} jinx ${SHS}
	cp jinx ${PLS} ${PERLLIB}
	cd ${PERLLIB} ; chmod ${LIBMODE} jinx ${PLS}
	rm -f ${BINDIR}/jinx.old
	@echo install man page jinx.1 by hand
dump: jinx.core
	${UNDUMP} dump ${PATH_NAME_PERL} jinx.core
jinx.core: jinx ${PLS}
	rm -f core
	-${PATH_NAME_PERL} jinx -D
	mv core jinx.core
clean:
	rm -f jinx.nr jinx.tr core jinx.core dump
	rm -f jinx.log jinx.dvi
realclean: clean
	rm -f jinx.shar jinx.shar.Z jinx.ps jinx.ps.Z jinx.aux
man: jinx.nr jinx.tr
jinx.nr: jinx.1
	${NROFF} -man jinx.1 > jinx.nr
jinx.tr: jinx.1
	${TROFF} -man jinx.1 > jinx.tr
doc: jinx.dvi
jinx.dvi: jinx.tex
	${LATEX} jinx
	if ${GREP} Rerun jinx.log ; then ${LATEX} jinx ; fi

##################################################
# for author only
##################################################

show: jinx.nr
	col < jinx.nr | expand | more
jinx.ps.Z: jinx.dvi
	dvi2ps -r jinx.dvi > jinx.ps
	rm -f jinx.ps.Z
	compress -v jinx.ps
jinx.shar.Z: shar
shar:
	rm -f jinx.shar jinx.shar.01
	${SHAR} -o jinx.shar ${ALL}
	if test -f jinx.shar.01 ; then mv jinx.shar.01 jinx.shar ; fi
	compress -v jinx.shar
backup: jinx.shar.Z
	cp jinx.shar.Z ${TOOLS} ${BCKDIR}
arch: jinx.shar.Z jinx.ps.Z
	rcp jinx.shar.Z jinx.ps.Z ${ARCH}:${FTPDIR}
	rsh ${ARCH} chmod ${FTPMODE} ${FTPDIR}/jinx.shar.Z ${FTPDIR}/jinx.ps.Z
ctest:
	@testCurses jinx curses.pl screen.pl
wc:
	@wc ${ALL}
