# Makefile for tree, June, 1990.  Greg Lee

#LEX =
#LEXLIB = -ll
# or if you don't have flex, use:
LEX = lex
LEXLIB = -ll

INSTALL=install

# Use flag -u or -t to make .tex files:
UT = -u

# Keyword required by PS driver at the begining of TeX
# \specials to incorporate line of text directly in PS output
# (see explanation at the beginning of tex.c).  Default is
# no keyword.
#DEFS = -DSKEY=\"ps::\"
#DEFS = -DSKEY=\"ps-string \"
#DEFS = -DSKEY=\"ps-string=\"
#DEFS = -DSKEY=\"pstext=\"
DEFS =

install: all
       $(INSTALL) -o $(USER) -g $(GROUP) tree ${BIN}
       $(INSTALL) -o $(USER) -g $(GROUP) tpar ${BIN}
       $(INSTALL) -o $(USER) -g $(GROUP) unpar ${BIN}
       $(INSTALL) -o $(USER) -g $(GROUP) tree.1 $(MAN)/man1

all: tree tpar unpar

tree:   tree.l tex.c
       $(LEX) tree.l
       cc $(DEFS) -O -s -o tree lex.yy.c $(LEXLIB)
       rm lex.yy.c

tpar: tpar.l
       $(LEX) tpar.l
       cc -O -s -o tpar lex.yy.c $(LEXLIB)
       rm lex.yy.c

unpar: unpar.l
       $(LEX) unpar.l
       cc -O -s -o unpar lex.yy.c $(LEXLIB)
       rm lex.yy.c

mdoc:   mdoc.l
       $(LEX) mdoc.l
       cc -O -s -o mdoc lex.yy.c $(LEXLIB)
       @rm lex.yy.c

use.tre: use.raw mdoc
       rm -f use.tre
       mdoc <use.raw >use.tre

tex:    sample.tex texsample.tex tpsample.tex use.tex

sample.tex: sample tree
       rm -f sample.tex
       @echo '--- Expect a warning about an ill-formed \tree command ---'
       tree $(UT) sample >sample.tex
tpsample.tex: tpsample tree tpar
       rm -f tpsample.tex
       tpar -t tpsample |tree $(UT) >tpsample.tex
texsample.tex: texsample tree
       rm -f texsample.tex
       tree $(UT) texsample >texsample.tex
use.tex: use.tre tree
       rm -f use.tex
       @echo '--- Expect two warnings about discarded text ---'
       tree $(UT) use.tre >use.tex

shar:
       makekit -m
       mv Part01 tree.shar1
       mv Part02 tree.shar2
       mv Part03 tree.shar3

DIST = MANIFEST Makefile README mdoc.l sample tex.c \
       texsample tpar.l tpsample tree.1 tree.l unpar.l use.raw

tar:    $(DIST)
       tar cf tree.tar $(DIST)

clean:
       rm -f *.aux *.dvi *.lof *.log *.toc *.blg *.bbl *.ilg *.ind *.idx lex.yy.c tree tpar unpar