-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile.cross-compiles
30 lines (26 loc) · 1.49 KB
/
Makefile.cross-compiles
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export PATH := $(PATH):`go env GOPATH`/bin
LDFLAGS := -s -w
os-archs=darwin:amd64 darwin:arm64 freebsd:amd64 linux:amd64 linux:arm linux:arm:6 linux:arm64 windows:amd64 windows:arm64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat linux:riscv64 android:arm64
all: build
build: app
app:
@$(foreach n, $(os-archs), \
os=$(shell echo "$(n)" | cut -d : -f 1); \
arch=$(shell echo "$(n)" | cut -d : -f 2); \
extra=$(shell echo "$(n)" | cut -d : -f 3); \
flags=''; \
target_suffix=$${os}_$${arch}; \
if [ "$${os}" = "linux" ] && [ "$${arch}" = "arm" ] && [ "$${extra}" != "" ] ; then \
flags=GOARM=$${extra}; \
target_suffix=$${os}_$${arch}_$${extra}; \
elif [ "$${os}" = "linux" ] && [ "$${arch}" = "mips" ] && [ "$${extra}" != "" ] ; then \
flags=GOMIPS=$${extra}; \
fi; \
env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/tiny-frpc_$${target_suffix} ./cmd/frpc;\
env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -tags nssh -o ./release/tiny-frpc-ssh_$${target_suffix} ./cmd/frpc;\
echo "Build $${os}-$${arch} done";\
)
@mv ./release/tiny-frpc_windows_amd64 ./release/tiny-frpc_windows_amd64.exe
@mv ./release/tiny-frpc-ssh_windows_amd64 ./release/tiny-frpc-ssh_windows_amd64.exe
@mv ./release/tiny-frpc_windows_arm64 ./release/tiny-frpc_windows_arm64.exe
@mv ./release/tiny-frpc-ssh_windows_arm64 ./release/tiny-frpc-ssh_windows_arm64.exe