#TESTING:
#
#(1) Create two files in "/usr/lib/term" that you can write upon, that
#can be recognized as tab files by nroff, and that do not conflict with
#system file names (makefile defaults are tabepstst and tabepstst-12).
#If the default names are not used, redefine T and T12.  Uncomment the
#lines marked "careful" in the *.tab targets.
#
#(2) Identify a device in LP and LP12 that can pass a file through to an
#LQ-type printer, without altering it.  The makefile default is
#">/dev/epson".  If you use it, you probably will have to configure the
#printer ports by hand, to put them into raw mode.  The drivers put the
#printer into pica or elite mode, but do no other configuration.  The
#file "epson" is a printer interface script that has options for printer
#configuration and calls a routine to configure the printer ports.
#
#(3) run: 	make test test12

#Table.c and table.h are required to compile the nroff driver.
#They are from the Townsend package, in volume 13 of comp.sourcs.unix.
#The full package is well worth extracting from a sources archive 
#(elbat, to disassemble a driver; table.5, the man page; and more).

CFLAGS = -O
#CFLAGS = -g
#LDFLAGS

#need writable files in driver directory, with names that 
#do not conflict with system files
T =	epstst
T12 =	epstst-12
TERMFILE = /usr/lib/term/tab$(T)
TERMFILE12 = /usr/lib/term/tab$(T12)

#Set up LP and LP12 to pass stream without processing.
#May have to configure printer port and printer by hand.
LP = >/dev/epson
LP12 = >/dev/epson
#if have installed install "epson" or equivalent in lp/interface
#LP = | lp -depson -setlp -ounidiron -olq -onofilter
#LP12 = | lp -depson -osetlp -ounidiron -olq -onofilter -oresetpica

#for installation only
BINDIR = /usr/local/bin
PUBDIR = /usr/pub
MAN1DIR = /usr/man/new/man1
MAN5DIR = /usr/man/new/man5

dummy:
	@echo please give a target

all:	epf  nobs tabepson.tab tabepson12.tab

epf:	epf.c matrix.h
	cc $(CFLAGS) $(LDFLAGS) epf.c -o epf

nobs:	nobs.c
	cc $(CFLAGS) $(LDFLAGS) nobs.c -o nobs

tabepson.tab:	tabepson.o table.o
	cc tabepson.o table.o
	a.out tabepson.tab
	cp tabepson.tab $(TERMFILE)		#careful!

tabepson12.tab:	tabepson12.o table.o
	cc tabepson12.o table.o
	a.out tabepson12.tab
	cp tabepson12.tab $(TERMFILE12)		#careful!

table.o:	table.h

tabepson.o:	code.epson

tabepson12.o:	code.epson

special:
#uncomment to run all tests - else copy test into "special"
	cat specialgrk specialtbl specialeqn[12] >special

special.epf:	tabepson.tab epf nobs special
#pipe through pic for including files in tbl and eqn
	cat special|pic|tbl|neqn|nroff -T$(T) >special.raw
#the sed filter fixes the SO-<bksp> / SI-<bksp> problem;
#to use, substitute true control characters for the mnemonics, 
#and appropriately alter commenting
#	cat special.raw|\
#		sed -e "s/\^N\^H[\^H\^N]*\^N/\^N/g" \
#			-e "s/\^O\^H[\^H\^O]*\^O/\^O/g"|\
#		col -fx >special.col
	cat special.raw|\
		sed -e "s/\\[\\]*\/\/g" \
			-e "s/\\[\\]*\/\/g"|\
		col -fx >special.col
#	cat special.raw|col -fx >special.col
	cat special.col|nobs >special.nobs
	cat special.nobs|epf >special.epf

special12.epf:	tabepson12.tab epf nobs special
	cat special|pic|tbl|neqn|nroff -T$(T12) >special12.raw
	cat special12.raw|\
		sed -e "s/\\[\\]*\/\/g" \
			-e "s/\\[\\]*\/\/g"|\
		col -fx >special12.col
	cat special12.col|nobs >special12.nobs
	cat special12.nobs|epf >special12.epf

test:	special.epf
	cat special.epf $(LP)

test12:	special12.epf
	cat special12.epf $(LP12)

install:	nobs epf tabepson.tab tabepson12.tab epseqnchar
	strip nobs epf
	mv nobs epf $(BINDIR)
	cp epseqnchar $(PUBDIR)
#	mv tabepson.tab $(TERMFILE)		#shouldn't be needed
#	mv tabepson12.tab $(TERMFILE12)
	cp epf.1 nobs.1 $(MAN1DIR)
	cp table.5 $(MAN5DIR)
#do the right thing by permissions-ownerships
#lp interface?

clean:
	-rm core *.o tabepson*.tab a.out special*.* special nobs epf

spotless:	clean
	-rm $(BINDIR)/nobs $(BINDIR)/epf
	-rm $(TERMFILE) $(TERMFILE12) $(PUBDIR)/epseqnchar
	-rm $(MAN1DIR)/epf.1 $(MAN1DIR)/nobs.1 $(MAN5DIR)/table.5

shar:
	cat MANIFEST | sed 1,2d | makekit -pX -s42k >scr
	diff scr MANIFEST
	rm scr
