MAILGREPWEB_HTDOCS=$(DESTDIR)/usr/share/noris-mailgrep-web/htdocs
MAILGREPWEB_CONFIG=$(DESTDIR)/etc/noris-mailgrep-web
APACHE_INCLUDES_AVAILABLE=$(DESTDIR)/etc/apache2/includes-intra

.PHONY: all install clean help release
.DEFAULT_GOAL := help

# Test: make DESTDIR=/tmp/noris-mailgrep-web install
install:  ## Installs noris-mailgrep-web locally (DESTDIR compatible)
	install --directory $(MAILGREPWEB_HTDOCS)
	install --directory $(MAILGREPWEB_CONFIG)
	install --directory $(APACHE_INCLUDES_AVAILABLE)

	cp --force examples/mailgrep-config.php.example $(MAILGREPWEB_CONFIG)
	cp --force examples/mailgrep-web.conf.example $(APACHE_INCLUDES_AVAILABLE)

	cp --recursive src/. $(MAILGREPWEB_HTDOCS)

clean:  ## Removes packaging debris
	rm --force debian/files \
		*-stamp \
		debian/noris-mailgrep-web.debhelper.log \
		debian/noris-mailgrep-web.substvars
	rm --force --recursive debian/noris-mailgrep-web

release: ## Interactively creates a debian release
	@bash release

# See http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:  ## Prints what you are reading
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
	    awk 'BEGIN { \
	            FS = ":.*?## "; \
	            printf "\033[0;33m%s\033[0m\n", "Available targets:" \
	        }; { \
	            printf "  \033[0;32m%-18s\033[0m %s\n", $$1, $$2 \
        }'
    #                                 ^^ 1. column width
