1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-27 01:24:41 +01:00
gojekyll/Makefile

55 lines
1.7 KiB
Makefile
Raw Normal View History

2017-06-20 15:00:04 +02:00
BINARY = gojekyll
PACKAGE = github.com/osteele/gojekyll
2017-07-18 15:34:54 +02:00
SOURCEDIR = .
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
2017-06-20 15:00:04 +02:00
COMMIT_HASH = `git rev-parse --short HEAD 2>/dev/null`
2017-07-18 15:34:54 +02:00
BUILD_DATE = `date +%FT%T%z`
2017-07-19 18:25:59 +02:00
VERSION := $(COMMIT_HASH)
OS := $(shell uname -o)
2017-06-20 15:00:04 +02:00
2017-07-19 18:25:59 +02:00
LDFLAGS=-ldflags "-X ${PACKAGE}/cmd.Version=${VERSION} -X ${PACKAGE}/cmd.BuildDate=${BUILD_DATE}"
2017-06-20 15:00:04 +02:00
2017-07-13 02:01:17 +02:00
.DEFAULT_GOAL: build
2017-07-19 18:25:59 +02:00
.PHONY: build clean deps setup install lint release test help
2017-06-20 15:00:04 +02:00
$(BINARY): $(SOURCES)
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
2017-07-18 15:34:54 +02:00
rm -f ${BINARY}
2017-06-20 15:00:04 +02:00
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
go build -race ${LDFLAGS} -o ${BINARY}-race ${PACKAGE}
2017-07-19 18:25:59 +02:00
release: build
mkdir -p dist
2017-07-19 19:02:19 +02:00
tar -cvzf dist/$(BINARY)_$(VERSION)_$(OS:GNU/%=%)_$(shell uname -m).tar.gz $(BINARY) LICENSE README.md
2017-07-19 18:25:59 +02:00
2017-07-13 02:01:17 +02:00
setup: ## install dependencies and development tools
2017-07-19 18:49:43 +02:00
go get -t -u ./...
go get github.com/alecthomas/gometalinter
2017-06-20 15:00:04 +02:00
gometalinter --install
install: ## compile and install the executable
2017-07-15 23:03:55 +02:00
go install ${LDFLAGS} ${PACKAGE}
2017-06-20 15:00:04 +02:00
2017-07-13 02:01:17 +02:00
lint: ## Run all the linters
2017-07-26 16:33:34 +02:00
gometalinter ./... --tests --deadline=5m --disable=gotype --disable=aligncheck
2017-06-20 15:00:04 +02:00
test: ## test the package
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}'