-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (98 loc) · 3.95 KB
/
Copy pathMakefile
File metadata and controls
125 lines (98 loc) · 3.95 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
# Makefile for Anvilock (CMake Wrapper)
# Set default build directory
BUILD_DIR = build
EXECUTABLE_NAME = anvilock
# Compiler and Flags
CMAKE = cmake
CMAKE_RELEASE_FLAGS = -DCMAKE_BUILD_TYPE=Release
MAKE = make
FLAGS ?=
GLOBAL_FLAG := -DBUILD_GLOBAL
INSTALL_MANIFEST := $(BUILD_DIR)/install_manifest.txt
STB_URL = "https://raw.githubusercontent.com/nothings/stb/master/stb_image.h"
STB_PATH= "stb_image.h"
# Paths to protocol files
EXT_PROTOCOL_PATH ?= /usr/share/wayland-protocols/staging/ext-session-lock/ext-session-lock-v1.xml
XDG_PROTOCOL_PATH ?= /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml
# Output directories
PROTOCOLS_DIR := protocols
PROTOCOLS_SRC_DIR := $(PROTOCOLS_DIR)/src
WAYLAND_SCANNER := wayland-scanner
# Ensure output directories exist
$(shell mkdir -p $(PROTOCOLS_SRC_DIR))
# Rules for EXT_SESSION_LOCK_V1 protocol
$(PROTOCOLS_DIR)/ext-session-lock-client-protocol.h $(PROTOCOLS_SRC_DIR)/ext-session-lock-client-protocol.c: $(EXT_PROTOCOL_PATH)
@if [ -f "$<" ]; then \
echo "Generating headers and sources for EXT_SESSION_LOCK_V1 protocol..."; \
$(WAYLAND_SCANNER) client-header "$<" $(PROTOCOLS_DIR)/ext-session-lock-client-protocol.h; \
$(WAYLAND_SCANNER) private-code "$<" $(PROTOCOLS_SRC_DIR)/ext-session-lock-client-protocol.c; \
echo "EXT_SESSION_LOCK_V1 protocol generated successfully."; \
else \
echo "Error: EXT_SESSION_LOCK_V1 protocol file not found." >&2; \
exit 1; \
fi
# Rules for XDG_SHELL protocol
$(PROTOCOLS_DIR)/xdg-shell-client-protocol.h $(PROTOCOLS_SRC_DIR)/xdg-shell-client-protocol.c: $(XDG_PROTOCOL_PATH)
@if [ -f "$<" ]; then \
echo "Generating headers and sources for XDG_SHELL protocol..."; \
$(WAYLAND_SCANNER) client-header "$<" $(PROTOCOLS_DIR)/xdg-shell-client-protocol.h; \
$(WAYLAND_SCANNER) private-code "$<" $(PROTOCOLS_SRC_DIR)/xdg-shell-client-protocol.c; \
echo "XDG_SHELL protocol generated successfully."; \
else \
echo "Error: XDG_SHELL protocol file not found." >&2; \
exit 1; \
fi
# Sanitized Builds
ASAN_BUILD_DIR = build-asan
TSAN_BUILD_DIR = build-tsan
# Targets
all: release
debug:
@mkdir -p $(BUILD_DIR)
@cd $(BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=Debug .. && $(MAKE)
protocols:
$(PROTOCOLS_DIR)/ext-session-lock-client-protocol.h $(PROTOCOLS_SRC_DIR)/ext-session-lock-client-protocol.c \
$(PROTOCOLS_DIR)/xdg-shell-client-protocol.h $(PROTOCOLS_SRC_DIR)/xdg-shell-client-protocol.c
init:
@if [ ! -f "$(STB_PATH)" ]; then \
wget -q -O "$(STB_PATH)" "$(STB_URL)"; \
else \
echo ">> $(STB_PATH) already exists. Skipping download."; \
fi
$(MAKE) protocols
release:
$(MAKE) init
@mkdir -p $(BUILD_DIR)
@cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_RELEASE_FLAGS) $(FLAGS) .. && $(MAKE)
asan:
@mkdir -p $(ASAN_BUILD_DIR)
@cd $(ASAN_BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=Debug-ASan $(FLAGS) .. && $(MAKE)
tsan:
@mkdir -p $(TSAN_BUILD_DIR)
@cd $(TSAN_BUILD_DIR) && $(CMAKE) -DCMAKE_BUILD_TYPE=Debug-TSan $(FLAGS) .. && $(MAKE)
format:
@find src include \( -name "*.c" -o -name "*.h" \) -exec clang-format -i {} +
tidy:
@find src include -name "*.c" -o -name "*.h" | xargs clang-tidy
clean:
@rm -rf $(BUILD_DIR) $(ASAN_BUILD_DIR) $(TSAN_BUILD_DIR)
@echo "--> Cleaned up $(BUILD_DIR), $(ASAN_BUILD_DIR) and $(TSAN_BUILD_DIR)."
build-global:
@echo "==> Building Anvilock GLOBALLY and installing..."
$(CMAKE) -S . -B $(BUILD_DIR) $(TESTING_FLAG)=OFF $(GLOBAL_FLAG)=ON $(CMAKE_EXTRA_FLAGS)
$(CMAKE) --build $(BUILD_DIR)
cd $(BUILD_DIR) && sudo $(MAKE) install
build-global-uninstall:
@echo "==> Uninstalling Anvilock from the GLOBAL build..."
@if [ -f "$(INSTALL_MANIFEST)" ]; then \
xargs -a $(INSTALL_MANIFEST) sudo rm -v; \
echo "--> Uninstallation complete."; \
else \
echo "**Error: No install_manifest.txt found. Please ensure the project was installed.**"; \
exit 1; \
fi
uninstall:
@xargs rm -f < install_manifest.txt
run:
./$(BUILD_DIR)/$(EXECUTABLE_NAME)
.PHONY: all debug release asan tsan format clean install uninstall build-global build-global-uninstall