#sccs	"@(#)roff:Makefile	1.8"

#	nroff/troff make file (text subsystem)	Makefile  9/25/85 ell
#	troff and fonts not built
include $(MAKEINC)/Makepre.h

# SUBDIRS = terms fonts
# fonts is not currently built
SUBDIRS = terms
PTAG = -DNROFF
IFLAG = -i
CFLAGS = -O $(PTAG) $(OPTS) ${FFLAG}
NTSOURCE = hytab.c n1.c n10.c n[2-9i].c nii.c ntab.c strs.hd t10.c \
	 t6.c tab3.c tdef.hd tw.hd uns.hd def.nr.names def.rq.names
SMSOURCE = suftabmake.c suftab.c
SOURCE = ${NTSOURCE} ${SMSOURCE}
DEPENDLIST = $(SOURCE)
NFILES = n1.o n2.o n3.o n4.o n5.o n6.o n7.o n8.o n9.o n10.o ni.o \
		nii.o ntab.o hytab.o
TFILES = n1.o n2.o n3.o n4.o n5.o t6.o n7.o n8.o n9.o t10.o ni.o \
		nii.o tab3.o hytab.o
STRIP=-s
ID = id.o

all:  Makeincludes comall nroff suftab 

Makeincludes: rqtab.dt nrtab.dt $(DEPENDLIST)
	$(INCCMD) $(DEPENDLIST) | $(SORT) | $(FILTER) > Makeincludes
	$(MAKE)

includes: rqtab.dt nrtab.dt $(DEPENDLIST)
	$(INCCMD) $(DEPENDLIST) | $(SORT) | $(FILTER) > Makeincludes

nroff:	$(NFILES) $(ID)
	${CC} $(IFLAG) $(OPTS) ${FFLAG} ${STRIP} -o nroff $(NFILES) $(ID)
	chmod 755 nroff

troff:	checkPTAG $(TFILES) $(ID)
	${CC} $(IFLAG) $(OPTS) ${FFLAG} ${STRIP} -o troff $(TFILES) $(ID)
	chmod 755 troff

checkPTAG:	;  @(if [ -n "$(PTAG)" ];\
			then (echo "must use PTAG="; exit 1);\
			else exit 0; fi)

n[18].o::	tdef.hd strs.hd tw.hd uns.hd
	
n[2-79].o:	tdef.hd strs.hd tw.hd

nii.o:	tw.hd

#	***** NOTE *****  the 300 in the next line is hardwired for (NN)
nrtab.dt: bldtab def.nr.names
	./bldtab 300 def.nr.names > nrtab.dt

./nrtab.dt: nrtab.dt

#	***** NOTE *****  the 350 in the next line is hardwired for (NM)
rqtab.dt:  bldtab def.rq.names
	./bldtab 350 def.rq.names > rqtab.dt

./rqtab.dt: rqtab.dt

suftab:	suftabmake.c suftab.c $(ID)
	${CC} suftabmake.c -o suftabmake $(ID)
	./suftabmake
	chmod 644 suftab

bldtab:	bldtab.c tdef.hd
	$(CC) -s -O -o bldtab bldtab.c


dnroff:	$(NFILES)
	${CC} $(IFLAG) $(OPTS) ${FFLAG} -o dnroff $(NFILES)
dtroff:	checkPTAG $(TFILES)
	${CC} $(IFLAG) $(OPTS) ${FFLAG} -o dtroff $(TFILES)

clean: comclean
	rm -f *.o 

clobber: clean comclobber
	rm -f nroff troff suftab dnroff dtroff suftabmake bldtab ??tab.dt id.c

id.c: roff.sl
	mkslid > id.c
	
populate: $(SUBDIRS) fonts
	UNIT=`cat .unit`; export UNIT; \
	for D in $(SUBDIRS) fonts; \
	do \
		( \
		cd $$D; echo "$$UNIT/$$D" >.unit; echo "** $$D **:"; getunit; \
		) \
	done

$(SUBDIRS) fonts:
	mkdir $@

install: cominstall
	$(INSTALL) -i$(EXITFLAG) nroff $(INSDIR) $(PROTOFILE)
	$(INSTALL) -i$(EXITFLAG) suftab $(INSDIR) $(PROTOFILE)

include Makeincludes
include $(MAKEINC)/Makepost.h
