diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2025-04-13 18:03:57 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2025-04-13 18:03:57 +0200 |
commit | bdc785b6d09ee0bc6f289f707b0fd317448027b4 (patch) | |
tree | 34ce86e4c785833591b45e3f0aa33b3ed865e64e /x86-bare-metal/mbr-textmode/Makefile | |
parent | b1640f63048e60c3289f81effd8930adc45d705a (diff) | |
download | zig-playground-bdc785b6d09ee0bc6f289f707b0fd317448027b4.tar.gz zig-playground-bdc785b6d09ee0bc6f289f707b0fd317448027b4.zip |
mbr: add vga text mode example
Diffstat (limited to 'x86-bare-metal/mbr-textmode/Makefile')
-rw-r--r-- | x86-bare-metal/mbr-textmode/Makefile | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/x86-bare-metal/mbr-textmode/Makefile b/x86-bare-metal/mbr-textmode/Makefile new file mode 100644 index 0000000..7642791 --- /dev/null +++ b/x86-bare-metal/mbr-textmode/Makefile @@ -0,0 +1,28 @@ +O := BUILD + +$(O)/boot: $(O)/boot.elf | dump_info + objcopy -O binary $< $@ + +$(O)/boot.elf: mbr.ld $(O)/mbr.o $(O)/zmbr.o + ld -o $@ -nostdlib -T $^ + +$(O)/mbr.o: mbr.S | $(O) + gcc -m32 -c -o $@ -ffreestanding mbr.S + +$(O)/zmbr.o: zmbr.zig | $(O) + zig build-obj -femit-bin=$@ -target x86-freestanding-none -O ReleaseSmall $< + +clean: + $(RM) -r $(O) + +$(O): + mkdir -p $(O) + +dump_info: $(O)/boot.elf + objdump -Mintel --disassemble=kmain --visualize-jumps=extended-color $< + readelf -W -l $< + size $< + size $< | awk '/$(notdir $<)/ { print "MBR utilization " $$1/512 "%" }' + +run: $(O)/boot + qemu-system-i386 -hda $< $(QEMU_ARGS) |