GIT_COMMIT = $(shell git rev-parse HEAD)
BUILD_TIME = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" | tr -d '\n')

ASSETS=template static
CUR_DIR=$(shell pwd)

PARENT_PKG=amuz.es/go/
NAME=mnemonics
PKG=$(PARENT_PKG)$(NAME)

usage:
	@echo ""
	@echo "Task                 : Description"
	@echo "-----------------    : -------------------"
	@echo "make setup           : Install all necessary dependencies"
	@echo "make dev             : Generate development build"
	@echo "make test            : Run tests"
	@echo "make build           : Generate production build for current OS"
	@echo "make bootstrap       : Install cross-compilation toolchain"
	@echo "make release         : Generate binaries for all supported OSes"
	@echo "make test            : Execute test suite"
	@echo "make test-all        : Execute test suite on multiple PG versions"
	@echo "make clean           : Remove all build files and reset assets"
	@echo "make assets          : Generate production assets file"
	@echo "make dev-assets      : Generate development assets file"
	@echo ""

test:
	gopm test -cover ./...

test-all:
	@./script/test_all.sh

assets-%: asset/%/
	@echo "serialize $*"
	@$(GOPATH)/bin/go-bindata -o bind/$*/handler.go -pkg $* -prefix $* -ignore=[.]gitignore -ignore=[.]gitkeep  -prefix asset/$*/ $(BINDATA_OPTS) $<...

assets: $(addprefix assets-,${ASSETS})

dev-assets:
	@$(MAKE) --no-print-directory assets BINDATA_OPTS="-debug"

dev:
	gopm build -v
	@echo "You can now execute ./$(NAME)"

build: assets
	gopm build -v
	@echo "You can now execute ./$(NAME)"

release: assets
	@$(MAKE) --no-print-directory dependency-save
	@echo "Building binaries..."

	@echo "\nPackaging binaries...\n"
	@./script/package.sh

setup:
	go get -u github.com/gpmgo/gopm
	go get golang.org/x/tools/cmd/cover
	go get github.com/jteeuwen/go-bindata/...
	gopm get -v
clean:
	rm -f ./$(NAME)
	rm -rf ./bind/*
