-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile_x86_64
41 lines (34 loc) · 1.04 KB
/
makefile_x86_64
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
.PHONY: bootstrap
bootstrap: bin/kernelx64.elf
# we want to use clang and output a PE/COFF formatted file
# these are the zig flags
ZFLAGS = \
-target x86_64-uefi \
-fClang \
-ofmt=coff \
--subsystem efi_application \
-fLLD
# we want a freestanding executable
CFLAGS+= \
-target x86_64-unknown-windows \
-ffreestanding \
-mcmodel=large \
-fno-pic \
-fshort-wchar \
-mno-red-zone \
-Wall
# force use of LLVM Linker and output a PE/COFF formatted file
LDFLAGS+= \
-target x86_64-unknown-windows \
-nostdlib \
-Wl,-entry:efi_main \
-Wl,-subsystem:efi_application \
-fuse-ld=lld
bin/kernelx64.elf: bin/efi/boot bin/uefi_bootstrap.obj bin/efi/boot/bootx64.efi
cd kernel && make -f makefile_x86_64
bin/efi/boot:
mkdir -p $@
bin/uefi_bootstrap.obj: bootstrap/uefi_bootstrap.zig
zig build-obj $(ZFLAGS) -femit-bin=$@ -cflags $(CFLAGS) -- $^
bin/efi/boot/bootx64.efi: bin/uefi_bootstrap.obj
clang $(CFLAGS) -o $@ bin/uefi_bootstrap.obj $(LDFLAGS)