BIN_NAME=formulaic

VERSION := $(shell grep "const Version " version.go | sed -E 's/.*"(.+)"$$/\1/')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
IMAGE_NAME := "elfsternberg/formulaic"

.PHONY default
default: help

.PHONY build
build:                ### Compile the formulaic binary
	@echo "building ${BIN_NAME} ${VERSION}"
	@echo "GOPATH=${GOPATH}"
	go build -ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X main.VersionPrerelease=DEV" -o bin/${BIN_NAME}

.PHONY test
test:                 ### Run the unit tests
	go test $(glide nv)

.PHONY get-dep
get-deps:             ### Install the dependencies needed to build the project
	glide install

.PHONY clean
clean:                ### Clean the directory tree
	@test ! -e bin/${BIN_NAME} || rm bin/${BIN_NAME}

.PHONY help
help:                 ### Display this help message
	@echo 'Management commands for formulaic:'
	@echo
	@echo 'Usage:'
	@perl -nl scripts/show-help.pl $(MAKEFILE_LIST)