Makefile 613 B

12345678910111213141516171819202122232425262728293031323334
  1. ASM=nasm
  2. BIN=bin
  3. CC=i686-elf-gcc
  4. CFLAGS=-ffreestanding -fno-pie -ansi
  5. LD=i686-elf-ld
  6. LDFLAGS=-Ttext 0x1000 --oformat binary
  7. OBJ=kernel/kernel_entry.o kernel/kernel.o kernel/ports.o kernel/util.o drivers/screen.o
  8. all: os-image
  9. os-image: boot/boot_sect.bin kernel/kernel.bin
  10. mkdir -p $(BIN)
  11. cat $^ > $(BIN)/$@
  12. # build kernel binary file
  13. kernel/kernel.bin: $(OBJ)
  14. $(LD) $(LDFLAGS) $^ -o $@
  15. %.o: %.c
  16. $(CC) $(CFLAGS) -c $< -o $@
  17. %.o: %.asm
  18. $(ASM) $< -f elf -o $@
  19. %.bin: %.asm
  20. $(ASM) $< -f bin -I 'boot/' -o $@
  21. .PHONY: clean
  22. clean:
  23. rm -rf boot/*.bin kernel/*.bin
  24. rm -rf kernel/*.o boot/*.o drivers/*.o