-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (88 loc) · 2.91 KB
/
Copy pathMakefile
File metadata and controls
111 lines (88 loc) · 2.91 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
# Makefile for Queue Entropy Analysis
CXX = g++
CXXFLAGS = -std=c++17 -Wall -Wextra -Wpedantic -O3 -I include -pthread
SRCDIR = src
TESTDIR = tests
BUILDDIR = build
# Optional override for install path
PREFIX ?= /usr/local
# Source files (exclude performance test from main build)
SOURCES = $(filter-out $(SRCDIR)/performance_test.cpp, $(wildcard $(SRCDIR)/*.cpp))
TEST_SOURCES = $(wildcard $(TESTDIR)/*.cpp)
# New folder, same structure (mirror structure under build)
OBJS = $(SOURCES:$(SRCDIR)/%.cpp=$(BUILDDIR)/%.o)
# Executables
MAIN_EXEC = market_entropy_analyzer
TEST_EXECS = $(TEST_SOURCES:$(TESTDIR)/%.cpp=test_%)
# Default target
all: $(MAIN_EXEC)
# Ensure build directory exists
$(BUILDDIR):
mkdir -p $(BUILDDIR)
# Convert every .cpp source file into its own .o object file
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp | $(BUILDDIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Main executable (links from precompiled object files)
$(MAIN_EXEC): $(OBJS)
$(CXX) $(CXXFLAGS) -o $@ $^
#--------------------------------------------------------------
# Test executables
test_%: $(TESTDIR)/%.cpp $(filter-out $(BUILDDIR)/main.o, $(OBJS))
$(CXX) $(CXXFLAGS) $^ -o $@
# Build all tests
tests: $(TEST_EXECS)
# Run all tests
test: tests
@echo "Running all tests..."
@for test in $(TEST_EXECS); do \
echo "Running $$test..."; \
./$$test; \
echo ""; \
done
# Run specific test
test-queue: test_test_queue_edge_cases
./test_test_queue_edge_cases
test-entropy: test_test_entropy_edge_cases
./test_test_entropy_edge_cases
test-pipeline: test_test_pipeline_edge_cases
./test_test_pipeline_edge_cases
test-market: test_test_market_simulation
./test_test_market_simulation
# Performance test
perf: test_test_market_simulation
./test_test_market_simulation
# Clean build artifacts
clean:
rm -f $(MAIN_EXEC) $(TEST_EXECS)
rm -rf $(BUILDDIR)
rm -f *.o *.so *.a
# Install (copy to system bin)
install: $(MAIN_EXEC)
cp $(MAIN_EXEC) /usr/local/bin/
# Uninstall
uninstall:
rm -f /usr/local/bin/$(MAIN_EXEC)
# Debug build
debug: CXXFLAGS += -g -DDEBUG
debug: $(MAIN_EXEC)
# Release build
release: CXXFLAGS += -DNDEBUG
release: $(MAIN_EXEC)
# Help
help:
@echo "Available targets:"
@echo " all - Build main executable"
@echo " tests - Build all test executables"
@echo " test - Run all tests"
@echo " test-queue - Run queue edge case tests"
@echo " test-entropy - Run entropy edge case tests"
@echo " test-pipeline - Run pipeline edge case tests"
@echo " test-market - Run market simulation tests"
@echo " perf - Run performance tests"
@echo " clean - Remove build artifacts"
@echo " debug - Build with debug symbols"
@echo " release - Build optimized release version"
@echo " install - Install to system"
@echo " uninstall - Remove from system"
@echo " help - Show this help"
.PHONY: all tests test test-queue test-entropy test-pipeline test-market perf clean debug release install uninstall help