Makefile 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. GIT ?= git
  2. GO_VARS ?=
  3. GO ?= go
  4. COMMIT := $(shell $(GIT) rev-parse HEAD)
  5. VERSION ?= $(shell $(GIT) describe --tags ${COMMIT} 2> /dev/null || echo "$(COMMIT)")
  6. BUILD_TIME := $(shell LANG=en_US date +"%F_%T_%z")
  7. ROOT := github.com/flashmob/go-guerrilla
  8. LD_FLAGS := -X $(ROOT).Version=$(VERSION) -X $(ROOT).Commit=$(COMMIT) -X $(ROOT).BuildTime=$(BUILD_TIME)
  9. .PHONY: help clean dependencies test
  10. help:
  11. @echo "Please use \`make <ROOT>' where <ROOT> is one of"
  12. @echo " dependencies to go install the dependencies"
  13. @echo " guerrillad to build the main binary for current platform"
  14. @echo " test to run unittests"
  15. clean:
  16. rm -f guerrillad
  17. dependencies:
  18. $(GO_VARS) $(GO) list -f='{{ join .Deps "\n" }}' $(ROOT)/cmd/guerrillad | grep -v $(ROOT) | tr '\n' ' ' | $(GO_VARS) xargs $(GO) get -u -v
  19. $(GO_VARS) $(GO) list -f='{{ join .Deps "\n" }}' $(ROOT)/cmd/guerrillad | grep -v $(ROOT) | tr '\n' ' ' | $(GO_VARS) xargs $(GO) install -v
  20. guerrillad: *.go */*.go */*/*.go
  21. $(GO_VARS) $(GO) build -o="guerrillad" -ldflags="$(LD_FLAGS)" $(ROOT)/cmd/guerrillad
  22. test: *.go */*.go */*/*.go
  23. $(GO_VARS) $(GO) test -v .
  24. $(GO_VARS) $(GO) test -v ./tests
  25. $(GO_VARS) $(GO) test -v ./cmd/guerrillad
  26. $(GO_VARS) $(GO) test -v ./response