#
# Makefile for the nroff driver-customization tools
#
LP = mx80

DESTDIR = /usr/lib/nterm	# ditroff systems
TABFILE = tab.$(LP)

#DESTDIR = /usr/lib/term	# pre-ditroff systems
#TABFILE = tab$(LP)

DEFS =
CFLAGS = $(DEFS) -O	# -DKANJI if your nroff is the international version
LDFLAGS = -s
LFLAGS = $(DEFS)

DERIVED = $(TABFILE) $(LP).c $(LP).test

.SUFFIXES: .1 .5 .lp
.1.lp:
	nroff -man -T$(LP) $< | $(LP) >$*.lp
.5.lp:
	nroff -man -T$(LP) $< | $(LP) >$*.lp

all:	convtab dotmatrix

install: $(LP) $(TABFILE)
	mv $(TABFILE) $(DESTDIR)

CONVOBJS = termtab.o ditread.o otread.o otwrite.o ditwrite.o
convtab: convtab.o escapes.o $(CONVOBJS)
	$(CC) $(LFLAGS) convtab.o escapes.o $(CONVOBJS) -o convtab
dotmatrix: dotmatrix.o escapes.o
	$(CC) $(CFLAGS) dotmatrix.o escapes.o -o dotmatrix

convtab.o: convtab.c termtab.h
termtab.o: termtab.c termtab.h
ditread.o: ditread.c termtab.h
otwrite.o: otwrite.c termtab.h
ditwrite.o: ditwrite.c termtab.h
otread.o: otread.c termtab.h
escapes.o: escapes.c
dotmatrix.o: dotmatrix.c

$(DERIVED): dotmatrix $(LP).pix
	dotmatrix <$(LP).pix

lint:	
	lint $(LFLAGS) convtab.c escapes.c $(CONVOBJS:.o=.c)
	lint $(LFLAGS) dotmatrix.c escapes.c

clean:
	rm -f a.out *.o $(DERIVED) $(LP).raw $(LP).lp

test: $(DERIVED)
	nroff -T$(LP) $(LP).test | tee $(LP).raw | $(LP) | tee $(LP).lp | lp

shar:
	shar READ.ME Makefile *.[ch15] *.pix post.proto >dotmatrix.shar
