Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (55 loc) · 2.15 KB
/
Copy pathMakefile
File metadata and controls
67 lines (55 loc) · 2.15 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
BUILD_DIR := build
INSTALL_DIR := /usr/local/bin
TARGET_NAME := fusequota
.PHONY: all musl clean install libfuse libfuse-patches test format help
all: libfuse $(BUILD_DIR)/Makefile
@echo "--- Building Project ---"
$(MAKE) -C $(BUILD_DIR)
musl: Dockerfile.musl
@echo "--- Building Static Musl Binary (via Docker) ---"
@# Ensure BuildKit is enabled for the --output feature
DOCKER_BUILDKIT=1 docker build -f Dockerfile.musl --output build/ .
@echo "Success! Binary is at: build/fusequota_musl"
libfuse-patches:
@if git -C external/libfuse apply --reverse --check ../../patches/libfuse-fixes.patch 2>/dev/null; then \
echo "--- libfuse patches already applied ---"; \
else \
echo "--- Applying libfuse patches ---"; \
git -C external/libfuse apply ../../patches/libfuse-fixes.patch; \
fi
libfuse: libfuse-patches
@echo "--- Building libfuse (Static) ---"
@if [ ! -d "external/libfuse/build" ]; then \
meson setup external/libfuse external/libfuse/build --default-library=static; \
else \
meson configure external/libfuse/build --default-library=static; \
fi
ninja -C external/libfuse/build
$(BUILD_DIR)/Makefile:
@echo "--- Configuring CMake ---"
mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR) && cmake ..
test: libfuse
@echo "--- Building and Running Tests ---"
cmake -S . -B $(BUILD_DIR) -DFUSEQUOTA_BUILD_TESTS=ON
cmake --build $(BUILD_DIR)
ctest --test-dir $(BUILD_DIR) --output-on-failure
install: all
@echo "--- Installing Binary ---"
sudo install -m 755 $(BUILD_DIR)/$(TARGET_NAME) $(INSTALL_DIR)
clean:
@echo "--- Cleaning Build Files ---"
rm -rf $(BUILD_DIR)
rm -rf external/libfuse/build
FORMAT_SOURCES := $(shell find src tests -name "*.cpp" -o -name "*.hpp")
format:
@echo "--- Formatting Code ---"
clang-format -i $(FORMAT_SOURCES)
help:
@echo "Usage:"
@echo " make - Build libfuse and the main project"
@echo " make install - Build and install the binary to $(INSTALL_DIR)"
@echo " make test - Build and run the unit and integration tests"
@echo " make clean - Remove build directories"
@echo " make musl - Build a static binary using musl (via Docker)"
@echo " make format - Format source code using clang-format"