-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
80 lines (63 loc) · 2.12 KB
/
Makefile
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
SRC_DIR=$(PWD)
BUILD_JOBS=24
BUILD_DIR_MXE=$(PWD)/build-mxe
BUILD_TYPE_MXE=Release
MXE_DIR=$(PWD)/mxe
MXE_TARGET=i686-w64-mingw32.static
MXE_BIN=$(MXE_DIR)/usr/bin
CMAKE_MXE=$(MXE_TARGET)-cmake
BUILD_DIR_NATIVE=$(PWD)/build-native
CMAKE_NATIVE=cmake
BUILD_TYPE_NATIVE=Debug
CTEST_BASE_ARGS= --output-on-failure \
--stop-on-failure \
-j$(BUILD_JOBS)
.PHONY: target-native-setup target-native-build target-native-test \
mxe-toolchain \
target-windows-setup target-windows-build \
clean
all: tests
tests: target-native-test
windows-executable: target-windows-build
clean:
rm -rf $(BUILD_DIR_NATIVE) $(BUILD_DIR_MXE)
reformat:
$(SRC_DIR)/scripts/reformat.sh
target-native-setup: $(MXE_INCLUDE)
rm -rf $(BUILD_DIR_NATIVE) && \
mkdir -p $(BUILD_DIR_NATIVE) && \
$(CMAKE_NATIVE) \
-B $(BUILD_DIR_NATIVE) \
-S $(SRC_DIR) \
-DCMAKE_BUILD_TYPE="$(BUILD_TYPE_NATIVE)" \
-DBUILD_TESTING="ON"
target-native-build:
[ ! -d "$(BUILD_DIR_NATIVE)" ] && make target-native-setup;\
$(CMAKE_NATIVE) \
--build $(BUILD_DIR_NATIVE) \
-j$(BUILD_JOBS) \
--target infect infect_lib disasm function_discovery block_copy copy_execution
target-native-test: target-native-build
cd $(BUILD_DIR_NATIVE) && \
ctest $(CTEST_BASE_ARGS) -L disassembler && \
ctest $(CTEST_BASE_ARGS) -L function_discovery && \
ctest $(CTEST_BASE_ARGS) -L copy_code
mxe-toolchain $(MXE_BIN)/$(MXE_TARGET) $(MXE_BIN)/$(CMAKE_MXE):
[ ! -d "$(MXE_DIR)" ] && git clone https://github.com/mxe/mxe.git $(MXE_DIR);\
[ -d "$(MXE_DIR)" ] && \
cd $(MXE_DIR) && \
git pull --ff-only && \
make -j$(BUILD_JOBS) MXE_TARGETS="$(MXE_TARGET)" gcc cmake
target-windows-setup: $(MXE_BIN)/$(MXE_TARGET) $(MXE_BIN)/$(CMAKE_MXE)
rm -rf $(BUILD_DIR_MXE) && \
mkdir -p $(BUILD_DIR_MXE) && \
PATH="$(MXE_BIN):$$PATH" $(CMAKE_MXE) \
-B $(BUILD_DIR_MXE) \
-S $(SRC_DIR) \
-DCMAKE_BUILD_TYPE="$(BUILD_TYPE_MXE)" \
-DBUILD_TESTING="OFF"
target-windows-build: $(MXE_BIN)/$(MXE_TARGET) $(MXE_BIN)/$(CMAKE_MXE)
[ ! -d "$(BUILD_DIR_MXE)" ] && make target-windows-setup;\
PATH="$(MXE_BIN):$$PATH" $(CMAKE_MXE) --build $(BUILD_DIR_MXE) \
-j$(BUILD_JOBS) \
--target infect infect_lib