Skip to content

Commit c63affd

Browse files
committed
chore: add architecture detection to binary names
Added OS and architecture detection in Makefile to generate platform-specific binary names like gitkeykit-linux-amd64.
1 parent 3e0636e commit c63affd

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Makefile

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,30 @@ SRCS = $(wildcard $(SRC_DIR)/*.c) \
1414
# Object files
1515
OBJS = $(SRCS:%.c=$(BUILD_DIR)/%.o)
1616

17-
# Target executable
18-
TARGET = $(BIN_DIR)/gitkeykit
17+
# variables for architecture and OS detection
18+
ifeq ($(OS),Windows_NT)
19+
DETECTED_OS := windows
20+
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
21+
DETECTED_ARCH := x86_64
22+
else ifeq ($(PROCESSOR_ARCHITECTURE),x86)
23+
DETECTED_ARCH := x86
24+
else
25+
DETECTED_ARCH := $(PROCESSOR_ARCHITECTURE)
26+
endif
27+
else
28+
DETECTED_OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
29+
DETECTED_ARCH := $(shell uname -m)
30+
# Normalize architecture names
31+
ifeq ($(DETECTED_ARCH),x86_64)
32+
DETECTED_ARCH := amd64
33+
endif
34+
ifeq ($(DETECTED_ARCH),aarch64)
35+
DETECTED_ARCH := arm64
36+
endif
37+
endif
38+
39+
# Modify the target executable name to include OS and architecture
40+
TARGET = $(BIN_DIR)/gitkeykit-$(DETECTED_OS)-$(DETECTED_ARCH)
1941

2042
# Platform-specific settings
2143
ifeq ($(OS),Windows_NT)
@@ -41,7 +63,6 @@ directories:
4163
$(MKDIR) $(BUILD_DIR)/$(SRC_DIR)/utils
4264
endif
4365

44-
# Add this near the top, after the variables but before the platform-specific settings
4566
all: directories $(TARGET)
4667

4768
# Link the final executable

0 commit comments

Comments
 (0)