Newer
Older
honey-os / Makefile
@biosfood biosfood on 5 Nov 2023 1 KB enable qemu scisi debug logging
  1. IMAGE_FILE = /run/user/1000/honey-os.img
  2.  
  3. CC = i686-elf-gcc
  4. CCFLAGS = -m32 -mtune=generic -ffreestanding -nostdlib -c -I src/include -I src/kernel/include -Wno-discarded-qualifiers -fms-extensions -Wno-shift-count-overflow -O0
  5. LD = i686-elf-ld
  6. LD_FLAGS = -z max-page-size=0x1000 -T link.ld
  7. AS = nasm
  8. ASFlAGS = -felf32
  9. EMU = qemu-system-x86_64
  10. EMUFLAGS = -m 1G -drive if=none,id=stick,format=raw,file=$(IMAGE_FILE) -no-reboot -no-shutdown -monitor stdio -d int -D crashlog.log -s -d int -device qemu-xhci -device usb-mouse -device usb-storage,drive=stick,commandlog=on -device usb-kbd
  11.  
  12. BUILD_FOLDER = build
  13.  
  14. SOURCE_FILES := $(shell find src/kernel -name *.c -or -name *.asm -or -name *.s)
  15. OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o)
  16.  
  17. run: build initrd hlib userPrograms $(IMAGE_FILE)
  18. @echo "starting qemu"
  19. @$(EMU) $(EMUFLAGS)
  20.  
  21. build:
  22. @mkdir build
  23.  
  24. initrd:
  25. @mkdir initrd
  26.  
  27. $(IMAGE_FILE): rootfs/boot/kernel rootfs/initrd.tar
  28. @echo "creating the iso image"
  29. @grub-mkrescue -o $(IMAGE_FILE) rootfs
  30.  
  31. rootfs/boot/kernel: $(OBJS) link.ld
  32. @echo "linking"
  33. @$(LD) $(LD_FLAGS) -o $@ $(OBJS)
  34.  
  35. $(BUILD_FOLDER)/%.asm.o: %.asm
  36. @echo "asembling $<"
  37. @mkdir -p $(dir $@)
  38. @$(AS) $(ASFlAGS) $< -o $@
  39.  
  40. $(BUILD_FOLDER)/%.c.o: %.c
  41. @echo "compiling $<"
  42. @mkdir -p $(dir $@)
  43. @$(CC) $(CCFLAGS) -r $< -o $@
  44.  
  45. $(BUILD_FOLDER)/%.s.o: %.s
  46. @echo "assembling $<"
  47. @mkdir -p $(dir $@)
  48. @$(CC) $(CCFLAGS) -r $< -o $@
  49.  
  50. userPrograms:
  51. @make --silent -C src/userland
  52.  
  53. hlib:
  54. @make --silent -C src/hlib
  55.  
  56. clean:
  57. @echo "clearing build folder"
  58. @rm -r $(BUILD_FOLDER) initrd src/userland/build