blob: 25898ccfc03ce270847879556bf7140d19ed7101 [file] [log] [blame]
# -*- mode:makefile -*-
init(kernel, kernel.elf)
preset(freestanding)
# This makes debugging hard :(
# preset(optimize)
preset(debug)
preset(32)
preset(warn)
preset(nasm)
archetype(c)
archetype(asm)
depends(sys, $(ROOT)/src/libsys, libsys.a)
depends(initrd, $(ROOT)/boot/initrd, initrd.img)
depends(ata_pio, dri/ata_pio, ata_pio.a)
depends(pci, dri/pci, pci.a)
depends(ide, dri/ide, ide.a)
depends(ext2, dri/fs/ext2, ext2.a)
# AHCI not yet implemented
# depends(ahci, dri/ahci, ahci.a)
TEST ?=
test_defines = $(TEST:%=-DTEST_%)
FS ?= ext2
CFLAGS += -I$(ROOT)/include/kernel $(test_defines) -O0 -Wno-ignored-qualifiers -Wno-sign-compare
LDFLAGS += -Tlink.ld -melf_i386
ASMFLAGS += -felf -Fdwarf
QEMUFLAGS = -drive file=hd0_ext2.img,format=raw
OBJECTS = boot.o \
main.o \
descriptor_tables.o \
io.o \
vga.o \
gdt_flush.o \
tss_flush.o \
idt.o \
log.o \
irq.o \
pic.o \
timer.o \
paging.o \
switch_table.o \
scan_codes.o \
kheap.o \
alloc.o \
vfs.o \
multiboot.o \
vfs_initrd.o \
syscall.o \
task.o \
task_api.o \
faults.o \
sync.o \
lib(ext2) \
lib(ide) \
lib(ata_pio) \
lib(pci) \
lib(sys)
type(custom_link)
debug-wait: kernel.elf
qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf
debug: kernel.elf
qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf &
@echo run "target remote localhost:1234" to connect to qemu
gdb $<
@pkill qemu-system-i38
hd0_%.img:
status_log(MKFS, $@)
@dd bs=4M count=8 if=/dev/zero of=$@
@$(patsubst hd0_%.img,mkfs.%,$@) $@
fs-info: hd0_$(FS).img
tune2fs -l $< | grep -i inode
reset-fs:
@rm hd0_ext2.img
@$(MAKE) hd0_ext2.img
@sudo $(MAKE) mount
@echo 'hi' | sudo tee $(ROOT)/mnt/hello.txt
@sudo $(MAKE) umount
@$(MAKE) qemu
qemu: kernel.elf hd0_$(FS).img
qemu-system-i386 $(QEMUFLAGS) -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot
qemu-iso: install
qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
scan_codes.c: gen_scan_codes.py scan_codes.tsv
python3 $< > $@
mount: hd0_$(FS).img
status_log(MOUNT, $^ $(ROOT)/mnt)
@mkdir -p $(ROOT)/mnt
@mount $^ $(ROOT)/mnt
umount:
status_log(UMOUNT, $(ROOT)/mnt)
@umount $(ROOT)/mnt
install: kernel.elf lib(initrd)
cp kernel.elf $(ROOT)/boot/
rm -f $(ROOT)/bin/bluejay.iso
grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
finish