This repository was archived by the owner on Dec 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (73 loc) · 2.08 KB
/
Makefile
File metadata and controls
101 lines (73 loc) · 2.08 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
# SPDX-License-Identifier: Apache-2.0
# Copyright 2021 Ricerca Security, Inc. All rights reserved.
TARGET := processor
LIBTARGET := libcsdec.a
SRC_DIR := src
INC_DIR := include
# capstone library name (without prefix 'lib' and suffix '.so')
LIBCAPSTONE := capstone
CXX ?= g++
CXXFLAGS := -std=c++17 -Wall
CXXFLAGS += -I$(INC_DIR)
CXXFLAGS += -l$(LIBCAPSTONE)
# When the value is 1, cache mode is enabled.
# This mode speeds up the decoding process by saving the disassemble
# and trace results in the software cache."
CACHE_MODE := 1
PRINT_EDGE_COV := 0
ifeq ($(CACHE_MODE), 1)
CXXFLAGS += -DCACHE_MODE
endif
ifeq ($(PRINT_EDGE_COV), 1)
CXXFLAGS += -DPRINT_EDGE_COV
endif
# For ptrix mode
MAX_ATOM_LEN := 4096
ifneq ($(strip $(MAX_ATOM_LEN)),)
CXXFLAGS += -DMAX_ATOM_LEN=$(MAX_ATOM_LEN)
endif
SRCS := $(SRC_DIR)/bitmap.cpp \
$(SRC_DIR)/cache.cpp \
$(SRC_DIR)/common.cpp \
$(SRC_DIR)/decoder.cpp \
$(SRC_DIR)/deformatter.cpp \
$(SRC_DIR)/disassembler.cpp \
$(SRC_DIR)/libcsdec.cpp \
$(SRC_DIR)/process.cpp \
$(SRC_DIR)/processor.cpp \
$(SRC_DIR)/trace.cpp \
$(SRC_DIR)/utils.cpp
OBJS := $(SRCS:.cpp=.o)
TEST_DIR := tests
FIB_TEST := $(TEST_DIR)/fib
BRANCHES_TEST := $(TEST_DIR)/branches
all: CXXFLAGS += -O3
all: CXXFLAGS += -DNDEBUG # Disable calls to assert()
all: $(TARGET) $(LIBTARGET)
debug: CXXFLAGS += -DDEBUG_BUILD
debug: CXXFLAGS += -g
debug: $(TARGET) $(LIBTARGET)
$(TARGET): $(OBJS)
$(CXX) -o $@ $^ $(CXXFLAGS)
$(LIBTARGET): $(subst src/processor.o,,$(OBJS))
$(AR) -rc $@ $^
test: fib-test branches-test
fib-test:
make -C $(FIB_TEST) test
branches-test:
make -C $(BRANCHES_TEST) test
format:
clang-format -i src/*.cpp include/*.hpp include/*.h tests/*.cpp
tidy:
clang-tidy $(SRCS) \
--checks='-*,bugprone-*,cert-*,cppcoreguidelines-*, \
hicpp-*,modernize-*,performance-*,portability-*, \
readability-*,misc-*' \
-- -$(CXXFLAGS)
clean:
rm -rf $(OBJS) $(TARGET) $(LIBTARGET)
dist-clean: clean
make -C $(TEST_DIR) clean
make -C $(FIB_TEST) clean
make -C $(BRANCHES_TEST) clean
.PHONY: all debug test fib-test branches-test format tidy clean dist-clean