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.

128 lines
3.5 KiB

9 years ago
9 years ago
  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. build = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -ldflags "-extldflags -static" -o build/$(appname)$(3) $(SOURCE_DIR)
  8. tar = cd build && tar -cvzf $(1)_$(2).tar.gz $(appname)$(3) && rm $(appname)$(3)
  9. zip = cd build && zip $(1)_$(2).zip $(appname)$(3) && rm $(appname)$(3)
  10. build_large = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -tags 5BytesOffset -ldflags "-extldflags -static" -o build/$(appname)$(3) $(SOURCE_DIR)
  11. tar_large = cd build && tar -cvzf $(1)_$(2)_large_disk.tar.gz $(appname)$(3) && rm $(appname)$(3)
  12. zip_large = cd build && zip $(1)_$(2)_large_disk.zip $(appname)$(3) && rm $(appname)$(3)
  13. all: build
  14. .PHONY : clean deps build linux release windows_build darwin_build linux_build bsd_build clean
  15. clean:
  16. go clean -i $(GO_FLAGS) $(SOURCE_DIR)
  17. rm -f $(BINARY)
  18. rm -rf build/
  19. deps:
  20. go get $(GO_FLAGS) -d $(SOURCE_DIR)
  21. build: deps
  22. go build $(GO_FLAGS) -o $(BINARY) $(SOURCE_DIR)
  23. linux: deps
  24. mkdir -p linux
  25. GOOS=linux GOARCH=amd64 go build $(GO_FLAGS) -o linux/$(BINARY) $(SOURCE_DIR)
  26. release: deps windows_build darwin_build linux_build bsd_build 5_byte_linux_build 5_byte_darwin_build 5_byte_windows_build
  27. ##### LINUX BUILDS #####
  28. 5_byte_linux_build:
  29. $(call build_large,linux,amd64,)
  30. $(call tar_large,linux,amd64)
  31. 5_byte_darwin_build:
  32. $(call build_large,darwin,amd64,)
  33. $(call tar_large,darwin,amd64)
  34. 5_byte_windows_build:
  35. $(call build_large,windows,amd64,.exe)
  36. $(call zip_large,windows,amd64,.exe)
  37. linux_build: build/linux_arm.tar.gz build/linux_arm64.tar.gz build/linux_386.tar.gz build/linux_amd64.tar.gz
  38. build/linux_386.tar.gz: $(sources)
  39. $(call build,linux,386,)
  40. $(call tar,linux,386)
  41. build/linux_amd64.tar.gz: $(sources)
  42. $(call build,linux,amd64,)
  43. $(call tar,linux,amd64)
  44. build/linux_arm.tar.gz: $(sources)
  45. $(call build,linux,arm,)
  46. $(call tar,linux,arm)
  47. build/linux_arm64.tar.gz: $(sources)
  48. $(call build,linux,arm64,)
  49. $(call tar,linux,arm64)
  50. ##### DARWIN (MAC) BUILDS #####
  51. darwin_build: build/darwin_amd64.tar.gz
  52. build/darwin_amd64.tar.gz: $(sources)
  53. $(call build,darwin,amd64,)
  54. $(call tar,darwin,amd64)
  55. ##### WINDOWS BUILDS #####
  56. windows_build: build/windows_386.zip build/windows_amd64.zip
  57. build/windows_386.zip: $(sources)
  58. $(call build,windows,386,.exe)
  59. $(call zip,windows,386,.exe)
  60. build/windows_amd64.zip: $(sources)
  61. $(call build,windows,amd64,.exe)
  62. $(call zip,windows,amd64,.exe)
  63. ##### BSD BUILDS #####
  64. bsd_build: build/freebsd_arm.tar.gz build/freebsd_386.tar.gz build/freebsd_amd64.tar.gz \
  65. build/netbsd_arm.tar.gz build/netbsd_386.tar.gz build/netbsd_amd64.tar.gz \
  66. build/openbsd_arm.tar.gz build/openbsd_386.tar.gz build/openbsd_amd64.tar.gz
  67. build/freebsd_386.tar.gz: $(sources)
  68. $(call build,freebsd,386,)
  69. $(call tar,freebsd,386)
  70. build/freebsd_amd64.tar.gz: $(sources)
  71. $(call build,freebsd,amd64,)
  72. $(call tar,freebsd,amd64)
  73. build/freebsd_arm.tar.gz: $(sources)
  74. $(call build,freebsd,arm,)
  75. $(call tar,freebsd,arm)
  76. build/netbsd_386.tar.gz: $(sources)
  77. $(call build,netbsd,386,)
  78. $(call tar,netbsd,386)
  79. build/netbsd_amd64.tar.gz: $(sources)
  80. $(call build,netbsd,amd64,)
  81. $(call tar,netbsd,amd64)
  82. build/netbsd_arm.tar.gz: $(sources)
  83. $(call build,netbsd,arm,)
  84. $(call tar,netbsd,arm)
  85. build/openbsd_386.tar.gz: $(sources)
  86. $(call build,openbsd,386,)
  87. $(call tar,openbsd,386)
  88. build/openbsd_amd64.tar.gz: $(sources)
  89. $(call build,openbsd,amd64,)
  90. $(call tar,openbsd,amd64)
  91. build/openbsd_arm.tar.gz: $(sources)
  92. $(call build,openbsd,arm,)
  93. $(call tar,openbsd,arm)