Makefile 696 B

1234567891011121314151617181920212223242526272829303132
  1. # $@ = target file
  2. # $< = first dependency
  3. # $^ = all dependencies
  4. # First rule is the one executed when no paramaters are fed to the Makefile
  5. all: run
  6. # Notice how dependencies are built as needed
  7. kernel.bin: kernel_entry.o kernel.o
  8. i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary
  9. kernel_entry.o: kernel_entry.asm
  10. nasm $< -f elf -o $@
  11. kernel.o: kernel.c
  12. i386-elf-gcc -ffreestanding -c $< -o $@
  13. # Rule to disassemble the kernel - may be useful to debug
  14. kernel.dis: kernel.bin
  15. ndisasm -b 32 $< > $@
  16. bootsect.bin: bootsect.asm
  17. nasm $< -f bin -o $@
  18. os-image.bin: bootsect.bin kernel.bin
  19. cat $^ > os-image.bin
  20. run: os-image.bin
  21. qemu-system-i386 -fda $<
  22. clean:
  23. rm *.bin *.o *.dis