include Makefile.defs

all: cube 

cube: cube-config
	@echo ""
	@echo "+++++++++++++ CUBE ++++++++++++++++++++++++++"
	@if test -d src; then ( cd src; gmake all ); fi

lib:  cube-config
	@echo ""
	@echo "+++++++++++++ CUBE ++++++++++++++++++++++++++"
	@if test -d src; then ( cd src; gmake libcube.a ); fi

install: install-config
	@echo ""
	@echo "+++++++++++++ CUBE ++++++++++++++++++++++++++"
	@if test -d src; then ( cd src; gmake install ); fi	

install-lib: install-config
	@echo ""
	@echo "+++++++++++++ CUBE ++++++++++++++++++++++++++"
	@if test -d src; then ( cd src; gmake install-lib ); fi 

cube-config: cube-config.in
	@echo "#! /bin/sh " > cube-config
	@echo "prefix="${PREFIX} >> cube-config
	@cat < cube-config.in >> cube-config
	@chmod 755 cube-config

install-config:
	@echo ""
	@echo "++++++++++ Install cube-config ++++++++++++"
	./mkinstalldirs -m 755 $(BINDIR)
	./install-sh -c -m 755 cube-config $(BINDIR)

	@echo ""
	@echo "++++++++++ Install doc dir +++++++++++++++++"
	./mkinstalldirs -m 755 $(DOCDIR)
	@if test -f doc/cube.pdf; then ./install-sh -c -m 644 doc/cube.pdf $(DOCDIR); fi
	@if test -f doc/cube.ps;  then ./install-sh -c -m 644 doc/cube.ps  $(DOCDIR); fi
	./install-sh -c -m 644 doc/cube.xsd $(DOCDIR)

clean:

	@echo ""
	@echo "+++++++++++++ CUBE ++++++++++++++++++++++++++"
	rm -rf cube-config
	@if test -d src; then ( cd src; gmake clean ); fi


