BUILD=@CMAKE_BINARY_DIR@
DIST=@program@-$(VER)
REL=release-$(VER)

QUIET=`test "$(VERBOSE)" || echo -s`

all install clean confclean docs:
	@$(MAKE) $(QUIET) -C "$(BUILD)" $@

distclean: confclean
	rm -rf $(BUILD)

allclean: distclean
	rm -rf html

dox: docs

readable:
	chmod -R go+rX .

release:
	@test -n "$(VER)" || { echo "Please set VER variable!"; exit 1; }
	rm -rf $(DIST) && hg archive -r $(REL) -X .hg\* $(DIST)
	cd $(DIST) || exit 1; \
	  DATE=`hg log -r $(REL) | awk '/date:/ {printf $$3" "$$4" "$$6}'`; \
	  MATHJAX= ./configure -Dversion=$(VER) -Dreldate="$$DATE" && \
          $(MAKE) all docs readable; mv */manticore .; $(MAKE) distclean
	tar czf $(DIST).tgz $(DIST) && rm -rf $(DIST)
