-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (45 loc) · 1.38 KB
/
Makefile
File metadata and controls
56 lines (45 loc) · 1.38 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
# Makefile for DRAM Reverse Engineering Tool
# Compiler and flags
CXX = g++
CXXFLAGS = -std=c++11 -O2 -g -Isrc/include -Ienable_arm_pmu
LDFLAGS = -lrt -lpthread
# Source files
SRCS = src/main.cpp src/utils.cpp src/rev-mc.cpp src/full_analysis.cpp src/linalg.cpp src/threshold.cpp
OBJS = $(SRCS:.cpp=.o)
# Tests
TEST_SRCS = tests/threshold/test_threshold.cpp
TEST_TARGETS = tests/bin/test_threshold
# Target executable
TARGET = main
# Default target
all: $(TARGET)
test: $(TEST_TARGETS)
@passed=0; failed=0; total=0; \
for t in $(TEST_TARGETS); do \
total=$$((total + 1)); \
printf "[TEST] %s\n" "$$t"; \
"$$t"; \
status=$$?; \
if [ $$status -eq 0 ]; then \
passed=$$((passed + 1)); \
printf " PASS %s\n" "$$t"; \
else \
failed=$$((failed + 1)); \
printf " FAIL %s (exit %d)\n" "$$t" "$$status"; \
fi; \
done; \
printf "\nTest summary: %d passed | %d failed | %d total\n" $$passed $$failed $$total; \
if [ $$failed -ne 0 ]; then exit 1; fi
# Rule to build the target executable
$(TARGET): $(OBJS)
$(CXX) $(OBJS) -o $(TARGET) $(LDFLAGS)
$(TEST_TARGETS): $(TEST_SRCS) src/threshold.cpp src/include/threshold.h
mkdir -p tests/bin
$(CXX) $(CXXFLAGS) $(TEST_SRCS) src/threshold.cpp -o $@ $(LDFLAGS)
# Rule to compile source files into object files
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean rule
clean:
rm -f $(OBJS) $(TARGET) $(TEST_TARGETS)
.PHONY: all clean test