# main makefile for VL distribution

REACTOR=.

all: $(REACTOR)/makefiles/config.mf afs-lib
	cd src && $(MAKE) REACTOR=..

SHELL = /bin/sh
DEST = /usr/local

clean:	
	@-echo 'Making clean...'
	@-cd src; rm -f *.o *.do *.bak *~ #*# core *.a *.so
	@-rm -f lib/*

install:
	@-echo "installing into" $(DEST)/include $(DEST)/lib $(DEST)/doc
	@-mkdir -p $(DEST)
	@-chmod a+rx $(DEST)
	@-mkdir -p $(DEST)/lib
	@-chmod a+rx $(DEST)/lib
	@-cp lib/* $(DEST)/lib 
	@-mkdir -p $(DEST)/doc
	@-chmod a+rx $(DEST)/doc
	@-cp doc/* $(DEST)/doc 
	@-mkdir -p $(DEST)/include/vl $(DEST)/include/cl
	@-chmod a+rx $(DEST)/include
	@-chmod a+rx $(DEST)/include/vl
	@-chmod a+rx $(DEST)/include/cl
	@-cp include/vl/* $(DEST)/include/vl
	@-cp include/cl/* $(DEST)/include/cl
	@-chmod -R a+r $(DEST)/include/vl $(DEST)/include/cl \
		$(DEST)/lib/libvl* $(DEST)/doc
	@-echo "done."

# to build multiple system libraries in afs, make 'afs-setup' first.
afs-setup:
	@-echo "Creating afs multiple-system lib directory"
	@-rm -r lib; ln -s .arch/@sys/lib lib

# if lib is a broken symbolic link, create the necessary .arch directory.
afs-lib:
	@-if test ! -d lib; then mkdir -p .arch/`sys`/lib; fi

config:
	$(MAKE) config -f makefiles/vl.mf

# --- setup -----------

# auto-generated by make-config-mf

$(REACTOR)/makefiles/config.mf:
	@-echo "=== System Configuration ==="
	@-echo "Select one of the following systems, and then run 'make <system>'."
	@-echo 
	@-echo "	linux_RH"
	@-echo "	sgi-n32"
	@-echo "	sgi-n64"
	@-echo "	sgi-o32"
	@-echo "	sun-gcc"
	@-echo 
	@-echo "After this is done, you can edit makefiles/config.mf to change"
	@-echo "compiler settings and paths. If you change the build flags, you"
	@-echo "must run 'make config' to update the headers."
	@exit 1

linux_RH:
	cp $(REACTOR)/makefiles/config-linux_RH.mf $(REACTOR)/makefiles/config.mf
	$(MAKE) config
sgi-n32:
	cp $(REACTOR)/makefiles/config-sgi-n32.mf $(REACTOR)/makefiles/config.mf
	$(MAKE) config
sgi-n64:
	cp $(REACTOR)/makefiles/config-sgi-n64.mf $(REACTOR)/makefiles/config.mf
	$(MAKE) config
sgi-o32:
	cp $(REACTOR)/makefiles/config-sgi-o32.mf $(REACTOR)/makefiles/config.mf
	$(MAKE) config
sun-gcc:
	cp $(REACTOR)/makefiles/config-sun-gcc.mf $(REACTOR)/makefiles/config.mf
	$(MAKE) config
