# file: doc/examples/functionlang/oneprocess/Pascal/Makefile

# IMPORTED VARIABLES
LIBDIR=/usr/local/scorpion/lib
BINDIR=/usr/local/scorpion/bin
CC=cc
IDLC=$(BINDIR)/idlc
PC=pc
CFLAGS=-I$(INCDIR)/C
IDLCFLAGS=
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
SRC=main.p
OBJ=main.o
TEST=../../test
LIB=$(LIBDIR)/libidlP.a #!!!$(LIBDIR)/idlvlib.o $(LIBDIR)/idlvlib.a
SPECS=../../specs
IDLCFLAGSLOC=-s4 -I$(SPECS) -I.. -C onephasecompiler.Cdl 

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

examples : funccomp
	$(RM) $(TEST)/foo.foldedposP2.aer $(TEST)/bar.foldedposP2.aer
	/bin/time funccomp < $(TEST)/foo.in > $(TEST)/foo.foldedposP2.aer
	/bin/time funccomp < $(TEST)/bar.in > $(TEST)/bar.foldedposP2.aer

funccomp : $(OBJ) onephasecompiler.h $(LIB)
	$(PC) $(PFLAGS) -o funccomp $(OBJ) onephasecompiler.o $(LIB) 

main.o : main.p onephasecompiler.h ../../frontend/Pascal/lexical.i \
		../../frontend/Pascal/syntactic.i resolve.i typing.i sem.h \
		algorithm.i const.h
	touch frontend.h frontend.i semantic.h semantic.i sem2.h
	touch constant_fold.h constant_fold.i const2.h
	$(RM) posPconverts.i
	ln -s $(SPECS)/posPconverts.p posPconverts.i
	$(RM) lexical.i
	ln -s ../../frontend/Pascal/lexical.i lexical.i
	$(RM) syntactic.i
	ln -s ../../frontend/Pascal/syntactic.i syntactic.i
	$(PC) $(PFLAGS) -I$(SPECS) -I../../frontend/Pascal -c main.p

resolve.i : ../../semantic/Pascal/resolve.p
	$(RM) resolve.i
	ln -s ../../semantic/Pascal/resolve.p resolve.i

typing.i : ../../semantic/Pascal/typing.p
	$(RM) typing.i
	ln -s ../../semantic/Pascal/typing.p typing.i

sem.h : ../../semantic/Pascal/sem2.h
	$(RM) sem.h
	ln -s ../../semantic/Pascal/sem2.h sem.h

algorithm.i : ../../constantfold/Pascal/algorithm.p
	$(RM) algorithm.i
	ln -s ../../constantfold/Pascal/algorithm.p algorithm.i

const.h : ../../constantfold/Pascal/const2.h
	$(RM) const.h
	ln -s ../../constantfold/Pascal/const2.h const.h

onephasecompiler.h : onephasecompiler.idl \
		$(SPECS)/functionsem.idl $(SPECS)/functionsyntax.idl \
		$(SPECS)/pos.idl ../all.idl
	$(RM) sourceposition.i
	ln -s $(SPECS)/sourceposition.i sourceposition.i
	$(IDLC) $(IDLCFLAGS) $(IDLCFLAGSLOC) onephasecompiler.idl

Clean :
	$(RM) *.o onephasecompiler.h onephasecompiler.p *.list *.Cdl \
		frontend.h frontend.i pos.h main.out \
		resolve.p typing.p semantic.h semantic.i sem.h sem2.h \
		algorithm.p constant_fold.h constant_fold.i const.h const2.h
