My crappy terminal OS
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.7 KiB

  1. C_SOURCES = $(wildcard kernel/*.c drivers/*.c cpu/*.c libc/*.c programs/*.c util/*.c)
  2. HEADERS = $(wildcard kernel/*.h drivers/*.h cpu/*.h libc/*.h programs/*.h util/*.c)
  3. # Nice syntax for file extension replacement
  4. OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o}
  5. # Change this if your cross-compiler is somewhere else
  6. CC = /home/stephen/opt/cross/bin/i686-elf-gcc
  7. GDB = /home/stephen/opt/cross/bin/i686-elf-gdb
  8. # -g: Use debugging symbols in gcc
  9. CFLAGS = -g -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs \
  10. -Wall -Wextra -Werror
  11. # First rule is run by default
  12. os-image.bin: boot/bootsect.bin boot/bootsect2.bin kernel.bin
  13. cat $^ > os-image.bin
  14. #Pad os-image.bin
  15. #dd if=/dev/null of=os-image.bin bs=1 count=0 seek=1474560
  16. # '--oformat binary' deletes all symbols as a collateral, so we don't need
  17. # to 'strip' them manually on this case
  18. kernel.bin: boot/kernel_entry.o ${OBJ}
  19. i686-elf-ld -o $@ -Ttext 0x8800 $^ --oformat binary
  20. # Used for debugging purposes
  21. kernel.elf: boot/kernel_entry.o ${OBJ}
  22. i686-elf-ld -o $@ -Ttext 0x8800 $^
  23. run: os-image.bin
  24. qemu-system-i386 -fda os-image.bin
  25. # Open the connection to qemu and load our kernel-object file with symbols
  26. debug: os-image.bin kernel.elf
  27. qemu-system-i386 -s -fda os-image.bin -d guest_errors,int &
  28. ${GDB} -ex "target remote localhost:1234" -ex "symbol-file kernel.elf"
  29. # Generic rules for wildcards
  30. # To make an object, always compile from its .c
  31. %.o: %.c ${HEADERS}
  32. ${CC} ${CFLAGS} -ffreestanding -c $< -o $@
  33. %.o: %.asm
  34. nasm $< -f elf -o $@
  35. %.bin: %.asm
  36. nasm $< -f bin -o $@
  37. clean:
  38. rm -rf *.bin *.dis *.o os-image.bin *.elf
  39. rm -rf kernel/*.o boot/*.bin drivers/*.o boot/*.o cpu/*.o libc/*.o