# -*- Mode: Makefile; Modified: "Wed Jan 26 00:11:00 2000 by dbs"; -*- 

### This makefile controls building Chombo libraries.
### It is nearly identical to `$CHOMBO_HOME/{test,example}/GNUmakefile'.

### The way this makefile works is the target specified by the user
### on the command line is treated as the `action' to perform on all
### the `libsrc' subdirectories.  In the rules, the subdirectories are
### treated like targets and the action is specified by a variable.
### The makefile builds each directory target by invoking make
### recursively on the directory with the action as the recursive target.
### This assumes that the makefiles in the subdirectories implement all
### the actions in the $(_all_actions) variable.

## Assume that the current dir is `Chombo-0.xx/libsrc' and set the
## default for $CHOMBO_HOME
CHOMBO_HOME := $(shell pwd)/..
AUTONAME = TRUE

## This causes all commands to be executed with `csh' instead of the
## default `sh'.  The `-f' option makes csh load faster by skipping
## the user's init files (we don't want them anyway).
##[NOTE: do _not_ change this unless you really know what you're doing!]
SHELL = /bin/csh -f


##
## The `DIRS' variable must be defined to be the names of the subdirectories
## to be built.  The user can override this on the command line to build only
## some of the directories.
##
DIRS = BoxTools 

##
## These are the actions (targets for the recursive make) supported by this
## makefile.  It assumes the makefiles in the subdirectories support them too.
##   all        builds all the libraries
##   lib        synonym for `all'
##   clean      deletes files for this configuration
##   realclean  deletes files for all configurations
##
_all_actions = all lib clean realclean include

.PHONY: $(_all_actions) $(DIRS) usage

##
## Default target
##
usage:
	@echo "This makefile supports targets:"
	@echo "     $(_all_actions) usage $(DIRS) [DIRS=]"

##
## For each action, set the action variable to tell the recursive
## makefile what to do.  There should be a separate dependency for
## every value in $(_all_actions).
##[NOTE: the `NODEPENDS=TRUE' variable disables automatic
##       dependency analysis in the recursive makefile, which is only
##       needed for actions that compile or link code.]
##[NOTE: running `include' before running `lib' or `all' will not put 
##       any of the ChomboFortran header files in the include directory.
##       Caveat usor.]
##
all       : _action = all
lib       : _action = lib
clean     : _action = clean     NODEPENDS=TRUE
realclean : _action = realclean NODEPENDS=TRUE
include:    _action = include   NODEPENDS=TRUE# #[NOTE: don't move the ":"]

# this dependency ensures the action is done for every directory.
$(_all_actions) : $(DIRS)

# this rule performs the action
$(DIRS):
	$(MAKE) --directory $@ $(_action)
