Makefile 503 B

1234567891011121314151617181920212223
  1. .POSIX:
  2. ISODIR := iso
  3. MULTIBOOT := $(ISODIR)/boot/main.elf
  4. MAIN := main.img
  5. .PHONY: clean run
  6. $(MAIN):
  7. as -32 boot.S -o boot.o
  8. gcc -c kernel.c -ffreestanding -m32 -o kernel.o -std=gnu99
  9. gcc -ffreestanding -m32 -nostdlib -o '$(MULTIBOOT)' -T linker.ld boot.o kernel.o -lgcc
  10. grub-mkrescue -o '$@' '$(ISODIR)'
  11. clean:
  12. rm -f *.o '$(MULTIBOOT)' '$(MAIN)'
  13. run: $(MAIN)
  14. qemu-system-i386 -cdrom '$(MAIN)'
  15. # Would also work.
  16. #qemu-system-i386 -hda '$(MAIN)'
  17. #qemu-system-i386 -kernel '$(MULTIBOOT)'