all: install
.PHONY: .

#
##  install
###
install: cabal/install lib/install cli/install web/install
cabal/install:
	cabal update $(CABAL_FLAGS) $(CABAL_UPDATE_FLAGS)
	cabal install -v $(CABAL_FLAGS) $(CABAL_INSTALL_FLAGS) cabal
.PHONY: lib cli web
lib lib/install:
	cabal install -v --force-reinstalls $(CABAL_FLAGS) $(CABAL_INSTALL_FLAGS) ./lib
cli cli/install:
	cabal install -v --force-reinstalls $(CABAL_FLAGS) $(CABAL_INSTALL_FLAGS) ./cli
web web/install:
	cabal install -v --force-reinstalls $(CABAL_FLAGS) $(CABAL_INSTALL_FLAGS) ./web

#
##  clean
###
clean: lib/clean cli/clean web/clean doc/clean
lib/clean:
	(cd lib && cabal clean)
cli/clean:
	(cd cli && cabal clean)
web/clean:
	(cd web && cabal clean)

#
##  test
###
test: lib/test cli/test web/test
lib/test:
	(cd lib && cabal test --show-details=always $(CABAL_FLAGS) $(CABAL_TEST_FLAGS))
cli/test:
	(cd cli && cabal test --show-details=always $(CABAL_FLAGS) $(CABAL_TEST_FLAGS))
web/test:
	(cd web && cabal test --show-details=always $(CABAL_FLAGS) $(CABAL_TEST_FLAGS))
%/install/test: CABAL_INSTALL_FLAGS+=--enable-tests
%/install/test: %/install
	

#
##  doc
###
.PHONY: doc
doc: doc/xhtml lib/doc cli/doc web/doc
lib/doc:
	(cd lib && cabal haddock --hyperlink-source $(CABAL_FLAGS) $(CABAL_HADDOCK_FLAGS))
cli/doc:
	(cd cli && cabal haddock --hyperlink-source $(CABAL_FLAGS) $(CABAL_HADDOCK_FLAGS))
web/doc:
	(cd web && cabal haddock --hyperlink-source $(CABAL_FLAGS) $(CABAL_HADDOCK_FLAGS))
doc/%: .
	$(MAKE) -C doc $*

#
##  dev
###
%/dev: CABAL_INSTALL_FLAGS+=-fdev
%/dev: %
	

#
##  not-threaded
###
%/not-threaded: CABAL_INSTALL_FLAGS+=-f-threaded
%/not-threaded: %
	
#