-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (49 loc) · 1.85 KB
/
Copy pathMakefile
File metadata and controls
63 lines (49 loc) · 1.85 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
NAME := bloodfang
CCX64 := clang -target x86_64-w64-mingw32
CCX86 := clang -target i686-w64-mingw32
ASMCC := nasm
CFLAGS := -Os -nostdlib -fno-asynchronous-unwind-tables -std=c++20
CFLAGS += -fno-ident -fpack-struct=8 -falign-functions=1 -s -w -mno-sse
CFLAGS += -ffunction-sections -falign-jumps=1 -falign-labels=1
CFLAGS += -Wl,-s,--no-seh,--enable-stdcall-fixup -masm=intel -fno-exceptions
CFLAGS += -fms-extensions -fPIC -Iinclude -Wl,-Tscripts/linker.ld
SRC := $(wildcard src/*.cc)
OBJ64 := $(SRC:%.cc=%.x64.obj)
OBJ86 := $(SRC:%.cc=%.x86.obj)
release: x64 x86
debug: x64-debug x86-debug
x64-debug: CFLAGS += -D DEBUG
x64-debug: x64
x86-debug: CFLAGS += -D DEBUG
x86-debug: x86
x64: nasm64 $(OBJ64)
@ echo "compiling x64 project"
@ $(CCX64) bin/obj/*.x64.obj -o bin/$(NAME).x64.exe $(CFLAGS)
@ objcopy --dump-section .text=bin/$(NAME).x64.bin bin/$(NAME).x64.exe
@ rm bin/$(NAME).x64.exe
x86: nasm86 $(OBJ86)
@ echo "compiling x86 project"
@ $(CCX86) bin/obj/*.x86.obj -o bin/$(NAME).x86.exe $(CFLAGS)
@ objcopy --dump-section .text=bin/$(NAME).x86.bin bin/$(NAME).x86.exe
@ rm bin/$(NAME).x86.exe
%.x64.obj: %.cc
@ echo "-> compiling $< to $(notdir $@)"
@ $(CCX64) -o bin/obj/$(notdir $@) -c $< $(CFLAGS)
%.x86.obj: %.cc
@ echo "-> compiling $< to $(notdir $@)"
@ $(CCX86) -o bin/obj/$(notdir $@) -c $< $(CFLAGS)
nasm64:
@ $(ASMCC) -f win64 src/asm/entry.x64.asm -o bin/obj/entry.x64.obj
@ $(ASMCC) -f win64 src/asm/utils.x64.asm -o bin/obj/utils.x64.obj
nasm86:
@ $(ASMCC) -f win32 src/asm/entry.x86.asm -o bin/obj/entry.x86.obj
@ $(ASMCC) -f win32 src/asm/utils.x86.asm -o bin/obj/utils.x86.obj
stomper:
@ $(CCX64) test/stomper.cc -o test/stomper.x64.exe -w
@ $(CCX86) test/stomper.cc -o test/stomper.x86.exe -w
clean:
@ rm -f bin/obj/*.x64.obj
@ rm -f bin/obj/*.x86.obj
@ rm -f bin/*.exe
@ rm -f bin/*.bin
@ echo "removed object files"