22
33BIN_DIR := bin
44
5+ # Detect OS
6+ UNAME_S := $(shell uname -s 2>/dev/null || echo Windows)
7+ ifeq ($(UNAME_S ) ,Linux)
8+ DETECTED_OS := linux
9+ INSTALL_DIR := /usr/local/bin
10+ SUDO := sudo
11+ RM := rm -f
12+ endif
13+ ifeq ($(UNAME_S ) ,Darwin)
14+ DETECTED_OS := darwin
15+ INSTALL_DIR := /usr/local/bin
16+ SUDO := sudo
17+ RM := rm -f
18+ endif
19+ ifeq ($(UNAME_S ) ,Windows)
20+ DETECTED_OS := windows
21+ INSTALL_DIR := $(USERPROFILE)/bin
22+ SUDO :=
23+ RM := del /Q
24+ endif
25+ # Fallback for Windows (Git Bash, MSYS2, etc.)
26+ ifeq ($(OS ) ,Windows_NT)
27+ DETECTED_OS := windows
28+ INSTALL_DIR := $(HOME)/bin
29+ SUDO :=
30+ RM := rm -f
31+ endif
32+
33+ # Detect architecture
34+ UNAME_M := $(shell uname -m 2>/dev/null || echo amd64)
35+ ifeq ($(UNAME_M ) ,x86_64)
36+ GOARCH := amd64
37+ endif
38+ ifeq ($(UNAME_M ) ,amd64)
39+ GOARCH := amd64
40+ endif
41+ ifeq ($(UNAME_M ) ,arm64)
42+ GOARCH := arm64
43+ endif
44+ ifeq ($(UNAME_M ) ,aarch64)
45+ GOARCH := arm64
46+ endif
47+
548# Default target
649all : build
750
@@ -16,15 +59,25 @@ mpcium:
1659mpc :
1760 go install ./cmd/mpcium-cli
1861
19- # Install binaries to /usr/local/bin (auto-detects architecture)
62+ # Install binaries (auto-detects OS and architecture)
2063install :
21- @echo " Building and installing mpcium binaries for Linux..."
22- GOOS=linux go build -o /tmp/mpcium ./cmd/mpcium
23- GOOS=linux go build -o /tmp/mpcium-cli ./cmd/mpcium-cli
24- sudo install -m 755 /tmp/mpcium /usr/local/bin/
25- sudo install -m 755 /tmp/mpcium-cli /usr/local/bin/
26- rm -f /tmp/mpcium /tmp/mpcium-cli
27- @echo " Successfully installed mpcium and mpcium-cli to /usr/local/bin/"
64+ @echo " Detected OS: $( DETECTED_OS) "
65+ @echo " Building and installing mpcium binaries..."
66+ ifeq ($(DETECTED_OS ) ,windows)
67+ @echo "Building for Windows..."
68+ GOOS=windows GOARCH=$(GOARCH) go build -o $(BIN_DIR)/mpcium.exe ./cmd/mpcium
69+ GOOS=windows GOARCH=$(GOARCH) go build -o $(BIN_DIR)/mpcium-cli.exe ./cmd/mpcium-cli
70+ @echo "Binaries built in $(BIN_DIR)/"
71+ @echo "Please add $(BIN_DIR) to your PATH or manually copy the binaries to a location in your PATH"
72+ else
73+ @mkdir -p /tmp/mpcium-install
74+ GOOS=$(DETECTED_OS) GOARCH=$(GOARCH) go build -o /tmp/mpcium-install/mpcium ./cmd/mpcium
75+ GOOS=$(DETECTED_OS) GOARCH=$(GOARCH) go build -o /tmp/mpcium-install/mpcium-cli ./cmd/mpcium-cli
76+ $(SUDO) install -m 755 /tmp/mpcium-install/mpcium $(INSTALL_DIR)/
77+ $(SUDO) install -m 755 /tmp/mpcium-install/mpcium-cli $(INSTALL_DIR)/
78+ rm -rf /tmp/mpcium-install
79+ @echo "Successfully installed mpcium and mpcium-cli to $(INSTALL_DIR)/"
80+ endif
2881
2982# Run all tests
3083test :
0 commit comments