###############################################################################
#
#	table (version 2.0) - a utility for creating nroff driver tables.
#
#	Makefile for nroff driver tables under USG UNIX.
#	Written by Bruce Townsend Oct, 1987.
#
#	Copyright (c) 1987 by Bruce Townsend and Bell-Northern Research.
#	Permission is granted to use and distribute, except for profit,
#	providing this copyright notice and the author's name is included.
#	No warranty of any kind is expressed or implied, and no liability of
#	any kind is assumed by either the author or Bell-Northern Research.
#
###############################################################################

###############################################################################
#	User-Configurable Section
#
SOURCES =	tabljet.c

DESTDIR =	/usr/lib/term
# Include the KANJI flag if your nroff supports Kanji characters
# CFLAGS =	-O -DKANJI
CFLAGS =	-O
LDFLAGS =	-s
#
#	End of User-Configurable Section
###############################################################################

TABFILES =	$(SOURCES:.c=.tab)
TABS =		$(SOURCES:.c=)
LINTSRC =	tabXXX.c
SHELL =		/bin/sh

.SUFFIXES:	.tab

.o.tab:
	cc $(LDFLAGS) table.o $*.o
	./a.out $@

.c.tab:
	cc -c $(CFLAGS) $<
	cc $(LDFLAGS) table.o $*.o
	./a.out $@


all:		$(TABFILES)

table:		$(TABFILES)

$(TABFILES):	table.o

$(TABS):	$(TABFILES)
		cp $@.tab $@

table.o:	table.c table.h
		cc -c $(CFLAGS) table.c

install:	$(TABS)
		cp $(TABS) $(DESTDIR)
		rm $(TABS)

lint:		table.c elbat.c structure.c table.h
		lint $(LFLAGS) table.c $(LINTSRC)
		lint $(LFLAGS) elbat.c structure.c

elbat:		elbat.o structure.o
	    	cc $(LDFLAGS) -o elbat elbat.o structure.o

structure.c:	table.h
		echo 'char	*structure = "\' > structure.c
		sed -n -e '1,/zzz/s/$$/\\n\\/p' table.h >> structure.c
		echo '";' >> structure.c

shar:
		shar -a README Makefile table.5 elbat.c table.c table.h \
			$(SOURCES) > TABLE.shar

clean:
		rm -f a.out *.o core structure.c

realclean:	clean
		rm -f $(TABFILES) $(TABS) elbat
