Skip to content

Commit d913758

Browse files
committed
fix
1 parent 8a52f2e commit d913758

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

Makefile

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,29 @@ MAIN = ./main.go
66
PREFIX ?= $(shell go env GOPATH)
77
XRAY_OS ?=
88
XRAY_ARCH ?=
9-
XRAY_INSTALL_ARGS := $(strip $(if $(XRAY_OS),--os $(XRAY_OS)) $(if $(XRAY_ARCH),--arch $(XRAY_ARCH)))
9+
# Derive arch flag from GOARCH when not explicitly provided (helps cross-builds)
10+
XRAY_ARCH_DERIVED := $(shell \
11+
case "$(GOARCH)" in \
12+
amd64) echo "64" ;; \
13+
386) echo "32" ;; \
14+
arm64) echo "arm64-v8a" ;; \
15+
armv7|arm) echo "arm32-v7a" ;; \
16+
armv6) echo "arm32-v6" ;; \
17+
armv5) echo "arm32-v5" ;; \
18+
mips) echo "mips32" ;; \
19+
mipsle) echo "mips32le" ;; \
20+
mips64) echo "mips64" ;; \
21+
mips64le) echo "mips64le" ;; \
22+
ppc64) echo "ppc64" ;; \
23+
ppc64le) echo "ppc64le" ;; \
24+
riscv64) echo "riscv64" ;; \
25+
s390x) echo "s390x" ;; \
26+
*) echo "" ;; \
27+
esac)
28+
29+
XRAY_OS_EFFECTIVE := $(if $(XRAY_OS),$(XRAY_OS),$(GOOS))
30+
XRAY_ARCH_EFFECTIVE := $(if $(XRAY_ARCH),$(XRAY_ARCH),$(XRAY_ARCH_DERIVED))
31+
XRAY_INSTALL_ARGS := $(strip $(if $(XRAY_OS_EFFECTIVE),--os $(XRAY_OS_EFFECTIVE)) $(if $(XRAY_ARCH_EFFECTIVE),--arch $(XRAY_ARCH_EFFECTIVE)))
1032

1133
ifeq ($(GOOS),windows)
1234
OUTPUT = $(NAME).exe
@@ -100,9 +122,9 @@ ifeq ($(UNAME_S),Linux)
100122
if [ "$(DISTRO)" = "debian" ] || [ "$(DISTRO)" = "ubuntu" ] || \
101123
[ "$(DISTRO)" = "centos" ] || [ "$(DISTRO)" = "rhel" ] || [ "$(DISTRO)" = "fedora" ] || \
102124
[ "$(DISTRO)" = "arch" ]; then \
103-
sudo XRAY_OS=$(XRAY_OS) XRAY_ARCH=$(XRAY_ARCH) bash -c "$$(curl -L https://github.com/PasarGuard/scripts/raw/main/install_core.sh) $(XRAY_INSTALL_ARGS)"; \
125+
sudo bash -c "$$(curl -L https://github.com/PasarGuard/scripts/raw/main/install_core.sh) $(XRAY_INSTALL_ARGS)"; \
104126
else \
105-
XRAY_OS=$(XRAY_OS) XRAY_ARCH=$(XRAY_ARCH) bash -c "$$(curl -L https://github.com/PasarGuard/scripts/raw/main/install_core.sh) $(XRAY_INSTALL_ARGS)"; \
127+
bash -c "$$(curl -L https://github.com/PasarGuard/scripts/raw/main/install_core.sh) $(XRAY_INSTALL_ARGS)"; \
106128
fi
107129

108130
else

0 commit comments

Comments
 (0)