-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile.cross-compiles
34 lines (29 loc) · 1.41 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
31
32
33
34
export PATH := $(GOPATH)/bin:$(PATH)
export GO111MODULE=on
# LDFLAGS := -linkmode external -extldflags -static -s -w
LDFLAGS := -s -w
os-archs=linux:amd64 darwin:amd64 darwin:arm64 windows:amd64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat freebsd:386 freebsd:amd64 linux:386 linux:arm linux:arm64 windows:386
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);\
gomips=$(shell echo "$(n)" | cut -d : -f 3);\
target_suffix=$${os}_$${arch};\
env CC=/usr/local/bin/x86_64-linux-musl-gcc CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -ldflags="$(LDFLAGS)" -trimpath -o ./release/DNS_Server_$${target_suffix} .;\
echo "Build $${os}-$${arch} done";\
)
@mv ./release/DNS_Server_windows_386 ./release/DNS_Server_windows_386.exe
@mv ./release/DNS_Server_windows_amd64 ./release/DNS_Server_windows_amd64.exe
linux:
@$(os-archs=linux:amd64;\
echo os-archs;\
foreach n, $(os-archs),\
os=$(shell echo "$(n)" | cut -d : -f 1);\
arch=$(shell echo "$(n)" | cut -d : -f 2);\
gomips=$(shell echo "$(n)" | cut -d : -f 3);\
target_suffix=$${os}_$${arch};\
env CC=/usr/local/bin/x86_64-linux-musl-gcc CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -ldflags="$(LDFLAGS)" -trimpath -o ./release/DNS_Server_$${target_suffix} .;\
echo "Build $${os}-$${arch} done";\
)