CC = gcc
CFLAGS = -O
HFILES = ./TeXit.h
FLEXFLAGS = -lfl
YACC = bison -y

# An example TeXlike output page of postscript

runTeX.ps: cTeXy_lib.ps expandPS runTeX.PS
	./expandPS < runTeX.PS > runTeX.ps
	@echo "take a look at the file runTeX.ps with ghostview"
	@echo "then take a look with more.. (the text is at the bottom"
	@echo "of the file).  If it looks to hard to enter text like"
	@echo "this, make tryTeX and use that to generate it..."

# A small program to type in text and to see what postscript will
# be needed to render it.

tryTeX: tryTeX.o TeXit.o
	$(CC) $(CFLAGS) -o tryTeX tryTeX.o TeXit.o -lm

# A small utility to better render numbers using the TeXps library

TeXnumb: TeXnumb.o TeXit.o
	$(CC) $(CFLAGS) -o TeXnumb TeXnumb.o TeXit.o -lm

# some useful utilities for piecing together postscript files

expandPS: expandPS.lex expandPS.y
	flex expandPS.lex
	$(YACC) expandPS.y
	$(CC) $(CFLAGS) -o expandPS y.tab.c $(FLEXFLAGS)
	rm y.tab.c lex.yy.c

tryTeX.o: tryTeX.c TeXit.h

TeXnumb.o: tryTeX.c TeXit.h

TeXit.o: TeXit.c TeXit.h

TeXpre.c: cTeXy_lib.ps TeXpreH_c TeXpreT_c wrapup
	./wrapup < cTeXy_lib.ps | cat TeXpreH_c - TeXpreT_c > TeXpre.c

cTeXy_lib.ps: compact TeXy_lib.PS
	./compact < TeXy_lib.PS > cTeXy_lib.ps

wrapup: wrapup.lex
	flex wrapup.lex
	$(CC) $(CFLAGS) -o wrapup lex.yy.c $(FLEXFLAGS)
	rm lex.yy.c

compact: compact.lex
	flex compact.lex
	$(CC) $(CFLAGS) -o compact lex.yy.c $(FLEXFLAGS)
	rm lex.yy.c

clean:
	rm -f *~
	rm -f TeXpre.c compact wrapup TeXnumb expandPS
	rm -f *.o core *.ps tryTeX lex.yy.c \#*#

