2017-06-20 15:00:04 +02:00
|
|
|
SOURCEDIR=.
|
|
|
|
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
|
|
|
|
|
|
|
|
BINARY = gojekyll
|
|
|
|
PACKAGE = github.com/osteele/gojekyll
|
|
|
|
COMMIT_HASH = `git rev-parse --short HEAD 2>/dev/null`
|
|
|
|
|
2017-07-13 02:40:05 +02:00
|
|
|
LDFLAGS=-ldflags "-X ${PACKAGE}.commands.Version=${COMMIT_HASH}"
|
2017-06-20 15:00:04 +02:00
|
|
|
|
2017-07-13 02:01:17 +02:00
|
|
|
.DEFAULT_GOAL: build
|
|
|
|
.PHONY: build clean deps setup install lint test help
|
2017-06-20 15:00:04 +02:00
|
|
|
|
|
|
|
$(BINARY): $(SOURCES)
|
2017-07-14 01:01:30 +02:00
|
|
|
go build ${LDFLAGS} -o ${BINARY} ${PACKAGE}
|
2017-07-14 01:39:53 +02:00
|
|
|
|
2017-06-20 15:00:04 +02:00
|
|
|
build: $(BINARY) ## compile the package
|
|
|
|
|
|
|
|
clean: ## remove binary files
|
|
|
|
rm -fI ${BINARY}
|
|
|
|
|
2017-07-14 01:39:53 +02:00
|
|
|
imports: ## list imports
|
|
|
|
go list -f '{{join .Imports "\n"}}' ./... | grep -v `go list -f '{{.ImportPath}}'` | grep '\.' | sort | uniq
|
|
|
|
|
2017-06-22 23:37:32 +02:00
|
|
|
deps: ## list dependencies
|
2017-07-14 01:39:53 +02:00
|
|
|
go list -f '{{join .Deps "\n"}}' ./... | grep -v `go list -f '{{.ImportPath}}'` | grep '\.' | sort | uniq
|
2017-06-20 15:00:04 +02:00
|
|
|
|
2017-07-14 01:39:53 +02:00
|
|
|
race: ## build a binary with race detection
|
2017-07-14 01:01:30 +02:00
|
|
|
go build -race ${LDFLAGS} -o ${BINARY}-race ${PACKAGE}
|
|
|
|
|
2017-07-13 02:01:17 +02:00
|
|
|
setup: ## install dependencies and development tools
|
2017-06-20 15:00:04 +02:00
|
|
|
go get -u github.com/alecthomas/gometalinter
|
|
|
|
gometalinter --install
|
|
|
|
|
|
|
|
install: ## compile and install the executable
|
|
|
|
go install ${LDFLAGS} ${PACKAGE}/cmd/gojekyll
|
|
|
|
|
2017-07-13 02:01:17 +02:00
|
|
|
lint: ## Run all the linters
|
2017-07-15 03:30:42 +02:00
|
|
|
gometalinter ./... --disable=gotype --disable=aligncheck
|
2017-06-20 15:00:04 +02:00
|
|
|
|
|
|
|
test: ## test the package
|
2017-06-22 21:21:47 +02:00
|
|
|
go test ./...
|
2017-06-20 15:00:04 +02:00
|
|
|
|
|
|
|
# Source: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
|
|
|
|
help:
|
|
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|