2019-09-16 12:26:48 +02:00
|
|
|
FLOPPY = 360
|
2019-03-31 15:22:24 +02:00
|
|
|
|
2019-09-15 21:03:08 +02:00
|
|
|
PROGRAMS = $(patsubst %.asm,%.com,$(wildcard programs/*.asm))
|
|
|
|
DISTFILES = kernel.com $(PROGRAMS)
|
2019-09-18 13:03:21 +02:00
|
|
|
ROMS =
|
2019-09-15 21:03:08 +02:00
|
|
|
|
2019-04-21 12:14:06 +02:00
|
|
|
QEMU_ARCH = $(shell uname -m)
|
|
|
|
QEMU = qemu-system-$(QEMU_ARCH)
|
|
|
|
|
2019-09-18 13:03:21 +02:00
|
|
|
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
|
|
|
|
2019-04-21 12:14:06 +02:00
|
|
|
ifdef KVM
|
|
|
|
QEMU_ARGS += --enable-kvm
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef DEBUG
|
2019-09-18 13:03:21 +02:00
|
|
|
ROMS += debug.rom
|
2019-04-21 12:14:06 +02:00
|
|
|
endif
|
|
|
|
|
2019-09-04 15:38:32 +02:00
|
|
|
ifndef DISPLAY
|
2019-09-11 21:32:40 +02:00
|
|
|
QEMU_ARGS += --display curses
|
2019-09-04 15:38:32 +02:00
|
|
|
endif
|
|
|
|
|
2019-04-21 12:14:06 +02:00
|
|
|
.PHONY: default clean qemu-rom qemu-floppy
|
|
|
|
|
2019-04-20 23:02:35 +02:00
|
|
|
default: kernel.rom
|
2019-03-24 19:30:49 +01:00
|
|
|
|
2019-09-21 17:26:03 +02:00
|
|
|
kernel.com: kernel/*.asm lib/*.asm
|
2019-09-08 17:18:37 +02:00
|
|
|
nasm -s -o $@ -l kernel.lst -I lib -I kernel kernel/main.asm
|
2019-03-25 09:51:37 +01:00
|
|
|
|
2019-09-21 17:26:03 +02:00
|
|
|
debug.rom: debug/*.asm lib/*.asm
|
2019-09-07 01:42:39 +02:00
|
|
|
nasm -s -o $@ -I lib -I debug debug/main.asm && scripts/fix-rom.sh $@
|
|
|
|
|
2019-09-21 20:05:41 +02:00
|
|
|
boot/%.bs: boot/%.asm
|
|
|
|
nasm -s -DFLOPPY=$(FLOPPY) -DCMDLINE='"KERNEL.COM"' -o $@ $<
|
2019-09-18 00:41:39 +02:00
|
|
|
|
2019-09-15 21:03:08 +02:00
|
|
|
programs/%.com: programs/%.asm
|
|
|
|
nasm -s -I lib -o $@ $<
|
|
|
|
|
2019-09-21 20:05:41 +02:00
|
|
|
fdimage.img: boot/fat.bs $(DISTFILES)
|
2019-09-18 00:41:39 +02:00
|
|
|
mformat -C -i $@ -f $(FLOPPY) -B boot/floppy.bs ::
|
2019-09-15 21:03:08 +02:00
|
|
|
mcopy -i $@ $(DISTFILES) ::
|
2019-03-24 19:30:49 +01:00
|
|
|
|
2019-09-18 00:41:39 +02:00
|
|
|
hdimage.img: boot/mbr.bs fdimage.img
|
|
|
|
cat boot/mbr.bs fdimage.img >$@
|
|
|
|
|
2019-03-24 19:30:49 +01:00
|
|
|
clean:
|
2019-09-21 20:18:20 +02:00
|
|
|
rm -f $$(cat .gitignore) programs/*.com boot/*.bs
|
2019-04-21 12:14:06 +02:00
|
|
|
|
2019-09-18 13:03:21 +02:00
|
|
|
qemu-floppy: fdimage.img $(ROMS)
|
2019-09-08 03:04:01 +02:00
|
|
|
$(QEMU) $(QEMU_ARGS) -boot c -fda fdimage.img
|
2019-09-18 00:41:39 +02:00
|
|
|
|
2019-09-18 13:03:21 +02:00
|
|
|
qemu-hdd: hdimage.img $(ROMS)
|
2019-09-18 00:41:39 +02:00
|
|
|
$(QEMU) $(QEMU_ARGS) -boot c -hda hdimage.img
|