2019-09-05 00:39:23 +00:00
|
|
|
VERSION := $(shell git rev-parse --short HEAD)
|
|
|
|
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
BUILDUSER := $(shell whoami)
|
|
|
|
BUILDHOST := $(shell hostname -s)
|
|
|
|
BUILDARCH := $(shell uname -m)
|
|
|
|
|
|
|
|
GOLDFLAGS += -X main.Version=$(VERSION)
|
|
|
|
GOLDFLAGS += -X main.Buildtime=$(BUILDTIME)
|
|
|
|
GOLDFLAGS += -X main.Builduser=$(BUILDUSER)@$(BUILDHOST)
|
|
|
|
GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
|
|
|
|
GOFLAGS = -ldflags "$(GOLDFLAGS)"
|
|
|
|
|
|
|
|
default: rundebug
|
|
|
|
|
|
|
|
rundebug: build
|
2019-10-03 12:43:02 +00:00
|
|
|
./xsum -v
|
2019-09-05 00:39:23 +00:00
|
|
|
|
|
|
|
run: build
|
|
|
|
./xsum
|
|
|
|
|
|
|
|
build: ./xsum
|
|
|
|
|
2019-10-03 13:01:13 +00:00
|
|
|
./xsum: *.go
|
2019-09-05 00:39:23 +00:00
|
|
|
go build -o $@ $(GOFLAGS) .
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
go fmt *.go
|
2019-10-03 13:01:13 +00:00
|
|
|
|
|
|
|
test:
|
|
|
|
docker build -t sneak/xsum .
|