Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. BINARY = weed/weed
  2. package = github.com/chrislusf/seaweedfs/weed
  3. GO_FLAGS = #-v
  4. SOURCE_DIR = ./weed/
  5. appname := weed
  6. sources := $(wildcard *.go)
  7. COMMIT ?= $(shell git rev-parse --short HEAD)
  8. LDFLAGS ?= -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${COMMIT}
  9. build = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -ldflags "-extldflags -static $(LDFLAGS)" -o build/$(appname)$(3) $(SOURCE_DIR)
  10. tar = cd build && tar -cvzf $(1)_$(2).tar.gz $(appname)$(3) && rm $(appname)$(3)
  11. zip = cd build && zip $(1)_$(2).zip $(appname)$(3) && rm $(appname)$(3)
  12. build_large = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -tags 5BytesOffset -ldflags "-extldflags -static $(LDFLAGS)" -o build/$(appname)$(3) $(SOURCE_DIR)
  13. tar_large = cd build && tar -cvzf $(1)_$(2)_large_disk.tar.gz $(appname)$(3) && rm $(appname)$(3)
  14. zip_large = cd build && zip $(1)_$(2)_large_disk.zip $(appname)$(3) && rm $(appname)$(3)
  15. all: build
  16. .PHONY : clean deps build linux release windows_build darwin_build linux_build bsd_build clean
  17. clean:
  18. go clean -i $(GO_FLAGS) $(SOURCE_DIR)
  19. rm -f $(BINARY)
  20. rm -rf build/
  21. deps:
  22. go get $(GO_FLAGS) -d $(SOURCE_DIR)
  23. rm -rf /home/travis/gopath/src/github.com/coreos/etcd/vendor/golang.org/x/net/trace
  24. rm -rf /home/travis/gopath/src/go.etcd.io/etcd/vendor/golang.org/x/net/trace
  25. build: deps
  26. go build $(GO_FLAGS) -ldflags "$(LDFLAGS)" -o $(BINARY) $(SOURCE_DIR)
  27. install: deps
  28. go install $(GO_FLAGS) -ldflags "$(LDFLAGS)" $(SOURCE_DIR)
  29. linux: deps
  30. mkdir -p linux
  31. GOOS=linux GOARCH=amd64 go build $(GO_FLAGS) -ldflags "$(LDFLAGS)" -o linux/$(BINARY) $(SOURCE_DIR)
  32. release: deps windows_build darwin_build linux_build bsd_build 5_byte_linux_build 5_byte_arm64_build 5_byte_darwin_build 5_byte_windows_build
  33. ##### LINUX BUILDS #####
  34. 5_byte_linux_build:
  35. $(call build_large,linux,amd64,)
  36. $(call tar_large,linux,amd64)
  37. 5_byte_darwin_build:
  38. $(call build_large,darwin,amd64,)
  39. $(call tar_large,darwin,amd64)
  40. 5_byte_windows_build:
  41. $(call build_large,windows,amd64,.exe)
  42. $(call zip_large,windows,amd64,.exe)
  43. 5_byte_arm_build: $(sources)
  44. $(call build_large,linux,arm,)
  45. $(call tar_large,linux,arm)
  46. 5_byte_arm64_build: $(sources)
  47. $(call build_large,linux,arm64,)
  48. $(call tar_large,linux,arm64)
  49. linux_build: build/linux_arm.tar.gz build/linux_arm64.tar.gz build/linux_386.tar.gz build/linux_amd64.tar.gz
  50. build/linux_386.tar.gz: $(sources)
  51. $(call build,linux,386,)
  52. $(call tar,linux,386)
  53. build/linux_amd64.tar.gz: $(sources)
  54. $(call build,linux,amd64,)
  55. $(call tar,linux,amd64)
  56. build/linux_arm.tar.gz: $(sources)
  57. $(call build,linux,arm,)
  58. $(call tar,linux,arm)
  59. build/linux_arm64.tar.gz: $(sources)
  60. $(call build,linux,arm64,)
  61. $(call tar,linux,arm64)
  62. ##### DARWIN (MAC) BUILDS #####
  63. darwin_build: build/darwin_amd64.tar.gz
  64. build/darwin_amd64.tar.gz: $(sources)
  65. $(call build,darwin,amd64,)
  66. $(call tar,darwin,amd64)
  67. ##### WINDOWS BUILDS #####
  68. windows_build: build/windows_386.zip build/windows_amd64.zip
  69. build/windows_386.zip: $(sources)
  70. $(call build,windows,386,.exe)
  71. $(call zip,windows,386,.exe)
  72. build/windows_amd64.zip: $(sources)
  73. $(call build,windows,amd64,.exe)
  74. $(call zip,windows,amd64,.exe)
  75. ##### BSD BUILDS #####
  76. bsd_build: build/freebsd_arm.tar.gz build/freebsd_386.tar.gz build/freebsd_amd64.tar.gz \
  77. build/netbsd_arm.tar.gz build/netbsd_386.tar.gz build/netbsd_amd64.tar.gz \
  78. build/openbsd_arm.tar.gz build/openbsd_386.tar.gz build/openbsd_amd64.tar.gz
  79. build/freebsd_386.tar.gz: $(sources)
  80. $(call build,freebsd,386,)
  81. $(call tar,freebsd,386)
  82. build/freebsd_amd64.tar.gz: $(sources)
  83. $(call build,freebsd,amd64,)
  84. $(call tar,freebsd,amd64)
  85. build/freebsd_arm.tar.gz: $(sources)
  86. $(call build,freebsd,arm,)
  87. $(call tar,freebsd,arm)
  88. build/netbsd_386.tar.gz: $(sources)
  89. $(call build,netbsd,386,)
  90. $(call tar,netbsd,386)
  91. build/netbsd_amd64.tar.gz: $(sources)
  92. $(call build,netbsd,amd64,)
  93. $(call tar,netbsd,amd64)
  94. build/netbsd_arm.tar.gz: $(sources)
  95. $(call build,netbsd,arm,)
  96. $(call tar,netbsd,arm)
  97. build/openbsd_386.tar.gz: $(sources)
  98. $(call build,openbsd,386,)
  99. $(call tar,openbsd,386)
  100. build/openbsd_amd64.tar.gz: $(sources)
  101. $(call build,openbsd,amd64,)
  102. $(call tar,openbsd,amd64)
  103. build/openbsd_arm.tar.gz: $(sources)
  104. $(call build,openbsd,arm,)
  105. $(call tar,openbsd,arm)