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. rs_src := $(wildcard src/*.rs)
  9. linker_script := src/arch/$(arch)/linker.ld
  10. grub_cfg := src/arch/$(arch)/grub.cfg
  11. .PHONY: all clean run iso
  12. all: $(kernel)
  13. clean:
  14. rm -r build/ target/
  15. run: $(iso)
  16. qemu-system-x86_64 -cdrom $(iso) -s
  17. run-trif: $(iso)
  18. qemu-system-x86_64 -cdrom $(iso) -no-reboot -d int -s
  19. iso: $(iso)
  20. $(iso): $(kernel)
  21. mkdir -p build/isofiles/boot/grub
  22. cp $(kernel) build/isofiles/boot/kernel.bin
  23. cp $(grub_cfg) build/isofiles/boot/grub
  24. grub-mkrescue -o $(iso) build/isofiles
  25. rm -r build/isofiles
  26. $(kernel): $(asm_obj) $(rs_kernel)
  27. ld -n --gc-sections -T $(linker_script) -o $(kernel) $^
  28. $(rs_kernel): $(rs_src)
  29. xargo build --target $(rs_target)
  30. build/$(arch)/%.o: src/arch/$(arch)/%.asm
  31. @mkdir -p $(shell dirname $@)
  32. nasm -felf64 $< -o $@