You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.1KB

  1. VERSION := $(shell git rev-parse --short HEAD)
  2. COMMIT := $(shell git log --pretty=format:"%H" -1)
  3. BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
  4. BUILDTIMEFILENAME := $(shell date -u '+%Y%m%d-%H%M%SZ')
  5. BUILDTIMETAG := $(shell date -u '+%Y%m%d%H%M%S')
  6. BUILDUSER := $(shell whoami)
  7. BUILDHOST := $(shell hostname -s)
  8. BUILDARCH := $(shell uname -m)
  9. FN := sco
  10. IMAGENAME := sneak/$(FN)
  11. UNAME_S := $(shell uname -s)
  12. GOLDFLAGS += -X main.Version=$(VERSION)
  13. GOLDFLAGS += -X main.Commit=$(COMMIT)
  14. GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
  15. # osx can't statically link apparently?!
  16. ifeq ($(UNAME_S),Darwin)
  17. GOFLAGS := -ldflags "$(GOLDFLAGS)"
  18. endif
  19. ifneq ($(UNAME_S),Darwin)
  20. GOFLAGS = -ldflags "-linkmode external -extldflags -static $(GOLDFLAGS)"
  21. endif
  22. default: fmt
  23. fmt:
  24. go fmt ./...
  25. goimports -l -w .
  26. docker-build:
  27. docker build -t $(IMAGENAME) .
  28. run: go-get
  29. cd cmd/$(FN) && go run
  30. build: ./$(FN)
  31. go-get:
  32. cd cmd/$(FN) && go get -v
  33. vet:
  34. go vet ./...
  35. bash -c 'test -z "$$(gofmt -l .)"'
  36. ./$(FN): */*.go cmd/*/*.go go-get vet
  37. cd cmd/$(FN) && go build -o ../../$(FN) $(GOFLAGS) .