| 1 | export PATH := $(PATH):`go env GOPATH`/bin |
| 2 | export GO111MODULE=on |
| 3 | LDFLAGS := -s -w |
| 4 | |
| 5 | os-archs=darwin:amd64 darwin:arm64 freebsd:amd64 openbsd:amd64 linux:amd64 linux:arm:7 linux:arm:5 linux:arm64 windows:amd64 windows:arm64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat linux:riscv64 linux:loong64 android:arm64 |
| 6 | |
| 7 | all: build |
| 8 | |
| 9 | build: app |
| 10 | |
| 11 | app: |
| 12 | @$(foreach n, $(os-archs), \ |
| 13 | os=$(shell echo "$(n)" | cut -d : -f 1); \ |
| 14 | arch=$(shell echo "$(n)" | cut -d : -f 2); \ |
| 15 | extra=$(shell echo "$(n)" | cut -d : -f 3); \ |
| 16 | flags=''; \ |
| 17 | target_suffix=$${os}_$${arch}; \ |
| 18 | if [ "$${os}" = "linux" ] && [ "$${arch}" = "arm" ] && [ "$${extra}" != "" ] ; then \ |
| 19 | if [ "$${extra}" = "7" ]; then \ |
| 20 | flags=GOARM=7; \ |
| 21 | target_suffix=$${os}_arm_hf; \ |
| 22 | elif [ "$${extra}" = "5" ]; then \ |
| 23 | flags=GOARM=5; \ |
| 24 | target_suffix=$${os}_arm; \ |
| 25 | fi; \ |
| 26 | elif [ "$${os}" = "linux" ] && ([ "$${arch}" = "mips" ] || [ "$${arch}" = "mipsle" ]) && [ "$${extra}" != "" ] ; then \ |
| 27 | flags=GOMIPS=$${extra}; \ |
| 28 | fi; \ |
| 29 | echo "Build $${os}-$${arch}$${extra:+ ($${extra})}..."; \ |
| 30 | env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} $${flags} go build -trimpath -ldflags "$(LDFLAGS)" -tags frpc -o ./release/frpc_$${target_suffix} ./cmd/frpc; \ |
| 31 | env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} $${flags} go build -trimpath -ldflags "$(LDFLAGS)" -tags frps -o ./release/frps_$${target_suffix} ./cmd/frps; \ |
| 32 | echo "Build $${os}-$${arch}$${extra:+ ($${extra})} done"; \ |
| 33 | ) |
| 34 | @mv ./release/frpc_windows_amd64 ./release/frpc_windows_amd64.exe |
| 35 | @mv ./release/frps_windows_amd64 ./release/frps_windows_amd64.exe |
| 36 | @mv ./release/frpc_windows_arm64 ./release/frpc_windows_arm64.exe |
| 37 | @mv ./release/frps_windows_arm64 ./release/frps_windows_arm64.exe |