
#
include	$(CORALROOT)/make_include
#

MAKE=make

#
#
#CORALBIN=$(CORALROOT)/bin/MIPS
#
#CORALBIN=$(CORALROOT)/bin/SUN4
#
CORALBIN=$(CORALROOT)/bin/HP
#


#############################
#
#  To install the system with the distributed executables
#  choose CORALBIN appropriately above, and then type 
#     make exec
#  To install and compile the system form src code , type
#     make install
#  To recompile an already set up system type
#     make recompile. 
#
#############################

default:
	@echo "To install the system with the distributed executables"
	@echo "set CORALBIN in this makefile, and then type"
	@echo "   make exec"
	@echo "To install and compile the system form source code, type"
	@echo "   make install"
	@echo "To recompile an already set up system type"
	@echo "   make recompile."

exec:
	@echo "Installing executables from $(CORALBIN)."
	(cd bin; ln -s $(CORALBIN)/coral .; ln -s $(CORALBIN)/magic .; \
		 ln -s $(CORALBIN)/exist .; ln -s $(CORALBIN)/translator .;\
		 ln -s $(CORALBIN)/Explain .;\
		 chmod a+x start-server *.CORAL;)

install: compile
	(cd bin; ln -s $(CORALROOT)/src/coral .; ln -s $(CORALROOT)/magic/magic .; \
		 ln -s $(CORALROOT)/magic/exist .; ln -s $(CORALROOT)/interface/translator .;\
		 chmod a+x start-server *.CORAL;)

recompile: dependency compile

dependency:
	cd src; co Makefile; chmod u+w Makefile; make depend
	cd magic;  co Makefile; chmod u+w Makefile; make depend
	cd interface;  co Makefile; chmod u+w Makefile; make depend

compile:
	(cd magic; $(MAKE))
	(cd src; $(MAKE))
	(cd interface; $(MAKE))
	echo "done compiling coral"

clean:  
	cd exodus; make clean
	cd includes; rm -f *~
	cd interface; make clean
	cd magic; make clean
	cd src; make clean
	#cd EXAMPLES; rm -f *~ *.M core; rm -rf testdata; rm -rf testdiff
	#cd doc/manual/examples; rm -f *~ *.M core; rm -rf testdata; rm -rf testdiff

setup:  create recompile

create: exodus examples
	mkdir bin; (cd bin; ln -s $(MASTER)/bin/* .)
	ln -s $(MASTER)/doc .
	mkdir explain; (cd explain; ln -s $(MASTER)/explain/* .)
	ln -s $(MASTER)/help .
	mkdir includes; (cd includes; ln -s $(MASTER)/includes/* .)
	mkdir interface; (cd interface; ln -s $(MASTER)/interface/* .)
	mkdir magic; (cd magic; ln -s $(MASTER)/magic/* .)
	mkdir src; (cd src; ln -s $(MASTER)/src/* .)

examples:
	mkdir EXAMPLES;(cd EXAMPLES; ln -s $(MASTER)/EXAMPLES/* .)
	(cd EXAMPLES; rm -rf MORE_EXAMPLES; mkdir MORE_EXAMPLES)
	(cd EXAMPLES/MORE_EXAMPLES; ln -s $(MASTER)/EXAMPLES/MORE_EXAMPLES?RCS .; $(LINK))

exodus:
	mkdir exodus; (cd exodus; ln -s $(MASTER)/exodus/* .)

exec1:
	(cd bin; ln -s $(MASTER)/coral .; ln -s $(MASTER)/magic .; \
		 ln -s $(MASTER)/exist .; ln -s $(MASTER)/translator .;\
		 ln -s $(MASTER)/Explain .;\
		 chmod a+x start-server *.CORAL)
	(cd EXAMPLES; chmod a+x test_suite; ln -s $(MASTER)/doc/manual/examples MORE_EXAMPLES)
	(cd doc/manual/examples; chmod a+x test_suite)
