-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
61 lines (44 loc) · 1.49 KB
/
Makefile
File metadata and controls
61 lines (44 loc) · 1.49 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
CXX = clang++
CXXFLAGS = -std=c++23 -Wall -Wextra -pedantic \
-Isrc \
-Ilib/googletest/googletest/include \
-Ilib/googletest/googletest
LDFLAGS = -pthread
SRC_DIR = src
TEST_DIR = tests
GTEST_DIR = lib/googletest/googletest
# Default target if you just run `make`
TARGET = driver
# Test target
TEST_TARGETS = test_binary_tree test_hash_table test_prefix_trie
# GoogleTest sources
GTEST_SRC = \
$(GTEST_DIR)/src/gtest-all.cc \
$(GTEST_DIR)/src/gtest_main.cc
# Default source (if you just use `make`)
SRC = $(SRC_DIR)/driver.cpp
# Automatically discover modules by finding all src/*/driver.cpp
MODULES := BinaryTree HashTable PrefixTrie MaxHeap BPlusTree
.PHONY: all test clean $(MODULES)
all: $(TARGET)
# Default build (useful if you have a shared top-level driver)
$(TARGET): $(SRC)
$(CXX) $(CXXFLAGS) -o $@ $^
# Test targets
test: $(TEST_TARGETS)
@for test_exec in $(TEST_TARGETS); do \
echo "Running $$test_exec..."; \
./$$test_exec; \
done
test_binary_tree: $(TEST_DIR)/test_binary_tree.cpp $(GTEST_SRC)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
test_hash_table: $(TEST_DIR)/test_hash_table.cpp $(GTEST_SRC)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
test_prefix_trie: $(TEST_DIR)/test_prefix_trie.cpp $(GTEST_SRC)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
# Rule to build each module (e.g., BinaryTree → src/BinaryTree/driver.cpp)
$(MODULES):
$(CXX) $(CXXFLAGS) src/$@/driver.cpp -o $@ $(LDFLAGS)
# Clean everything
clean:
rm -f $(TARGET) $(TEST_TARGETS) $(MODULES)