58 lines
1.2 KiB
Makefile
58 lines
1.2 KiB
Makefile
FLOPPY = 360
|
|
|
|
PROGRAMS = $(patsubst %.asm,%.com,$(wildcard programs/*.asm))
|
|
DISTFILES = kernel.com $(PROGRAMS)
|
|
ROMS =
|
|
|
|
QEMU_ARCH = $(shell uname -m)
|
|
QEMU = qemu-system-$(QEMU_ARCH)
|
|
|
|
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
|
|
|
ifdef KVM
|
|
QEMU_ARGS += --enable-kvm
|
|
endif
|
|
|
|
ifdef DEBUG
|
|
ROMS += debug.rom
|
|
endif
|
|
|
|
ifndef DISPLAY
|
|
QEMU_ARGS += --display curses
|
|
endif
|
|
|
|
.PHONY: default clean qemu-rom qemu-floppy
|
|
|
|
default: kernel.rom
|
|
|
|
kernel.com: kernel/*.asm lib/*.asm
|
|
nasm -s -o $@ -l kernel.lst -I lib -I kernel kernel/main.asm
|
|
|
|
debug.rom: debug/*.asm lib/*.asm
|
|
nasm -s -o $@ -I lib -I debug debug/main.asm && scripts/fix-rom.sh $@
|
|
|
|
boot/floppy.bs: boot/fatvbr.asm
|
|
nasm -s -DCMDLINE='"KERNEL.COM"' -o $@ $<
|
|
|
|
boot/mbr.bs: boot/mbr.asm
|
|
nasm -s -DFLOPPY=$(FLOPPY) -o $@ $<
|
|
|
|
programs/%.com: programs/%.asm
|
|
nasm -s -I lib -o $@ $<
|
|
|
|
fdimage.img: boot/floppy.bs $(DISTFILES)
|
|
mformat -C -i $@ -f $(FLOPPY) -B boot/floppy.bs ::
|
|
mcopy -i $@ $(DISTFILES) ::
|
|
|
|
hdimage.img: boot/mbr.bs fdimage.img
|
|
cat boot/mbr.bs fdimage.img >$@
|
|
|
|
clean:
|
|
rm -f *.com *.bin *.rom *.img *.log *.bs *.lst programs/*.com
|
|
|
|
qemu-floppy: fdimage.img $(ROMS)
|
|
$(QEMU) $(QEMU_ARGS) -boot c -fda fdimage.img
|
|
|
|
qemu-hdd: hdimage.img $(ROMS)
|
|
$(QEMU) $(QEMU_ARGS) -boot c -hda hdimage.img
|