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.

144 lines
3.0 KiB

11 years ago
  1. LDFLAGS := $(shell go run buildscripts/gen-ldflags.go)
  2. PWD := $(shell pwd)
  3. GOPATH := $(shell go env GOPATH)
  4. BUILD_LDFLAGS := '$(LDFLAGS)'
  5. TAG := latest
  6. HOST ?= $(shell uname)
  7. CPU ?= $(shell uname -m)
  8. # if no host is identifed (no uname tool)
  9. # we assume a Linux-64bit build
  10. ifeq ($(HOST),)
  11. HOST = Linux
  12. endif
  13. # identify CPU
  14. ifeq ($(CPU), x86_64)
  15. HOST := $(HOST)64
  16. else
  17. ifeq ($(CPU), amd64)
  18. HOST := $(HOST)64
  19. else
  20. ifeq ($(CPU), i686)
  21. HOST := $(HOST)32
  22. endif
  23. endif
  24. endif
  25. #############################################
  26. # now we find out the target OS for
  27. # which we are going to compile in case
  28. # the caller didn't yet define OS himself
  29. ifndef (OS)
  30. ifeq ($(HOST), Linux64)
  31. arch = gcc
  32. else
  33. ifeq ($(HOST), Linux32)
  34. arch = 32
  35. else
  36. ifeq ($(HOST), Darwin64)
  37. arch = clang
  38. else
  39. ifeq ($(HOST), Darwin32)
  40. arch = clang
  41. else
  42. ifeq ($(HOST), FreeBSD64)
  43. arch = gcc
  44. endif
  45. endif
  46. endif
  47. endif
  48. endif
  49. endif
  50. all: install
  51. checks:
  52. @echo "Checking deps:"
  53. @(env bash $(PWD)/buildscripts/checkdeps.sh)
  54. @(env bash $(PWD)/buildscripts/checkgopath.sh)
  55. getdeps: checks
  56. @echo "Installing golint:" && go get -u github.com/golang/lint/golint
  57. @echo "Installing gocyclo:" && go get -u github.com/fzipp/gocyclo
  58. @echo "Installing deadcode:" && go get -u github.com/remyoudompheng/go-misc/deadcode
  59. @echo "Installing misspell:" && go get -u github.com/client9/misspell/cmd/misspell
  60. @echo "Installing ineffassign:" && go get -u github.com/gordonklaus/ineffassign
  61. verifiers: vet fmt lint cyclo spelling
  62. vet:
  63. @echo "Running $@:"
  64. @go vet github.com/minio/minio/cmd/...
  65. @go vet github.com/minio/minio/pkg/...
  66. fmt:
  67. @echo "Running $@:"
  68. @gofmt -s -l cmd
  69. @gofmt -s -l pkg
  70. lint:
  71. @echo "Running $@:"
  72. @${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/cmd...
  73. @${GOPATH}/bin/golint -set_exit_status github.com/minio/minio/pkg...
  74. ineffassign:
  75. @echo "Running $@:"
  76. @${GOPATH}/bin/ineffassign .
  77. cyclo:
  78. @echo "Running $@:"
  79. @${GOPATH}/bin/gocyclo -over 100 cmd
  80. @${GOPATH}/bin/gocyclo -over 100 pkg
  81. build: getdeps verifiers $(UI_ASSETS)
  82. deadcode:
  83. @${GOPATH}/bin/deadcode
  84. spelling:
  85. @${GOPATH}/bin/misspell -error `find cmd/`
  86. @${GOPATH}/bin/misspell -error `find pkg/`
  87. @${GOPATH}/bin/misspell -error `find docs/`
  88. test: build
  89. @echo "Running all minio testing:"
  90. @go test $(GOFLAGS) .
  91. @go test $(GOFLAGS) github.com/minio/minio/cmd...
  92. @go test $(GOFLAGS) github.com/minio/minio/pkg...
  93. coverage: build
  94. @echo "Running all coverage for minio:"
  95. @./buildscripts/go-coverage.sh
  96. gomake-all: build
  97. @echo "Installing minio:"
  98. @go build --ldflags $(BUILD_LDFLAGS) -o $(GOPATH)/bin/minio
  99. pkg-add:
  100. ${GOPATH}/bin/govendor add $(PKG)
  101. pkg-update:
  102. ${GOPATH}/bin/govendor update $(PKG)
  103. pkg-remove:
  104. ${GOPATH}/bin/govendor remove $(PKG)
  105. pkg-list:
  106. @$(GOPATH)/bin/govendor list
  107. install: gomake-all
  108. release: verifiers
  109. @MINIO_RELEASE=RELEASE ./buildscripts/build.sh
  110. experimental: verifiers
  111. @MINIO_RELEASE=EXPERIMENTAL ./buildscripts/build.sh
  112. clean:
  113. @echo "Cleaning up all the generated files:"
  114. @find . -name '*.test' | xargs rm -fv
  115. @rm -rf build
  116. @rm -rf release