rdos/Makefile

54 lines
1.3 KiB
Makefile

FD_CYLINDERS = 40
FD_HEADS = 2
FD_SECTORS = 9
QEMU_ARCH = $(shell uname -m)
QEMU = qemu-system-$(QEMU_ARCH)
QEMU_ARGS = -serial stdio
ifdef KVM
QEMU_ARGS += --enable-kvm
endif
ifdef DEBUG
QEMU_ARGS += -chardev file,path=debugcon.log,id=seabios
QEMU_ARGS += -device isa-debugcon,iobase=0x402,chardev=seabios
QEMU_ARGS += -option-rom debug.rom
DEBUGROM = debug.rom
endif
ifndef DISPLAY
QEMU_ARGS += --display none
endif
.PHONY: default clean qemu-rom qemu-floppy
default: kernel.rom
kernel.rom: kernel/*.asm lib/*.inc
nasm -s -o $@ -I lib -I kernel kernel/main.asm && scripts/fix-rom.sh $@
debug.rom: debug/*.asm lib/*.inc
nasm -s -o $@ -I lib -I debug debug/main.asm && scripts/fix-rom.sh $@
boot/%.bin: boot/%.asm lib/*.inc
nasm -s -o $@ -I boot -I lib $<
fdimage.img: boot/floppy.bin kernel.rom
dd if=/dev/zero bs=512 count=$$(( $(FD_CYLINDERS) * $(FD_HEADS) * $(FD_SECTORS) )) of=$@
mformat -i $@ -t $(FD_CYLINDERS) -h $(FD_HEADS) -n $(FD_SECTORS) -B boot/floppy.bin ::
mcopy -i $@ kernel.rom ::kernel.rom
mattrib -i $@ +s ::kernel.rom
clean:
rm -f *.com *.bin *.rom *.img *.log boot/*.bin
qemu-rom: kernel.rom $(DEBUGROM)
$(QEMU) $(QEMU_ARGS) -option-rom kernel.rom
qemu-floppy: fdimage.img $(DEBUGROM)
$(QEMU) $(QEMU_ARGS) -boot c -hda fdimage.img
qemu-serial: boot/serial.bin $(DEBUGROM)
$(QEMU) $(QEMU_ARGS) -hda boot/serial.bin