57 lines
1.2 KiB
Makefile
57 lines
1.2 KiB
Makefile
VERSION := $(shell git rev-parse --short HEAD)
|
|
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
|
BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ')
|
|
BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S')
|
|
BUILDUSER := $(shell whoami)
|
|
BUILDHOST := $(shell hostname -s)
|
|
BUILDARCH := $(shell uname -m)
|
|
|
|
FN := historyposter
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
GOLDFLAGS += -X main.Version=$(VERSION)
|
|
GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
|
|
|
|
# osx can't statically link apparently?!
|
|
ifeq ($(UNAME_S),Darwin)
|
|
GOFLAGS := -ldflags "$(GOLDFLAGS)"
|
|
endif
|
|
|
|
ifneq ($(UNAME_S),Darwin)
|
|
GOFLAGS = -ldflags "-linkmode external -extldflags -static $(GOLDFLAGS)"
|
|
endif
|
|
|
|
default: fmt
|
|
|
|
fmt:
|
|
go fmt ./...
|
|
goimports -l -w .
|
|
|
|
debug: build
|
|
GOTRACEBACK=all DEBUG=1 ./$(FN) 2>&1 | tee -a debug.log
|
|
|
|
run: build
|
|
./$(FN)
|
|
|
|
clean:
|
|
-rm ./$(FN)
|
|
|
|
build: ./$(FN)
|
|
|
|
docker:
|
|
docker build .
|
|
|
|
go-get:
|
|
cd cmd/$(FN) && go get -v
|
|
|
|
./$(FN): */*.go cmd/*/*.go go-get
|
|
cd cmd/$(FN) && go build -o ../../$(FN) $(GOFLAGS) .
|
|
|
|
vet:
|
|
go lint ./...
|
|
go vet ./...
|
|
bash -c 'test -z "$$(gofmt -l .)"'
|
|
|
|
.PHONY: build fmt test is_uncommitted docker dist hub upload-docker-image clean run rundebug default build-docker-image-dist
|