######################################################################### 
#									# 
#   File: scorpion/doc/examples/functionlang/frontend/C/Makefile 
#				 					# 
#   Copyright (C) 1991 Richard Snodgrass
#									# 
#   The Scorpion System is free software in the public domain; you can  # 
#   redistribute it and/or modify it as you wish. We ask that you 	# 
#   retain credits referencing the University of Arizona and that you	# 
#   identify any changes you make.					# 
#									# 
#   Report problems to scorpion-project@cs.arizona.edu			# 
#   Direct all inquiries to:	The Scorpion Project			# 
#				Department of Computer Science		# 
#				Gould-Simpson Building			# 
#				University of Arizona			# 
#				Tucson, AZ 85721			# 
#				U.S.A.					# 
#									# 
#   Revision Log:							# 
#	$Log:$ 
#									# 
#   Edit Log:								# 
#									# 
######################################################################### 

# IMPORTED VARIABLES
LIBDIR=/usr/local/scorpion/lib
INCDIR=/usr/local/scorpion/include
BINDIR=/usr/local/scorpion/bin
CC=cc
IDLC=$(BINDIR)/idlc
PC=pc
CFLAGS=-I$(INCDIR)
IDLCFLAGS=-nc
PFLAGS=
CP=cp
MV=mv
RM=rm -f
LEX=lex
MAKE=make
YACC=yacc
UTILITYVARS='CC=$(CC)' 'IDLC=$(IDLC)' 'PC=$(PC)' 'CFLAGS=$(CFLAGS)' \
	      'IDLCFLAGS=$(IDLCFLAGS)' 'PFLAGS=$(PFLAGS)' 'CP=$(CP)' \
	      'MV=$(MV)' 'RM=$(RM)' 'LEX=$(LEX)' 'MAKE=$(MAKE)' \
	      'YACC=$(YACC)'
CI=ci
CO=co -l

# LOCAL VARIABLES
LIB=$(LIBDIR)/libidl.a
SPECS=../../specs
TEST=../../test
IDLCFLAGSLOC=-I$(SPECS) -I.. -C frontend.Cdl -nc
SRC=parser.y lex.l main.c
OBJ=main.o parser.o lex.o

###########################################################

example: frontend
	$(RM) $(TEST)/foo.syntaxC.aer $(TEST)/foo.syntaxC.log \
		$(TEST)/bar.syntaxC.aer $(TEST)/bar.syntaxC.log
	/bin/time frontend < $(TEST)/foo.in > $(TEST)/foo.syntaxC.aer
	/bin/time frontend < $(TEST)/bar.in > $(TEST)/bar.syntaxC.aer
	/bin/time $(BINDIR)/idlcheck -v -C frontend.Cdl \
		ParseTreeOut $(TEST)/foo.syntaxC.aer 2> $(TEST)/foo.syntaxC.log
	/bin/time $(BINDIR)/idlcheck -v -C frontend.Cdl \
		ParseTreeOut $(TEST)/bar.syntaxC.aer 2> $(TEST)/bar.syntaxC.log

frontend: $(OBJ) frontend.o $(LIB)
	$(CC) $(CFLAGS) -o frontend $(OBJ) frontend.o $(LIB)

frontend.o: frontend.c frontend.h
	$(CC) $(CFLAGS) -c $*.c

main.o : main.c frontend.h ${SPECS}/posCconverts.h
	$(CC) $(CFLAGS) -I${SPECS} -c main.c

parser.c tokens.h : parser.y
	$(YACC) -d parser.y
	$(MV) y.tab.c parser.c
	$(MV) y.tab.h tokens.h

parser.o : parser.c frontend.h
	$(CC) $(CFLAGS) -c parser.c

frontend.h frontend.c: frontend.idl \
		$(SPECS)/functionsyntax.idl $(SPECS)/pos.idl ../fe.idl
	$(IDLC) $(IDLCFLAGS) $(IDLCFLAGSLOC) frontend.idl

lex.o : lex.c frontend.h tokens.h
	$(CC) $(CFLAGS) -c lex.c

lex.c : lex.l
	$(LEX) lex.l
	$(MV) lex.yy.c lex.c

lextest : lextest.o lex.o
	$(CC) $(CFLAGS) -o lextest lextest.o lex.o $(LIB) -ll

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

Clean:
	$(RM) *.o frontend frontend.h pos.h tokens.h parser.c parser.out \
		lex.c frontend.Cdl *.list
