######################################################################### 
#									# 
#   File: scorpion/test/Makefile
#				 					# 
#   Copyright (C) 1991 Hasnain Karampurwala
#									# 
#   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:								# 
#									# 
######################################################################### 

SHELL=/bin/sh

# IMPORTED VARS 
RUNYACC=true
RUNLEX=true
HASPASCAL=true

AR=/usr/bin/ar ru
CAT=/bin/cat
CC=/bin/cc
CI=ci
CO=co
CP=/bin/cp
FIND=/usr/bin/find
LEX=/usr/bin/lex
LINT=/usr/bin/lint
MAKE=/bin/make
MV=/bin/mv
PC=/usr/lang/pc
RANLIB=/usr/bin/ranlib
RM=/bin/rm -f
RMDIR=/usr/bin/rmdir
SED=/usr/bin/sed
SHELL=/bin/sh
STRIP=/usr/bin/strip
TOUCH=/usr/bin/touch -c
YACC=/usr/bin/yacc -d
RUNYACC=true
RUNLEX=true
HASPASCAL=true
LINTLIBRARY=true
LINTFLAGS=-abx

UTILITYVARS='AR=$(AR)' 'CC=$(CC)' 'PC=$(PC)' 'IDLC=$(IDLC)' 'FIND=$(FIND)' \
	'CFLAGS=$(CFLAGS)' 'IDLCFLAGS=$(IDLCFLAGS)' 'PFLAGS=$(PFLAGS)' \
	'CP=$(CP)' 'MV=$(MV)' 'RM=$(RM)' 'LEX=$(LEX)' 'MAKE=$(MAKE)' \
	'YACC=$(YACC)' 'MACHINE=$(MACHINE)' 'SED=$(SED)' 'SHELL=$(SHELL)'\
	'LINT=$(LINT)' 'RANLIB=$(RANLIB)' 'CAT=$(CAT)' 'TOUCH=$(TOUCH)' \
	'RMDIR=$(RMDIR)' 'STRIP=$(STRIP)'



TestPath:
	$(MAKE) -s $(UTILITYVARS) 'RUNLEX=$(RUNLEX)' 'RUNYACC=$(RUNYACC)' \
		'HASPASCAL=$(HASPASCAL)' 'LINTLIBRARY=$(LINTLIBRARY)' TestPath1
	./test
	$(RM) test

TestPath1:
	$(TOUCH) test.h
	$(CP) test.c test1.c 
	$(MV) test1.c garbage
	$(RM) garbage
	mkdir garbagedir
	$(RMDIR) garbagedir
	$(CAT) test.c | $(SED) > /dev/null
	$(FIND) . -name test.c > /dev/null
	-if ($(RUNYACC)) then \
		$(YACC) testy.y; \
		$(RM) *.tab.*; \
	else true;\
	fi
	-if ($(RUNLEX)) then \
		$(LEX) testl.l; \
		$(RM) *.yy.c; \
	else true;\
	fi
	-if ($(HASPASCAL)) then \
		$(PC) -c test.p; \
	else true;\
	fi
	-if ($(LINTLIBRARY)) then \
		$(LINT) $(LINTFLAGS) test.c; \
	else true;\
	fi
	$(MAKE) $(UTILITYVARS) test.a
	$(MAKE) $(UTILITYVARS) test
	$(STRIP) test

test: test.a
	$(CC) -o test test.a

test.a: test.c test.h
	$(CC) -c test.c
	$(AR) test.a test.o
	$(RANLIB) test.a
	
Clean:
	$(RM) *.o core a.out *.yy.* *.tab.* *.a test
