-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug_makefile
61 lines (42 loc) · 1.65 KB
/
debug_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
# Generates an exe with all debugging symbols on for easy stepping.
# TODO: Not tested with HBINs yet.
#---------- Performance ----------#
# MAKEFLAGS += -s -j1
MAKEFLAGS += -s -j$(NUMBER_OF_PROCESSORS)
#---------- Project Settings ----------#
PROJECT := hannibal
CC_X64 := x86_64-w64-mingw32-g++
#---------- Compiler Flags ----------#
DEBUG_CFLAGS := -O0 -Iinclude -D DEBUG_BUILD -D PROFILE_MYTHIC_HTTP
DEBUG_CFLAGS += -fpermissive -Wunknown-pragmas -Wignored-qualifiers -w
#---------- Linker Flags ----------#
DEBUG_LDFLAGS = -g -m64
#---------- Paths ----------#
SRC_DIR := src
OBJ_DIR := bin/obj
BIN_DIR := bin
SRC_FILES := $(wildcard $(SRC_DIR)/*.c)
OBJ_FILES := $(SRC_FILES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
# This makefile creates a normal .exe, so the stub_wrapper and hannibal_initialize.c can't be part of this build.
SRC_FILES_DEBUG := $(filter-out src/hannibal_initialize.c, $(SRC_FILES))
OBJ_FILES_DEBUG := $(SRC_FILES_DEBUG:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
#---------- Targets ----------#
all: $(BIN_DIR)/$(PROJECT).exe
$(BIN_DIR)/$(PROJECT).exe: clean $(OBJ_FILES_DEBUG)
@ echo "[+] Linking x64 Executable"
@ $(CC_X64) bin/obj/*.o -o $(BIN_DIR)/$(PROJECT).exe $(DEBUG_CFLAGS) $(DEBUG_LDFLAGS)
@ del /q bin\obj\*.o 2>nul
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "[+] Compiling $? -> $@"
@ $(CC_X64) -o $@ -c $? $(DEBUG_CFLAGS) $(DEBUG_LDFLAGS)
#---------- Utility ----------#
clean:
@ del /q bin\obj\*.o 2>nul
@ del /q bin\obj\*.s 2>nul
@ del /q bin\obj\*.ii 2>nul
@ del /q bin\*.bin 2>nul
print:
@echo "SRC_FILES_DEBUG: $(SRC_FILES_DEBUG)"
@echo "SRC_FILES: $(SRC_FILES)"
@echo "OBJ_FILES: $(OBJ_FILES)"
@echo "OBJ_FILES_DEBUG: $(OBJ_FILES_DEBUG)"