WORKING_DIR := $(shell pwd)
PROGNAME := acm
VER := 6.0
WEBDIR := /home/www.icosaedro.it/public_html/acm

BUILD := $(shell date +%Y%m%d)
VERSION := ${VER}_${BUILD}

DISTFILE := ${PROGNAME}-${VERSION}

all:
	# Really do all (but something does not builds yet):
	#find . -mindepth 2 -name Makefile \
	#    | while read m; do make -C $$(dirname $$m) all || exit 1; done
	#
	# Only do what we really care the most:
	make -C src all

clean:
	rm -rf build-doxygen-docs-errors.txt doc/doxygen-html
	find . -mindepth 2 -name Makefile \
	    | while read m; do make -C $$(dirname $$m) clean; done

strip:

.PHONY: rebuild
rebuild: clean
	find . -mindepth 1 -type d \
	| while read d; do \
		if [ -f $$d/Makefile ]; then \
			echo "$$d"; \
			(cd $$d; check-included && make-makefile); \
		fi \
	done
	make

# SUBROUTINE:
dist_make_package: clean
	echo ${VERSION} > VERSION.txt
	cd .. && \
		ln -sf ${WORKING_DIR} ${DISTFILE} && \
		tar --create --gzip \
			--owner=root --group=root \
		    --exclude="*CVS*" \
		    --exclude="*.cvsignore" \
		    --exclude="*nbproject*" \
			--dereference \
			${DISTFILE} \
			> /tmp/${DISTFILE}.tar.gz && \
		rm ${DISTFILE} && \
		echo "Package available in /tmp/${DISTFILE}.tar.gz"

distclean: clean

dist: dist_make_package

doxygen:
	tools/build-doxygen-docs.sh

upgrade:
	@echo ""
	@echo "ACM Upgrade Procedure"
	@echo "====================="
	@echo ""
	@echo "The version of this package is `cat VERSION.txt`. Check for new releases on:"
	@echo ""
	@echo "    http://www.icosaedro.it/acm/download.html"
	@echo ""
