Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. NEBULA_CMD_PATH = "./cmd/nebula"
  2. BUILD_NUMBER ?= dev+$(shell date -u '+%Y%m%d%H%M%S')
  3. GO111MODULE = on
  4. export GO111MODULE
  5. ALL_LINUX = linux-amd64 \
  6. linux-386 \
  7. linux-ppc64le \
  8. linux-arm-5 \
  9. linux-arm-6 \
  10. linux-arm-7 \
  11. linux-arm64 \
  12. linux-mips \
  13. linux-mipsle \
  14. linux-mips64 \
  15. linux-mips64le
  16. ALL = $(ALL_LINUX) \
  17. darwin-amd64 \
  18. windows-amd64
  19. all: $(ALL:%=build/%/nebula) $(ALL:%=build/%/nebula-cert)
  20. release: $(ALL:%=build/nebula-%.tar.gz)
  21. release-linux: $(ALL_LINUX:%=build/nebula-%.tar.gz)
  22. bin-windows: build/windows-amd64/nebula.exe build/windows-amd64/nebula-cert.exe
  23. mv $? .
  24. bin-darwin: build/darwin-amd64/nebula build/darwin-amd64/nebula-cert
  25. mv $? .
  26. bin:
  27. go build -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula ${NEBULA_CMD_PATH}
  28. go build -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula-cert ./cmd/nebula-cert
  29. install:
  30. go install -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" ${NEBULA_CMD_PATH}
  31. go install -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert
  32. build/%/nebula: .FORCE
  33. GOOS=$(firstword $(subst -, , $*)) \
  34. GOARCH=$(word 2, $(subst -, ,$*)) \
  35. GOARM=$(word 3, $(subst -, ,$*)) \
  36. go build -trimpath -o $@ -ldflags "-X main.Build=$(BUILD_NUMBER)" ${NEBULA_CMD_PATH}
  37. build/%/nebula-cert: .FORCE
  38. GOOS=$(firstword $(subst -, , $*)) \
  39. GOARCH=$(word 2, $(subst -, ,$*)) \
  40. GOARM=$(word 3, $(subst -, ,$*)) \
  41. go build -trimpath -o $@ -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert
  42. build/%/nebula.exe: build/%/nebula
  43. mv $< $@
  44. build/%/nebula-cert.exe: build/%/nebula-cert
  45. mv $< $@
  46. build/nebula-%.tar.gz: build/%/nebula build/%/nebula-cert
  47. tar -zcv -C build/$* -f $@ nebula nebula-cert
  48. build/nebula-%.zip: build/%/nebula.exe build/%/nebula-cert.exe
  49. cd build/$* && zip ../nebula-$*.zip nebula.exe nebula-cert.exe
  50. vet:
  51. go vet -v ./...
  52. test:
  53. go test -v ./...
  54. test-cov-html:
  55. go test -coverprofile=coverage.out
  56. go tool cover -html=coverage.out
  57. bench:
  58. go test -bench=.
  59. bench-cpu:
  60. go test -bench=. -benchtime=5s -cpuprofile=cpu.pprof
  61. go tool pprof go-audit.test cpu.pprof
  62. bench-cpu-long:
  63. go test -bench=. -benchtime=60s -cpuprofile=cpu.pprof
  64. go tool pprof go-audit.test cpu.pprof
  65. proto: nebula.pb.go cert/cert.pb.go
  66. nebula.pb.go: nebula.proto .FORCE
  67. go build github.com/golang/protobuf/protoc-gen-go
  68. PATH="$(PWD):$(PATH)" protoc --go_out=. $<
  69. rm protoc-gen-go
  70. cert/cert.pb.go: cert/cert.proto .FORCE
  71. $(MAKE) -C cert cert.pb.go
  72. service:
  73. @echo > /dev/null
  74. $(eval NEBULA_CMD_PATH := "./cmd/nebula-service")
  75. ifeq ($(words $(MAKECMDGOALS)),1)
  76. $(MAKE) service ${.DEFAULT_GOAL} --no-print-directory
  77. endif
  78. .FORCE:
  79. .PHONY: test test-cov-html bench bench-cpu bench-cpu-long bin proto release service
  80. .DEFAULT_GOAL := bin