-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphony.mk
58 lines (49 loc) · 1.55 KB
/
phony.mk
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
EXTERNAL_PATH := external
LIMINE_PATH := $(EXTERNAL_PATH)/limine
ifeq ($(shell uname -s),Darwin)
OS := macOS
else
OS := other
endif
.PHONY: qemu debug test debug-test iso run clean
ISOROOT = isoroot
qemu: iso
qemu-system-x86_64 -cdrom $(ISO) -d int -no-shutdown -no-reboot
# Run a qemu instance in the background and attach a GDB instance to it
debug: iso
qemu-system-x86_64 -cdrom $(ISO) -d int -no-shutdown -no-reboot -S -gdb tcp::1234 &
ifeq ($(OS), macOS)
lldb \
-o "target create $(BIN)" \
-o "gdb-remote localhost:1234" \
-o "breakpoint set --name kernel_main" \
-o "c"
else
gdb -ex 'target remote localhost:1234' -ex 'symbol-file $(BIN)' -ex 'b kernel_main'
endif
# run with DEBUG flags but don't attach a debugger
test: CPPFLAGS += -DDEBUG_BUILD
test: qemu
debug: CPPFLAGS += -DDEBUG_BUILD
debug: debug
# Build a bootable CD-ROM for the OS
iso: $(BIN)
# Build limine-deploy.
cd $(LIMINE_PATH)
make -C $(LIMINE_PATH)
cd ..
# Create a directory which will be our ISO root.
mkdir -p $(ISOROOT)
# Copy the relevant files over.
cp -v $(BIN) limine.cfg $(LIMINE_PATH)/limine.sys \
$(LIMINE_PATH)/limine-cd.bin $(LIMINE_PATH)/limine-cd-efi.bin $(ISOROOT)/
# Create the bootable ISO.
xorriso -as mkisofs -b limine-cd.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot limine-cd-efi.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
$(ISOROOT) -o $(ISO)
# Install Limine stage 1 and 2 for legacy BIOS boot.
./$(LIMINE_PATH)/limine-deploy $(ISO)
clean:
rm -rf $(BIN) $(ISO) $(ISOROOT) $(OBJS) $(HEADER_DEPS) $(CLEAN)