Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. freebsd-amd64 \
  19. windows-amd64
  20. all: $(ALL:%=build/%/nebula) $(ALL:%=build/%/nebula-cert)
  21. release: $(ALL:%=build/nebula-%.tar.gz)
  22. release-linux: $(ALL_LINUX:%=build/nebula-%.tar.gz)
  23. release-freebsd: build/nebula-freebsd-amd64.tar.gz
  24. bin-windows: build/windows-amd64/nebula.exe build/windows-amd64/nebula-cert.exe
  25. mv $? .
  26. bin-darwin: build/darwin-amd64/nebula build/darwin-amd64/nebula-cert
  27. mv $? .
  28. bin-freebsd: build/freebsd-amd64/nebula build/freebsd-amd64/nebula-cert
  29. mv $? .
  30. bin:
  31. go build -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula ${NEBULA_CMD_PATH}
  32. go build -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula-cert ./cmd/nebula-cert
  33. install:
  34. go install -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" ${NEBULA_CMD_PATH}
  35. go install -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert
  36. build/%/nebula: .FORCE
  37. GOOS=$(firstword $(subst -, , $*)) \
  38. GOARCH=$(word 2, $(subst -, ,$*)) \
  39. GOARM=$(word 3, $(subst -, ,$*)) \
  40. go build -trimpath -o $@ -ldflags "-X main.Build=$(BUILD_NUMBER)" ${NEBULA_CMD_PATH}
  41. build/%/nebula-cert: .FORCE
  42. GOOS=$(firstword $(subst -, , $*)) \
  43. GOARCH=$(word 2, $(subst -, ,$*)) \
  44. GOARM=$(word 3, $(subst -, ,$*)) \
  45. go build -trimpath -o $@ -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert
  46. build/%/nebula.exe: build/%/nebula
  47. mv $< $@
  48. build/%/nebula-cert.exe: build/%/nebula-cert
  49. mv $< $@
  50. build/nebula-%.tar.gz: build/%/nebula build/%/nebula-cert
  51. tar -zcv -C build/$* -f $@ nebula nebula-cert
  52. build/nebula-%.zip: build/%/nebula.exe build/%/nebula-cert.exe
  53. cd build/$* && zip ../nebula-$*.zip nebula.exe nebula-cert.exe
  54. vet:
  55. go vet -v ./...
  56. test:
  57. go test -v ./...
  58. test-cov-html:
  59. go test -coverprofile=coverage.out
  60. go tool cover -html=coverage.out
  61. bench:
  62. go test -bench=.
  63. bench-cpu:
  64. go test -bench=. -benchtime=5s -cpuprofile=cpu.pprof
  65. go tool pprof go-audit.test cpu.pprof
  66. bench-cpu-long:
  67. go test -bench=. -benchtime=60s -cpuprofile=cpu.pprof
  68. go tool pprof go-audit.test cpu.pprof
  69. proto: nebula.pb.go cert/cert.pb.go
  70. nebula.pb.go: nebula.proto .FORCE
  71. go build github.com/golang/protobuf/protoc-gen-go
  72. PATH="$(PWD):$(PATH)" protoc --go_out=. $<
  73. rm protoc-gen-go
  74. cert/cert.pb.go: cert/cert.proto .FORCE
  75. $(MAKE) -C cert cert.pb.go
  76. service:
  77. @echo > /dev/null
  78. $(eval NEBULA_CMD_PATH := "./cmd/nebula-service")
  79. ifeq ($(words $(MAKECMDGOALS)),1)
  80. $(MAKE) service ${.DEFAULT_GOAL} --no-print-directory
  81. endif
  82. .FORCE:
  83. .PHONY: test test-cov-html bench bench-cpu bench-cpu-long bin proto release service
  84. .DEFAULT_GOAL := bin