Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. export NAME=eliasdb
  2. export TAG=`git describe --abbrev=0 --tags`
  3. export CGO_ENABLED=0
  4. export GOOS=linux
  5. all: build
  6. clean:
  7. rm -f eliasdb
  8. mod:
  9. go mod init || true
  10. go mod tidy
  11. test:
  12. go test -p 1 ./...
  13. cover:
  14. go test -p 1 --coverprofile=coverage.out ./...
  15. go tool cover --html=coverage.out -o coverage.html
  16. sh -c "open coverage.html || xdg-open coverage.html" 2>/dev/null
  17. fmt:
  18. gofmt -l -w -s .
  19. vet:
  20. go vet ./...
  21. build: clean mod fmt vet
  22. go build -ldflags "-s -w" -o $(NAME) cli/eliasdb.go
  23. build-mac: clean mod fmt vet
  24. GOOS=darwin GOARCH=amd64 go build -o $(NAME).mac cli/eliasdb.go
  25. build-win: clean mod fmt vet
  26. GOOS=windows GOARCH=amd64 go build -o $(NAME).exe cli/eliasdb.go
  27. build-arm7: clean mod fmt vet
  28. GOOS=linux GOARCH=arm GOARM=7 go build -o $(NAME).arm7 cli/eliasdb.go
  29. build-arm8: clean mod fmt vet
  30. GOOS=linux GOARCH=arm64 go build -o $(NAME).arm8 cli/eliasdb.go
  31. dist: build build-win build-mac build-arm7 build-arm8
  32. rm -fR dist
  33. mkdir -p dist/$(NAME)_linux_amd64
  34. mv $(NAME) dist/$(NAME)_linux_amd64
  35. cp -fR examples dist/$(NAME)_linux_amd64
  36. cp LICENSE dist/$(NAME)_linux_amd64
  37. cp NOTICE dist/$(NAME)_linux_amd64
  38. tar --directory=dist -cz $(NAME)_linux_amd64 > dist/$(NAME)_$(TAG)_linux_amd64.tar.gz
  39. mkdir -p dist/$(NAME)_darwin_amd64
  40. mv $(NAME).mac dist/$(NAME)_darwin_amd64/$(NAME)
  41. cp -fR examples dist/$(NAME)_darwin_amd64
  42. cp LICENSE dist/$(NAME)_darwin_amd64
  43. cp NOTICE dist/$(NAME)_darwin_amd64
  44. tar --directory=dist -cz $(NAME)_darwin_amd64 > dist/$(NAME)_$(TAG)_darwin_amd64.tar.gz
  45. mkdir -p dist/$(NAME)_windows_amd64
  46. mv $(NAME).exe dist/$(NAME)_windows_amd64
  47. cp -fR examples dist/$(NAME)_windows_amd64
  48. cp LICENSE dist/$(NAME)_windows_amd64
  49. cp NOTICE dist/$(NAME)_windows_amd64
  50. tar --directory=dist -cz $(NAME)_windows_amd64 > dist/$(NAME)_$(TAG)_windows_amd64.tar.gz
  51. mkdir -p dist/$(NAME)_arm7
  52. mv $(NAME).arm7 dist/$(NAME)_arm7
  53. cp -fR examples dist/$(NAME)_arm7
  54. cp LICENSE dist/$(NAME)_arm7
  55. cp NOTICE dist/$(NAME)_arm7
  56. tar --directory=dist -cz $(NAME)_arm7 > dist/$(NAME)_$(TAG)_arm7.tar.gz
  57. mkdir -p dist/$(NAME)_arm8
  58. mv $(NAME).arm8 dist/$(NAME)_arm8
  59. cp -fR examples dist/$(NAME)_arm8
  60. cp LICENSE dist/$(NAME)_arm8
  61. cp NOTICE dist/$(NAME)_arm8
  62. tar --directory=dist -cz $(NAME)_arm8 > dist/$(NAME)_$(TAG)_arm8.tar.gz
  63. sh -c 'cd dist; sha256sum *.tar.gz' > dist/checksums.txt