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.

86 lines
2.2 KiB

  1. ###
  2. # Find OS and Go environment
  3. # GO contains the Go binary
  4. # FS contains the OS file separator
  5. ###
  6. ifeq ($(OS),Windows_NT)
  7. GO := $(shell where go.exe 2> NUL)
  8. FS := "\\"
  9. else
  10. GO := $(shell command -v go 2> /dev/null)
  11. FS := "/"
  12. endif
  13. ifeq ($(GO),)
  14. $(error could not find go. Is it in PATH? $(GO))
  15. endif
  16. GOPATH ?= $(shell $(GO) env GOPATH)
  17. GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com
  18. ###
  19. # Functions
  20. ###
  21. go_get = $(if $(findstring Windows_NT,$(OS)),\
  22. IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\
  23. IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS)$(2)$(FS) ( cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2) ) else (cd .) &\
  24. ,\
  25. mkdir -p $(GITHUBDIR)$(FS)$(1) &&\
  26. (test ! -d $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && cd $(GITHUBDIR)$(FS)$(1) && git clone https://github.com/$(1)/$(2)) || true &&\
  27. )\
  28. cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3)
  29. mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
  30. mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd)
  31. ###
  32. # tools
  33. ###
  34. TOOLS_DESTDIR ?= $(GOPATH)/bin
  35. CERTSTRAP = $(TOOLS_DESTDIR)/certstrap
  36. PROTOBUF = $(TOOLS_DESTDIR)/protoc
  37. GOX = $(TOOLS_DESTDIR)/gox
  38. GOODMAN = $(TOOLS_DESTDIR)/goodman
  39. all: tools
  40. tools: certstrap protobuf gox goodman
  41. check: check_tools
  42. check_tools:
  43. @# https://stackoverflow.com/a/25668869
  44. @echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\
  45. $(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
  46. certstrap: $(CERTSTRAP)
  47. $(CERTSTRAP):
  48. @echo "Get Certstrap"
  49. @go get github.com/square/certstrap@338204a88c4349b1c135eac1e8c14c693ad007da
  50. protobuf: $(PROTOBUF)
  51. $(PROTOBUF):
  52. @echo "Get Protobuf"
  53. ## protobuf v1.3.0
  54. @go get github.com/gogo/protobuf/protoc-gen-gogo@0ca988a254f991240804bf9821f3450d87ccbb1b
  55. gox: $(GOX)
  56. $(GOX):
  57. @echo "Get Gox"
  58. # used to build tm-monitor binaries
  59. ## gox v1.0.1
  60. @go get github.com/mitchellh/gox@d8caaff5a9dc98f4cfa1fcce6e7265a04689f641
  61. goodman: $(GOODMAN)
  62. $(GOODMAN):
  63. @echo "Get Goodman"
  64. @go get github.com/snikch/goodman/cmd/goodman@10e37e294daa3c9a90abded60ff9924bafab3888
  65. tools-clean:
  66. rm -f $(CERTSTRAP) $(PROTOBUF) $(GOX) $(GOODMAN)
  67. rm -f tools-stamp
  68. .PHONY: all tools tools-clean