You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

  1. arch := x86_64
  2. kernel := build/$(arch)/kernel.bin
  3. iso := build/$(arch)/os.iso
  4. rs_target := $(arch)-unknown-none
  5. rs_kernel := target/$(rs_target)/debug/libsparkle_os.a
  6. asm_src := $(wildcard src/arch/$(arch)/*.asm)
  7. asm_obj := $(patsubst src/arch/$(arch)/%.asm, build/$(arch)/%.o, $(asm_src))
  8. linker_script := src/arch/$(arch)/linker.ld
  9. grub_cfg := src/arch/$(arch)/grub.cfg
  10. .PHONY: all clean run iso
  11. all: $(kernel)
  12. clean:
  13. rm -r build/ target/
  14. run: $(iso)
  15. qemu-system-x86_64 -cdrom $(iso) -s
  16. run-trif: $(iso)
  17. qemu-system-x86_64 -cdrom $(iso) -no-reboot -d int -s
  18. iso: $(iso)
  19. $(iso): $(kernel)
  20. mkdir -p build/isofiles/boot/grub
  21. cp $(kernel) build/isofiles/boot/kernel.bin
  22. cp $(grub_cfg) build/isofiles/boot/grub
  23. grub-mkrescue -o $(iso) build/isofiles
  24. rm -r build/isofiles
  25. $(kernel): $(asm_obj) $(rs_kernel)
  26. ld -n --gc-sections -T $(linker_script) -o $(kernel) $^
  27. .PHONY: $(rs_kernel) # always run xargo
  28. $(rs_kernel):
  29. xargo build --target $(rs_target)
  30. build/$(arch)/%.o: src/arch/$(arch)/%.asm
  31. @mkdir -p $(shell dirname $@)
  32. nasm -felf64 $< -o $@