-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (42 loc) · 1.36 KB
/
Copy pathMakefile
File metadata and controls
55 lines (42 loc) · 1.36 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
# MeMS-Pro Makefile
# Compiler and Flags
CXX := g++
CXXFLAGS := -std=c++17 -I./src -Wall -Wextra -g
LDFLAGS := -pthread
TEST_LDFLAGS := -pthread -lgtest -lgtest_main
# Directories
SRC_DIR := src
TEST_DIR := tests
BIN_DIR := bin
# Source files
SRCS := $(SRC_DIR)/memory_manager.cpp \
$(SRC_DIR)/slab_allocator.cpp \
$(SRC_DIR)/main.cpp
BENCH_SRC := $(SRC_DIR)/benchmark.cpp
TEST_SRCS := $(TEST_DIR)/allocator_test.cpp
# Executables
DEMO_EXE := $(BIN_DIR)/memory_test
BENCH_EXE := $(BIN_DIR)/benchmark
TEST_EXE := $(BIN_DIR)/test_runner
# Default target builds everything needed
.PHONY: all demo bench test clean
all: demo bench
# Build the demo (multithreaded run)
demo: $(SRCS)
@mkdir -p $(BIN_DIR)
$(CXX) $(CXXFLAGS) $(SRCS) -o $(DEMO_EXE) $(LDFLAGS)
# Build & run the benchmark suite
bench: $(BENCH_SRC) $(SRC_DIR)/memory_manager.cpp $(SRC_DIR)/slab_allocator.cpp
@mkdir -p $(BIN_DIR)
$(CXX) $(CXXFLAGS) $^ -o $(BENCH_EXE) $(LDFLAGS)
@echo "Yaay .. Running benchmark..."
./$(BENCH_EXE)
# Build & run unit tests (requires Google Test)
test: $(SRC_DIR)/memory_manager.cpp $(SRC_DIR)/slab_allocator.cpp $(TEST_SRCS)
@mkdir -p $(BIN_DIR)
$(CXX) $(CXXFLAGS) $^ -o $(TEST_EXE) $(TEST_LDFLAGS)
./$(TEST_EXE)
# Clean up all build artifacts and logs
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BIN_DIR) *.o *.out memlog.txt benchmark_results.csv