-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (83 loc) · 3.36 KB
/
Copy pathMakefile
File metadata and controls
103 lines (83 loc) · 3.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
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
CXX = g++
CXXFLAGS = -std=c++17 -Wall -Wextra -O2 -g
INCLUDES = -I include
SRCDIR = src
EXAMPLESDIR = examples
TESTSDIR = tests
# Source files
CORE_SOURCES = $(wildcard $(SRCDIR)/core/*.cpp)
ALGORITHMS_SOURCES = $(wildcard $(SRCDIR)/algorithms/*.cpp)
EVALUATORS_SOURCES = $(wildcard $(SRCDIR)/evaluators/*.cpp)
OPTIMIZERS_SOURCES = $(wildcard $(SRCDIR)/optimizers/*.cpp)
STRATEGIES_SOURCES = $(wildcard $(SRCDIR)/strategies/*.cpp)
UTILS_SOURCES = $(wildcard $(SRCDIR)/utils/*.cpp)
ALL_SOURCES = $(CORE_SOURCES) $(ALGORITHMS_SOURCES) $(EVALUATORS_SOURCES) \
$(OPTIMIZERS_SOURCES) $(STRATEGIES_SOURCES) $(UTILS_SOURCES)
# Object files
OBJECTS = $(ALL_SOURCES:.cpp=.o)
# Executables
WORKING_DEMO = $(EXAMPLESDIR)/working_demo
WORKING_TEST = $(TESTSDIR)/test_working_integration
COMMUNITY_TEST = $(TESTSDIR)/test_community_detection
# Default target
all: $(WORKING_DEMO) $(WORKING_TEST) $(COMMUNITY_TEST)
# Build object files
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Build working demo
$(WORKING_DEMO): $(OBJECTS) $(EXAMPLESDIR)/working_demo.o
$(CXX) $(CXXFLAGS) $(OBJECTS) $(EXAMPLESDIR)/working_demo.o -o $@
# Build working integration test
$(WORKING_TEST): $(OBJECTS) $(TESTSDIR)/test_working_integration.o
$(CXX) $(CXXFLAGS) $(OBJECTS) $(TESTSDIR)/test_working_integration.o -o $@
# Build community detection test
$(COMMUNITY_TEST): $(OBJECTS) $(TESTSDIR)/test_community_detection.o
$(CXX) $(CXXFLAGS) $(OBJECTS) $(TESTSDIR)/test_community_detection.o -o $@
# Build example object files
$(EXAMPLESDIR)/working_demo.o: $(EXAMPLESDIR)/working_demo.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Build test object files
$(TESTSDIR)/test_working_integration.o: $(TESTSDIR)/test_working_integration.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(TESTSDIR)/test_community_detection.o: $(TESTSDIR)/test_community_detection.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Test compilation of individual source files
test-compile:
@echo "Testing compilation of all source files..."
@for file in $(ALL_SOURCES); do \
echo "Compiling $$file..."; \
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $$file -o /tmp/temp.o || exit 1; \
done
@echo "All source files compile successfully!"
# Run the working demo
run-demo: $(WORKING_DEMO)
@echo "Running working demo..."
@./$(WORKING_DEMO)
# Run the working integration test
run-test: $(WORKING_TEST)
@echo "Running working integration test..."
@./$(WORKING_TEST)
# Run community detection test
run-community-test: $(COMMUNITY_TEST)
@echo "Running community detection test..."
@./$(COMMUNITY_TEST)
# Run all tests
run-all: run-demo run-test run-community-test
# Clean build files
clean:
@echo "Cleaning build files..."
@find . -name "*.o" -delete
@rm -f $(WORKING_DEMO) $(WORKING_TEST) $(COMMUNITY_TEST)
@echo "Clean completed."
# Help
help:
@echo "Available targets:"
@echo " all - Build all executables"
@echo " test-compile - Test compilation of all source files"
@echo " run-demo - Build and run the working demo"
@echo " run-test - Build and run the working integration test"
@echo " run-community-test - Build and run community detection test"
@echo " run-all - Build and run all tests and demos"
@echo " clean - Remove all build files"
@echo " help - Show this help message"
.PHONY: all test-compile run-demo run-test run-community-test run-all clean help