Makefile.cross-compiles 1.1 KB

12345678910111213141516171819202122232425
  1. export PATH := $(GOPATH)/bin:$(PATH)
  2. export GO111MODULE=on
  3. LDFLAGS := -s -w
  4. os-archs=darwin:amd64 darwin:arm64 freebsd:386 freebsd:amd64 linux:386 linux:amd64 linux:arm linux:arm64 windows:386 windows:amd64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat
  5. all: build
  6. build: app
  7. app:
  8. @$(foreach n, $(os-archs),\
  9. os=$(shell echo "$(n)" | cut -d : -f 1);\
  10. arch=$(shell echo "$(n)" | cut -d : -f 2);\
  11. gomips=$(shell echo "$(n)" | cut -d : -f 3);\
  12. target_suffix=$${os}_$${arch};\
  13. echo "Build $${os}-$${arch}...";\
  14. env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_$${target_suffix} ./cmd/frpc;\
  15. env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_$${target_suffix} ./cmd/frps;\
  16. echo "Build $${os}-$${arch} done";\
  17. )
  18. @mv ./release/frpc_windows_386 ./release/frpc_windows_386.exe
  19. @mv ./release/frps_windows_386 ./release/frps_windows_386.exe
  20. @mv ./release/frpc_windows_amd64 ./release/frpc_windows_amd64.exe
  21. @mv ./release/frps_windows_amd64 ./release/frps_windows_amd64.exe