#
# $Id: Makefile,v 1.32 2011/06/03 19:56:31 thomasw Exp $
#
# General build makefile.  (Main)


## Change these if you wish to change default installation directories.
export LIBDIR = /usr/local/lib
export INCLUDEDIR = /usr/local/include
export EXPDIR = /usr/local/share/seamax
export APPDIR = /usr/local/bin

## Change these if your system is configured differently.
export PWD 	= /bin/pwd
export CP 	= /bin/cp
export RM 	= /bin/rm
export MKDIR 	= /bin/mkdir
export CC 	= /usr/bin/gcc
export CXX 	= /usr/bin/g++
export AR 	= /usr/bin/ar

## ============================================================================
## The following values are for internal package managment and should only
## be changed if you know what you are doing.
export PRODUCT = Seamax
export VERSION = 1.3.5

#CVS project name, used for install scripts
export PROJECT = seamax
SUBDIRS = lib cethernet include dox examples
CVS = `find -iname \CVS`

TAR 	= /bin/tar
GZIP 	= /bin/gzip
export DOXY	= /usr/bin/doxygen


## ============================================================================
all: subdirs

objs:
	@echo "----------------------------------------------------------------"
	@echo "Building all objects."
	@echo "----------------------------------------------------------------"
	@echo
	@for n in $(SUBDIRS); do $(MAKE) -s -C $$n objs || exit 1; done
	@echo "----------------------------------------------------------------"
	@echo "Done building objects."
	@echo "----------------------------------------------------------------"

subdirs:
	@echo "----------------------------------------------------------------"
	@echo "Building all."
	@echo "----------------------------------------------------------------"
	@echo
	@for n in $(SUBDIRS); do $(MAKE) -s -C $$n all || exit 1; done
	@echo "----------------------------------------------------------------"
	@echo "Done building all sources."
	@echo "----------------------------------------------------------------"

clean:
	@echo "----------------------------------------------------------------"
	@echo "Removing all build files."
	@echo "----------------------------------------------------------------"
	@echo
	@for n in $(SUBDIRS); do $(MAKE) -s -C $$n clean || exit 1; done
	@echo "----------------------------------------------------------------"
	@echo "Done removing all build files."
	@echo "----------------------------------------------------------------"

install:
	@echo "----------------------------------------------------------------"
	@echo "Installing $(PRODUCT) suite."
	@echo "----------------------------------------------------------------"
	@echo
	@for n in $(SUBDIRS); do $(MAKE) -s -C $$n install || exit 1; done
	@echo "----------------------------------------------------------------"
	@echo "Done installing $(PRODUCT) suite."
	@echo "----------------------------------------------------------------"

uninstall:
	@echo "----------------------------------------------------------------"
	@echo "Uninstalling $(PRODUCT) suite."
	@echo "----------------------------------------------------------------"
	@echo
	@for n in $(SUBDIRS); do $(MAKE) -s -C $$n uninstall || exit 1; done
	@echo "----------------------------------------------------------------"
	@echo "Done uninstalling $(PRODUCT) suite."
	@echo "----------------------------------------------------------------"

cleaninstall: clean install

purge: uninstall clean

distro: clean
	@echo "----------------------------------------------------------------"
	@echo "Building $(PRODUCT) distribution package!"
	@echo "----------------------------------------------------------------"
	@$(RM) -f $(PRODUCT)_$(VERSION).tar.gz
	@$(RM) -r $(CVS)
	@$(MAKE) -s -C dox dox || exit 1
	@$(TAR) -cf $(PRODUCT)_$(VERSION).tar ../${PROJECT}
	@$(GZIP) $(PRODUCT)_$(VERSION).tar
	@echo "----------------------------------------------------------------"
	@echo "Done!"
	@echo "----------------------------------------------------------------"
