-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (54 loc) · 1.93 KB
/
Copy pathMakefile
File metadata and controls
78 lines (54 loc) · 1.93 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
C_SRCS = src/main.c src/ArgParsing.c src/FileProcessor.c
CPP_SRCS = src/Simulation/SubRequest.cpp src/Simulation/Simulation.cpp src/Simulation/Cache.cpp src/Simulation/CPU.cpp src/Simulation/RAM.cpp
C_OBJS = $(C_SRCS:.c=.o)
CPP_OBJS = $(CPP_SRCS:.cpp=.o)
TARGET := cache
SCPATH = $(SYSTEMC_HOME)
CFLAGS := -Wall -Wextra -pedantic -std=c17
CXXFLAGS := -Wall -Wextra -pedantic -std=c++14 -I$(SCPATH)/include -L$(SCPATH)/lib -lsystemc -lm
CXX := $(shell command -v g++ || command -v clang++)
ifeq ($(strip $(CXX)),)
$(error Neither clang++ nor g++ is available. Exiting.)
endif
CC := $(shell command -v gcc || command -v clang)
ifeq ($(strip $(CC)),)
$(error Neither clang nor gcc is available. Exiting.)
endif
UNAME_S := $(shell uname -s)
ifneq ($(UNAME_S), Darwin)
CXXFLAGS += -Wl,-rpath=$(SCPATH)/lib
endif
all: debug
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
debug: CXXFLAGS += -g
debug: $(TARGET)
release: CXXFLAGS += -O2
release: $(TARGET)
$(TARGET): $(C_OBJS) $(CPP_OBJS)
$(CXX) $(CXXFLAGS) $(C_OBJS) $(CPP_OBJS) $(LDFLAGS) -o $(TARGET)
clean:
rm -f $(TARGET)
rm -f src/*.o
rm -f src/Simulation/*.o
test:
rm -rf build
cmake -S . -B build
cmake --build build -j16
cd build; ctest --output-on-failure --parallel 16
integration:
rm -rf build
cmake -DBUILD_INTEGRATION_TESTING=ON -S . -B build
cmake --build build -j16
cd build; ctest --output-on-failure --parallel 16
benchmarks:
cd tools; make; python3 BenchmarkRunner.py
# Use this to disallow reads while write-buffer is not empty
buildWithRAMReadAfterWrite: CXXFLAGS += -DSTRICT_RAM_READ_AFTER_WRITES
buildWithRAMReadAfterWrite: $(TARGET)
# Use this to turn off the write-buffer optimisation
buildWithStrictInstrOrder: CXXFLAGS += -DSTRICT_RAM_READ_AFTER_WRITES -DSTRICT_INSTRUCTION_ORDER
buildWithStrictInstrOrder: $(TARGET)
.PHONY: all debug release clean test buildWithStrictInstrOrder buildWithRAMReadAfterWrite benchmarks