# file: doc/examples/functionlang/Makefile

# IMPORTED VARIABLES
BINDIR=/usr/local/scorpion/bin
LIBDIR=/usr/local/scorpion/lib
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
HASPASCAL=true

# LOCAL VARIABLES
EOPTS='BINDIR=$(BINDIR)' 'LIBDIR=$(LIBDIR)' 'HASPASCAL=$(HASPASCAL)' \
	$(UTILITYVARS)

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

example :
	cd specs; /bin/time $(MAKE) $(EOPTS)
	cd frontend ; /bin/time $(MAKE) $(EOPTS)
	cd semantic ; /bin/time $(MAKE) $(EOPTS)
	cd constantfold ; /bin/time $(MAKE) $(EOPTS)
	cd convert ; /bin/time $(MAKE) $(EOPTS)
	cd oneprocess ; /bin/time $(MAKE) $(EOPTS)

Time: example
	size frontend/C/frontend semantic/C/semantic \
		 constantfold/C/constant_fold convert/C/convert
	size oneprocess/C/funccomp
	-if ($(HASPASCAL)) then \
		size frontend/Pascal/frontend semantic/Pascal/semantic \
			constantfold/Pascal/constant_fold convert/Pascal/convert; \
		echo; \
		size oneprocess/Pascal/funccomp; \
	else true; \
	fi
	wc test/foo.in test/long.in
	/bin/time funccompC < test/foo.in > /dev/null
	/bin/time oneprocess/C/funccomp < test/foo.in > /dev/null
	/bin/time funccompC < test/long.in > /dev/null
	/bin/time oneprocess/C/funccomp < test/long.in > /dev/null
	-if ($(HASPASCAL)) then \
		/bin/time funccompP < test/foo.in > /dev/null; \
		echo; \
		/bin/time oneprocess/Pascal/funccomp < test/foo.in > /dev/null ; \
		echo; \
		/bin/time funccompP < test/long.in > /dev/null; \
		echo; \
		/bin/time oneprocess/Pascal/funccomp < test/long.in > /dev/null; \
	else true; \
	fi

Clean:
	cd specs ; $(MAKE) Clean 'RM=$(RM)'
	cd frontend ; $(MAKE) Clean 'RM=$(RM)'
	cd semantic ; $(MAKE) Clean 'RM=$(RM)'
	cd constantfold ; $(MAKE) Clean 'RM=$(RM)'
	cd convert ; $(MAKE) Clean 'RM=$(RM)'
	cd oneprocess ; $(MAKE) Clean 'RM=$(RM)'
