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.

49 lines
1.2 KiB

8 years ago
8 years ago
  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 doc
  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. debug: $(iso)
  19. qemu-system-x86_64 -cdrom $(iso) -s -S
  20. iso: $(iso)
  21. $(iso): $(kernel)
  22. mkdir -p build/isofiles/boot/grub
  23. cp $(kernel) build/isofiles/boot/kernel.bin
  24. cp $(grub_cfg) build/isofiles/boot/grub
  25. grub-mkrescue -o $(iso) build/isofiles
  26. rm -r build/isofiles
  27. $(kernel): $(asm_obj) $(rs_kernel)
  28. ld -n --gc-sections -T $(linker_script) -o $(kernel) $^
  29. .PHONY: $(rs_kernel) # always run xargo
  30. $(rs_kernel):
  31. xargo build --target $(rs_target)
  32. build/$(arch)/%.o: src/arch/$(arch)/%.asm
  33. @mkdir -p $(shell dirname $@)
  34. nasm -felf64 $< -o $@
  35. doc:
  36. cargo rustdoc --lib -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports