Makefile 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 LICENSE dist/$(NAME)_linux_amd64
  36. cp NOTICE dist/$(NAME)_linux_amd64
  37. tar --directory=dist -cz $(NAME)_linux_amd64 > dist/$(NAME)_$(TAG)_linux_amd64.tar.gz
  38. mkdir -p dist/$(NAME)_darwin_amd64
  39. mv $(NAME).mac dist/$(NAME)_darwin_amd64/$(NAME)
  40. cp LICENSE dist/$(NAME)_darwin_amd64
  41. cp NOTICE dist/$(NAME)_darwin_amd64
  42. tar --directory=dist -cz $(NAME)_darwin_amd64 > dist/$(NAME)_$(TAG)_darwin_amd64.tar.gz
  43. mkdir -p dist/$(NAME)_windows_amd64
  44. mv $(NAME).exe dist/$(NAME)_windows_amd64
  45. cp LICENSE dist/$(NAME)_windows_amd64
  46. cp NOTICE dist/$(NAME)_windows_amd64
  47. tar --directory=dist -cz $(NAME)_windows_amd64 > dist/$(NAME)_$(TAG)_windows_amd64.tar.gz
  48. mkdir -p dist/$(NAME)_arm7
  49. mv $(NAME).arm7 dist/$(NAME)_arm7
  50. cp LICENSE dist/$(NAME)_arm7
  51. cp NOTICE dist/$(NAME)_arm7
  52. tar --directory=dist -cz $(NAME)_arm7 > dist/$(NAME)_$(TAG)_arm7.tar.gz
  53. mkdir -p dist/$(NAME)_arm8
  54. mv $(NAME).arm8 dist/$(NAME)_arm8
  55. cp LICENSE dist/$(NAME)_arm8
  56. cp NOTICE dist/$(NAME)_arm8
  57. tar --directory=dist -cz $(NAME)_arm8 > dist/$(NAME)_$(TAG)_arm8.tar.gz
  58. sh -c 'cd dist; sha256sum *.tar.gz' > dist/checksums.txt