
# Copyright (c) 1991, 1992, 1993 Brad Eacker,
#              (Music, Intuition, Software, and Computers)
# All Rights Reserved

# if you don't have alloca uncomment the next lines
#ALLOCA='-Dalloca=malloc'
# ALLOCA_OBJ=alloca.o

# if u_char is already defined in your system uncomment the following
EX_FLAGS=-DUCHAR

# if you need to use bison uncomment the following
YACC=bison -y

CFLAGS=-O $(ALLOCA) $(EX_FLAGS)
YFLAGS=-d

SHELL=/bin/sh

TARGETS = dbflst tmpl dbfadd dbfdel dbfpack dbfget dbfndx dbfcreat
THINGS = tmpl.dbf
TEST_TARGS = dbftst lexi gram

DBF_SRCS=dbf.h dbf_head.c dbf_rec.c dbf_misc.c dbftst.c dbflst.c \
	token.l gram.y dbinter.c dbf_sym.h yyerr.c tmpl.c dbfadd.c \
	dbfdel.c dbfpack.c dbfget.c dbf_ndx.h dbf_ndx.c dbfndx.c \
	dbfcreat.c
DBF_OBJS=dbf_head.o dbf_rec.o dbf_misc.o dbf_ndx.o
OBJS=dbinter.o $(ALLOCA_OBJ)

all: $(TARGETS) $(THINGS)

test: $(TEST_TARGS)

everything: all test

extras: tmpl.dbf

dbftst: dbftst.o $(DBF_OBJS)
	$(CC) -o $@ dbftst.o $(DBF_OBJS)

dbflst: dbflst.o $(DBF_OBJS)
	$(CC) -o $@ dbflst.o $(DBF_OBJS)

lexi: lex.yy.c
	$(CC) $(CFLAGS) -DDEBUG lex.yy.c -o $@ -lfl

gram: gram.tab.c lex.yy.c yyerr.o $(OBJS)
	$(CC) $(CFLAGS) -DYYDEBUG gram.tab.c lex.yy.c yyerr.o $(OBJS) -o $@ -lfl

tmpl.dbf: tmpl
	./tmpl

tmpl: tmpl.o $(DBF_OBJS)
	$(CC) -o $@ tmpl.o $(DBF_OBJS)

dbfadd: dbfadd.o $(DBF_OBJS)
	$(CC) -o $@ dbfadd.o $(DBF_OBJS)

dbfdel: dbfdel.o $(DBF_OBJS)
	$(CC) -o $@ dbfdel.o $(DBF_OBJS)

dbfpack: dbfpack.o $(DBF_OBJS)
	$(CC) -o $@ dbfpack.o $(DBF_OBJS)

dbfget: dbfget.o $(DBF_OBJS)
	$(CC) -o $@ dbfget.o $(DBF_OBJS)

dbfcreat: dbfcreat.o $(DBF_OBJS)
	$(CC) -o $@ dbfcreat.o $(DBF_OBJS)

dbfndx: dbfndx.o $(DBF_OBJS)
	$(CC) -o $@ dbfndx.o $(DBF_OBJS)

lex.yy.c: token.l
	lex token.l

gram.tab.c: gram.y
	$(YACC) $(YFLAGS) gram.y
	if [ -f y.tab.c ] ; then \
		mv y.tab.c gram.tab.c; \
		mv y.tab.h gram.tab.h; \
	fi

shar:
	shar README $(DBF_SRCS) Makefile HISTORY >dbf.shar

clean:
	rm -f *.o lex.yy.c y.tab.[ch] y.output gram.tab.[ch]
	rm -f errs output *~ tg.out

clobber: clean
	rm -f $(TEST_TARGS) $(TARGETS) $(THINGS)

dbf_head.o: dbf.h dbf_head.c
dbf_rec.o: dbf.h dbf_rec.c
dbf_misc.o: dbf.h dbf_misc.c
dbf_ndx.o: dbf.h dbf_ndx.h dbf_ndx.c
yyerr.o: yyerr.c
dbinter.o: dbinter.c
dbflst.o: dbf.h dbflst.c
dbftst.o: dbf.h dbftst.c
dbfadd.o: dbf.h dbfadd.c
dbfdel.o: dbf.h dbfdel.c
dbfpack.o: dbf.h dbfpack.c
dbfget.o: dbf.h dbfget.c
dbfndx.o: dbf.h dbf_ndx.h dbfndx.c
tmpl.o: dbf.h tmpl.c
