Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # PLATFORMS := darwin/amd64 darwin/arm64 freebsd/amd64 linux/386 linux/amd64 linux/arm linux/arm64 linux/mipsle windows/386 windows/amd64 windows/arm windows/arm64
  2. PLATFORMS := linux/amd64 linux/386 linux/arm linux/arm64 linux/mipsle linux/riscv64 windows/amd64
  3. temp = $(subst /, ,$@)
  4. os = $(word 1, $(temp))
  5. arch = $(word 2, $(temp))
  6. #all: web.tar.gz $(PLATFORMS) fixwindows zoraxy_file_checksum.sha1
  7. all: clear_old $(PLATFORMS) fixwindows
  8. binary: $(PLATFORMS)
  9. hash: zoraxy_file_checksum.sha1
  10. web: web.tar.gz
  11. clean:
  12. rm -f zoraxy_*_*
  13. rm -f web.tar.gz
  14. $(PLATFORMS):
  15. @echo "Building $(os)/$(arch)"
  16. GOROOT_FINAL=Git/ GOOS=$(os) GOARCH=$(arch) $(if $(filter linux/arm,$(os)/$(arch)),GOARM=6,) CGO_ENABLED="0" go build -o './dist/zoraxy_$(os)_$(arch)' -ldflags "-s -w" -trimpath
  17. # GOROOT_FINAL=Git/ GOOS=$(os) GOARCH=$(arch) GOARM=6 go build -o './dist/zoraxy_$(os)_$(arch)' -ldflags "-s -w" -trimpath
  18. fixwindows:
  19. -mv ./dist/zoraxy_windows_amd64 ./dist/zoraxy_windows_amd64.exe
  20. # -mv ./dist/zoraxy_windows_arm64 ./dist/zoraxy_windows_arm64.exe
  21. clear_old:
  22. -rm -rf ./dist/
  23. -mkdir ./dist/
  24. web.tar.gz:
  25. @echo "Removing old build resources, if exists"
  26. -rm -rf ./dist/
  27. -mkdir ./dist/
  28. @echo "Moving subfolders to build folder"
  29. -cp -r ./web ./dist/web/
  30. -cp -r ./system ./dist/system/
  31. @ echo "Remove sensitive information"
  32. -rm -rf ./dist/certs/
  33. -rm -rf ./dist/conf/
  34. -rm -rf ./dist/rules/
  35. @echo "Creating tarball for all required files"
  36. -rm ./dist/web.tar.gz
  37. -cd ./dist/ && tar -czf ./web.tar.gz system/ web/
  38. @echo "Clearing up unzipped folder structures"
  39. -rm -rf "./dist/web"
  40. -rm -rf "./dist/system"
  41. zoraxy_file_checksum.sha1:
  42. @echo "Generating the checksum, if sha1sum installed"
  43. -sha1sum ./dist/web.tar.gz > ./dist/zoraxy_file_checksum.sha1