-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
75 lines (62 loc) · 1.63 KB
/
Makefile
File metadata and controls
75 lines (62 loc) · 1.63 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Mach - Cross-Platform Makefile
# Directories
SRC_DIR = src
ASM_DIR = $(SRC_DIR)/asm
OBJ_DIR = obj
# Platform detection
UNAME_S := $(shell uname -s 2>/dev/null || echo Windows)
UNAME_M := $(shell uname -m 2>/dev/null || echo x86_64)
# Compiler
CC = gcc
CFLAGS = -Wall -Wextra -O3 -I$(SRC_DIR)
# Target
TARGET = mach
# Platform-specific settings
ifeq ($(UNAME_S),Darwin)
# macOS
CFLAGS += -I/opt/homebrew/opt/openssl@3/include
LDFLAGS = -L/opt/homebrew/opt/openssl@3/lib -lssl -lcrypto -lpthread
ifeq ($(UNAME_M),arm64)
ASM_SRC = fast_stats_arm64.s
else
ASM_SRC = fast_stats_x86.s
endif
HTTP_SRC = http.c
TERM_SRC = terminal.c
else ifeq ($(UNAME_S),Linux)
# Linux
LDFLAGS = -lssl -lcrypto -lpthread
ASM_SRC = fast_stats_x86.s
HTTP_SRC = http.c
TERM_SRC = terminal.c
else
# Windows (MinGW)
TARGET = mach.exe
LDFLAGS = -lssl -lcrypto -lws2_32
ASM_SRC = fast_stats_x86.s
HTTP_SRC = http_win.c
TERM_SRC = terminal_win.c
endif
# Source files
CORE_SRCS = main.c attacker.c stats.c ui.c storage.c updater.c
SRCS = $(addprefix src/, $(CORE_SRCS) $(HTTP_SRC) $(TERM_SRC))
OBJS = $(patsubst src/%.c,obj/%.o,$(SRCS)) $(OBJ_DIR)/$(ASM_SRC:.s=.o)
# Rules
all: $(OBJ_DIR) $(TARGET)
@echo "Built for $(UNAME_S) $(UNAME_M)"
$(OBJ_DIR):
@mkdir -p $(OBJ_DIR)
$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $(TARGET) $(LDFLAGS)
ifeq ($(UNAME_S),Darwin)
strip $(TARGET)
else ifeq ($(UNAME_S),Linux)
strip $(TARGET)
endif
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o: $(ASM_DIR)/%.s
$(CC) -c $< -o $@
clean:
rm -rf $(OBJ_DIR) $(TARGET) mach.exe
.PHONY: all clean