sco/Makefile
sneak 98e9eb44d3
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
maybe works now
2020-09-08 21:15:50 -07:00

47 lines
1.0 KiB
Makefile

VERSION := $(shell git rev-parse --short HEAD)
COMMIT := $(shell git log --pretty=format:"%H" -1)
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 := sco
IMAGENAME := sneak/$(FN)
UNAME_S := $(shell uname -s)
GOLDFLAGS += -X main.Version=$(VERSION)
GOLDFLAGS += -X main.Commit=$(COMMIT)
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 .
docker-build:
docker build -t $(IMAGENAME) .
run: go-get
cd cmd/$(FN) && go run
build: ./$(FN)
go-get:
cd cmd/$(FN) && go get -v
./$(FN): */*.go cmd/*/*.go go-get
cd cmd/$(FN) && go build -o ../../$(FN) $(GOFLAGS) .