# @(#)makefile	1.8 for STAR_Base, 2/12/93
#*******************************************************************************
#
# This code was written and designed by 
# Andrew Gene HALL of I.N. Services Pty. Ltd., Scarborough WA, Australia,
# for the 
# University of Western Australia, Crawley WA, Australia.
# 
#******************************************************************************/
# installation details
BIN_LOC = $(HOME)/bin

# configuration
#CFLAGS = -O -ansi          # Gnu compiler 
#CFLAGS = -g -qlanglvl=ansi # IBM RS6000
CFLAGS = -g -common -check -DREGEX_MALLOC # DEC 5000
#CFLAGS = -g -common -check # DEC 5000
#CFLAGS =  -Aa -g           # HP Snake
LDFLAGS =
INCS = sf_space.h request_space.h star.h getopt.h diagmesg.h  operators.h printsf.h utilitys.h sf_search.h interpret.h  marker.h expand.h dictionary.h find.h regex.h search.h
SRCS = star.y star.l sb.c getopt.c diagmesg.c operators.c printsf.c request.y request.l sf_search.c interpret.c marker.c expand.c dictionary.c find.c alloca.c strdup.c regex.c tfind.c tsearch.c
TMP_SRCS = parse_star.c star_scanner.c parse_request.c request_scanner.c
OBJS = sb.o parse_star.o getopt.o diagmesg.o printsf.o parse_request.o sf_search.o operators.o interpret.o marker.o expand.o dictionary.o find.o alloca.o strdup.o regex.o tfind.o tsearch.o

# programs
#CC = gcc # Gnu compiler
#CC = cc  # HP's ansi compiler
CC = c89 # DEC and IBM
CP = /usr/bin/cp
GET = sccs get
LN = /usr/bin/ln -s
MV = mv
VGRIND = vgrind
VFLAGS = -s10
REL = 
RM = rm
LEX = flex
YACC = bison
YFLAGS = -vt

sb: $(INCS) $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o sb

tar: Makefile
	tar cvf sb.tar $(INCS) $(SRCS) $(TMP_SRCS) sb.1 sb.1.cat Makefile
	compress sb.tar
	rm Makefile

test:
	./test

Makefile:
	$(GET) -p makefile > Makefile

clean:
	$(RM) -f core a.out *.o *.ps $(TMP_SRCS)
	sccs clean

install:
	$(RM) -f $(BIN_LOC)/sb
	$(LN) $(PWD)/sb $(BIN_LOC)

print: star_abstract.ps star_concrete.ps star_domains.ps star_functions.ps

ps: $(SRCS) $(INCS)
	make $<.ps

sources: $(SRCS)
$(SRCS):
	$(GET) $(REL) $@

includes: $(INCS)
$(INCS):
	$(GET) $(REL) $@

parse_star.c: star.y
	$(YACC) $(YFLAGS) star.y
	$(MV) star.tab.c $@

parse_request.c: request.y
	$(YACC) $(YFLAGS) request.y
	$(MV) request.tab.c $@

star_scanner.c: star.l
	$(LEX) -t star.l > star_scanner.c

request_scanner.c: request.l
	flex -t request.l > request_scanner.c

parse_star.o: parse_star.c star.h star_scanner.c
	$(CC) $(CFLAGS) -DYYDEBUG -DYYERROR_VERBOSE -c parse_star.c 

parse_request.o: parse_request.c request_scanner.c
	$(CC) $(CFLAGS) -DYYDEBUG -DYYERROR_VERBOSE -c parse_request.c 


.h~:
	$(GET) $(GFLAGS) $<

.c.o:
	$(CC) $(CFLAGS) -c $<

.y.ps:
	$(VGRIND) $(VFLAGS) -ly $< > $@
.y~.ps:
	$(GET) $(GFLAGS) $<
	$(VGRIND) $(VFLAGS) -ly $< > $@

.l.ps:
	$(VGRIND) $(VFLAGS) -lc $< > $@
.l~.ps:
	$(GET) $(GFLAGS) $<
	$(VGRIND) $(VFLAGS) -lc $< > $@

.ds.ps:
	$(VGRIND) -d $(HOME)/lib/vgrindefs $(VFLAGS) -lds $< > $@
.ds~.ps:
	$(GET) $(GFLAGS) $<
	$(VGRIND) -d $(HOME)/lib/vgrindefs $(VFLAGS) -lds $< > $@

.bnf.ps:
	$(VGRIND) -d $(HOME)/lib/vgrindefs $(VFLAGS) -lbnf $< > $@
.bnf~.ps:
	$(GET) $(GFLAGS) $<
	$(VGRIND) -d $(HOME)/lib/vgrindefs $(VFLAGS) -lbnf $< > $@

# for Borland Make
.SUFFIXES: .ds .ds~ .bnf .bnf~ .ps
