# This file makes the TeX to C conversion programs.
# It is appropriate for the SAS/C Development System Version 6.X by
# SAS Institute, Cary NC.  March 14, 1995, Andreas Scherer.

SHELL = execute
srcdir = .

# This is so kpathsea will get remade automatically if you change
# something in it and recompile from the package directory.
kpathsea_parent = ../..
kpathsea_dir = $(kpathsea_parent)/kpathsea
kpathsea = $(kpathsea_dir)/kpathsea.lib

# Routines used everywhere.
commono = ../lib/lib.lib $(kpathsea)

# Routines supplied by the flex package.
LEXLIB = other:lib/libfl.lib

CC = sc
WMERGE = wmerge

DEFS = define=_STRICT_ANSI define=YYBISON
CFLAGS = $(DEFS) idir=../lib idir=../.. math=IEEE noicons optimize

# You can substitute `bison -y' or `byacc' for `yacc' if you like.
YACC=bison -y # I do
LEX=flex

LIBS = $(commono) $(LEXLIB)

program = web2c fixwrites splitup regfix

.SUFFIXES:
.SUFFIXES: .o .c
.c.o:
	$(CC) $(CFLAGS) $*.c

all: $(program)

web2c:	y.tab.o lex.yy.o andyweb2c.o $(LIBS)
	$(CC) $(CFLAGS) data=far link to web2c \
	andyweb2c.o y.tab.o lex.yy.o $(LIBS)

lex.yy.o:	lex.yy.c
	$(CC) $(CFLAGS) data=far lex.yy.c
lex.yy.c:	andyweb2c.lex andyweb2c.h y.tab.o
	$(LEX) andyweb2c.lex
andyweb2c.lex:	web2c.lex web2c.lch
	$(WMERGE) web2c.lex web2c.lch andyweb2c.lex

y.tab.o:	y.tab.c
	$(CC) $(CFLAGS) data=far y.tab.c
y.tab.c y.tab.h:	andyweb2c.yacc andyweb2c.h
	@echo Expect one shift/reduce conflict.
	$(YACC) -d andyweb2c.yacc
andyweb2c.yacc:	web2c.yacc web2c.ych
	$(WMERGE) web2c.yacc web2c.ych andyweb2c.yacc

andyweb2c.o:	andyweb2c.c
	$(CC) $(CFLAGS) data=far andyweb2c.c
andyweb2c.c:	web2c.c web2c.ch y.tab.o
	$(WMERGE) web2c.c web2c.ch andyweb2c.c
andyweb2c.h:	web2c.h web2c.hch
	$(WMERGE) web2c.h web2c.hch andyweb2c.h

fixwrites:	andyfixwrites.o $(LIBS)
	$(CC) $(CFLAGS) link to fixwrites andyfixwrites.o $(LIBS)

andyfixwrites.o:	andyfixwrites.c
andyfixwrites.c:	fixwrites.c fixwrites.ch
	$(WMERGE) fixwrites.c fixwrites.ch andyfixwrites.c

splitup:	andysplitup.o $(LIBS)
	$(CC) $(CFLAGS) link to splitup andysplitup.o $(LIBS)

andysplitup.o:	andysplitup.c
andysplitup.c:	splitup.c splitup.ch
	$(WMERGE) splitup.c splitup.ch andysplitup.c

regfix:		andyregfix.o $(LIBS)
	$(CC) $(CFLAGS) link to regfix andyregfix.o $(LIBS)

andyregfix.o:	andyregfix.c
andyregfix.c:	regfix.c regfix.ch
	$(WMERGE) regfix.c regfix.ch andyregfix.c

clean:
	- delete andy\#? \#?.(bak|o|lnk|info) lex.yy.c y.tab.c y.tab.h

veryclean:	clean
	- delete fixwrites regfix splitup web2c
