-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (81 loc) · 2.64 KB
/
Makefile
File metadata and controls
102 lines (81 loc) · 2.64 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
# Compiler and flags
CXX = g++
CXXFLAGS = -std=c++17 -Wall -Wextra -Wpedantic
RELEASE_FLAGS = -O3 -DNDEBUG -march=native -flto -ffast-math
DEBUG_FLAGS = -g -O0 -DDEBUG -fsanitize=address -fsanitize=undefined
TEST_FLAGS = -g -O2
# Source files
SOURCES = main.cpp orderbook.cpp csv_parser.cpp
HEADERS = orderbook.h csv_parser.h
OBJECTS = $(SOURCES:.cpp=.o)
TEST_SOURCES = test_orderbook.cpp orderbook.cpp csv_parser.cpp
TEST_OBJECTS = $(TEST_SOURCES:.cpp=.o)
# Target executables
TARGET = reconstruction_orderbook
DEBUG_TARGET = reconstruction_orderbook_debug
TEST_TARGET = test_orderbook
# Default target (release build)
all: $(TARGET)
# Release build
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) -o $@ $^
# Debug build
debug: $(DEBUG_TARGET)
$(DEBUG_TARGET): CXXFLAGS += $(DEBUG_FLAGS)
$(DEBUG_TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $@ $^
# Test build
test: $(TEST_TARGET)
$(TEST_TARGET): CXXFLAGS += $(TEST_FLAGS)
$(TEST_TARGET): $(TEST_OBJECTS)
$(CXX) $(CXXFLAGS) -o $@ $^
# Object file compilation
%.o: %.cpp $(HEADERS)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean build artifacts
clean:
rm -f $(OBJECTS) $(TEST_OBJECTS) $(TARGET) $(DEBUG_TARGET) $(TEST_TARGET)
rm -f *.csv *.log core.*
# Install (copy to system path)
install: $(TARGET)
cp $(TARGET) /usr/local/bin/
# Uninstall
uninstall:
rm -f /usr/local/bin/$(TARGET)
# Run with sample data
run: $(TARGET)
./$(TARGET) mbo.csv output_mbp.csv
# Run tests
test_run: $(TEST_TARGET)
./$(TEST_TARGET)
# Performance profiling
profile: $(TARGET)
perf record -g ./$(TARGET) mbo.csv
perf report
# Memory check with valgrind
memcheck: $(DEBUG_TARGET)
valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all ./$(DEBUG_TARGET) mbo.csv
# Static analysis
analyze:
cppcheck --enable=all --std=c++17 $(SOURCES) $(HEADERS)
# Format code
format:
clang-format -i $(SOURCES) $(HEADERS) $(TEST_SOURCES)
# Build all targets
build_all: $(TARGET) $(DEBUG_TARGET) $(TEST_TARGET)
# Help
help:
@echo "Available targets:"
@echo " all (default) - Build release version"
@echo " debug - Build debug version with sanitizers"
@echo " test - Build test executable"
@echo " clean - Remove build artifacts"
@echo " install - Install to system path"
@echo " run - Run with sample data"
@echo " test_run - Run unit tests"
@echo " profile - Profile with perf"
@echo " memcheck - Check memory with valgrind"
@echo " analyze - Static code analysis"
@echo " format - Format code with clang-format"
@echo " build_all - Build all targets"
.PHONY: all debug test clean install uninstall run test_run profile memcheck analyze format build_all help