######################################################################
#
# Brimstone
##################################################
##################################################
#
# Top Level Targets
#
# TOP:		Compile with current mode
# <customername>:	Compile with stuff customer has bought
#
##################################################
#
# Standard Brimstone targets
#
# default:	Make everything
# depend:	Make include file dependencies
# clean:	Delete all junk
# neat:		Delete most junk (not customer stuff or dependencies)
# relink:	Force standard programs to relink themselves
#
##################################################

DOTCUSTOMERS=.freestone .test .noauth
CUSTOMERS=$(subst .,,${DOTCUSTOMERS})
DOTTEST=$(subst .,-o -f .,${DOTCUSTOMERS})
SUBDIR=lib test clients

TOP=.
include $(TOP)/Make.include

local remote:
	@echo Please make $(CUSTOMERS) instead

clean::
	$(RM) $(DOTCUSTOMERS) $(ENVFILE)

clobber::
	$(RM) -r BUILD

build::
	-d=BUILD/$(ARCH_DIR); (echo ./Makefile; echo ./sos.mk; echo ./Make.include; find clients lib test -name Makefile -print) | while read f; do mkdir -p $$d/`dirname $$f`; ln -s `pwd`/$$f $$d/$$f; done
	@echo "To compile: cd BUILD/$(ARCH_DIR) and type make"

##################################################
# Customer targets
#
freestone: .freestone
	$(MAKE) auto `cat $(TOP)/.env.customer`

test: .test
	$(MAKE) auto `cat $(TOP)/.env.customer`

noauth: .noauth
	$(MAKE) auto `cat $(TOP)/.env.customer`

######################################################################
# Interm targets
.freestone:
	@if [ -f .nosuchfile $(DOTTEST) ]; then $(RM) $(DOTCUSTOMERS); $(MAKE) ForceNewAuth ForceRelink; fi
	@echo USING_TEST=false USING_NULL=true USING_UNIX=true USING_HASH_STATIC=true USING_HASH_DYNAMIC=true USING_SKEY=true USING_ENIGMA=false USING_SECURID=false USING_CCARD=false BSMODE=local > $(ENVFILE)
	touch $@

.test:
	@if [ -f .nosuchfile $(DOTTEST) ]; then $(RM) $(DOTCUSTOMERS); $(MAKE) ForceNewAuth ForceRelink; fi
	@echo USING_TEST=false USING_NULL=true USING_UNIX=true USING_HASH_STATIC=true USING_HASH_DYNAMIC=true USING_SKEY=true USING_ENIGMA=flase USING_SECURID=false USING_CCARD=false BSMODE=local DEBUG_FLAG=-DDEBUG  > $(ENVFILE)
	touch $@

.noauth:
	@if [ -f .nosuchfile $(DOTTEST) ]; then $(RM) $(DOTCUSTOMERS); $(MAKE) ForceNewAuth ForceRelink; fi
	@echo USING_TEST=false USING_NULL=true USING_UNIX=true USING_HASH_STATIC=true USING_HASH_DYNAMIC=true USING_SKEY=false USING_ENIGMA=false USING_SECURID=false USING_CCARD=false BSMODE=remote DEBUG_FLAG=-DDEBUG > $(ENVFILE)
	touch $@
