-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (122 loc) · 3.46 KB
/
Copy pathMakefile
File metadata and controls
138 lines (122 loc) · 3.46 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Compiler
CC = g++
# Detect platform
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
# Installation directories
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
INSTALL = install
INSTALL_PROGRAM = $(INSTALL) -m 0755
# Default flags
CFLAGS = -O3 -std=c++17
LDFLAGS =
PLATFORM_SRC =
# Sources
CLIENT_SRC = Source/ZVM.cpp
CLIENT_BIN = ZVM
# Platform-specific settings
ifeq ($(UNAME_S),Darwin)
# macOS
ifeq ($(UNAME_M),arm64)
# Apple Silicon
CFLAGS += -target arm64-apple-macos14 -mcpu=apple-m4
else
# Intel Mac
CFLAGS += -march=native
endif
LDFLAGS += -framework IOKit -framework Cocoa -framework OpenGL
INSTALL_PROGRAM = $(INSTALL) -m 0755
else ifeq ($(UNAME_S),Linux)
# Linux
CC = g++
CFLAGS += -march=native
LDFLAGS += -lGL -lm -lpthread -ldl -lrt -lX11
INSTALL_PROGRAM = $(INSTALL) -m 0755
else ifeq ($(OS),Windows_NT)
# Windows (w64devkit/MinGW)
CC = g++
CLIENT_BIN = ZVM.exe
CFLAGS += -march=native
LDFLAGS += -lopengl32 -lgdi32 -lwinmm
# Static linking for portability
LDFLAGS += -static
# Windows install locations
PREFIX ?= C:/Program Files/ZVM
BINDIR = $(PREFIX)
INSTALL = copy
INSTALL_PROGRAM = $(INSTALL)
else
# Fallback for unknown systems
LDFLAGS +=
endif
# Final sources
SOURCES = $(CLIENT_SRC) $(PLATFORM_SRC)
# Default target
all: $(CLIENT_BIN)
# Build client
$(CLIENT_BIN): $(SOURCES) Source/*.hpp
$(CC) $(SOURCES) $(CFLAGS) -o $(CLIENT_BIN) $(LDFLAGS)
# Platform-specific targets
macos:
$(MAKE) CC=clang++ UNAME_S=Darwin all
linux:
$(MAKE) CC=g++ UNAME_S=Linux all
windows:
$(MAKE) CC=g++ OS=Windows_NT all
# Clean build artifacts
clean:
ifeq ($(OS),Windows_NT)
del /Q $(CLIENT_BIN) 2>nul || exit 0
else
rm -f $(CLIENT_BIN) ZVM.exe
endif
# Install binary
install: $(CLIENT_BIN)
ifeq ($(OS),Windows_NT)
@echo Installing to $(BINDIR)...
@if not exist "$(BINDIR)" mkdir "$(BINDIR)"
$(INSTALL_PROGRAM) $(CLIENT_BIN) "$(BINDIR)"
@echo Installation complete!
@echo Add $(BINDIR) to your PATH to use ZVM from anywhere
else
@echo Installing to $(BINDIR)...
@mkdir -p $(BINDIR)
$(INSTALL_PROGRAM) $(CLIENT_BIN) $(BINDIR)/$(CLIENT_BIN)
@echo Installation complete!
@echo ZVM installed to $(BINDIR)/$(CLIENT_BIN)
endif
# Uninstall binary
uninstall:
ifeq ($(OS),Windows_NT)
@echo Uninstalling from $(BINDIR)...
@if exist "$(BINDIR)\$(CLIENT_BIN)" del "$(BINDIR)\$(CLIENT_BIN)"
@echo Uninstallation complete!
else
@echo Uninstalling from $(BINDIR)...
@rm -f $(BINDIR)/$(CLIENT_BIN)
@echo Uninstallation complete!
endif
# Install dependencies help
help:
@echo "ZVM Cross-Platform Build System"
@echo "================================"
@echo ""
@echo "Targets:"
@echo " make - Auto-detect platform and build"
@echo " make macos - Build for macOS"
@echo " make linux - Build for Linux"
@echo " make windows - Build for Windows"
@echo " make clean - Remove build artifacts"
@echo " make install - Install ZVM binary (may require sudo on Unix)"
@echo " make uninstall- Uninstall ZVM binary"
@echo ""
@echo "Installation:"
@echo " Default install location: $(BINDIR)"
@echo " Custom install: make install PREFIX=/custom/path"
@echo " Unix/Linux: sudo make install"
@echo " macOS: sudo make install"
@echo " Windows: make install (run as administrator for system-wide install)"
@echo ""
@echo "Current platform detected: $(UNAME_S)"
.PHONY: all macos linux windows clean install uninstall help