FIXWRITES=	../../bin/fixwrites
REGFIX=		../../bin/regfix
SPLITUP=	../../bin/splitup
TANGLE=		../../bin/tangle
WEB2C=		../../bin/web2c 
WEB2CLIB=	../../lib

.SUFFIXES:
.SUFFIXES: .o .c .p .ch

SRCS=		tex0.c tex1.c tex2.c tex3.c tex4.c tex5.c tex6.c tex7.c \
		tex8.c
CLEANFILES+=	tex.p tex.pool tex.c texd.h itex.c coerce.h ${SRCS}
.if exists(obj)
CLEANFILES+=	*.web *.ch
.endif

.p.c: ${.CURDIR}/${WEB2CLIB}/common.defines
	cat ${.CURDIR}/${WEB2CLIB}/common.defines \
		${.CURDIR}/${WEB2CLIB}/texmf.defines ${.IMPSRC} \
		| ${WEB2C} -t -htexmf.h \
		| ${FIXWRITES} -t \
		| ${REGFIX} > tex.c
	cat coerce.h ${.CURDIR}/fixcoerce.h > xcoerce.h
	mv xcoerce.h coerce.h

.ch.p: ${TANGLE}
	-ln -s ${.CURDIR}/${.PREFIX}.web ${.PREFIX}.web
	-ln -s ${.CURDIR}/${.PREFIX}.ch ${.PREFIX}.ch
	${TANGLE} ${.PREFIX}.web ${.PREFIX}.ch

splitup: tex.c .USE
	${SPLITUP} < tex.c	

tex.pool: tex.ch

tex0.c: splitup
tex1.c: splitup
tex2.c: splitup
tex3.c: splitup
tex4.c: splitup
tex5.c: splitup
tex6.c: splitup
tex7.c: splitup
tex8.c: splitup

.include "../Makefile.defs"
.include <bsd.prog.mk>

all:		${SRCS} tex.pool

install:
	install -c -o ${BINOWN} -g ${BINGRP}  -m 0644 tex.pool ${DESTDIR}${LIBDIR}/tex
