2019-09-16 12:26:48 +02:00
|
|
|
FLOPPY = 360
|
2019-10-27 19:59:42 +01:00
|
|
|
|
2019-10-28 11:49:42 +01:00
|
|
|
BDOS = 0xF000
|
2019-10-29 12:08:11 +01:00
|
|
|
BDOSIMG = bdos/8086.bin
|
2019-10-28 11:49:42 +01:00
|
|
|
|
|
|
|
BIOS = 0xF800
|
2019-10-29 12:08:11 +01:00
|
|
|
BIOSIMG = bios/8086.bin
|
2019-10-28 11:38:18 +01:00
|
|
|
|
2019-10-18 16:43:28 +02:00
|
|
|
PROGRAMS = $(patsubst %.asm,%.com,$(wildcard com/*.asm))
|
2019-10-28 11:38:18 +01:00
|
|
|
DISTFILES = $(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-09-28 15:37:47 +02:00
|
|
|
NASM = nasm
|
2019-10-14 23:04:40 +02:00
|
|
|
NASM_ARGS = -s -Ilib -Plib/nasmcomp.asm -w-macro-params
|
2019-10-28 11:49:42 +01:00
|
|
|
NASM_ARGS += -DBDOS=$(BDOS) -DBIOS=$(BIOS)
|
2019-09-28 15:37:47 +02:00
|
|
|
|
2019-09-28 21:09:51 +02:00
|
|
|
EMUL = utils/emul
|
|
|
|
|
2019-04-21 12:14:06 +02:00
|
|
|
ifdef KVM
|
|
|
|
QEMU_ARGS += --enable-kvm
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef DEBUG
|
2019-10-18 15:50:42 +02:00
|
|
|
ROMS += rom/debug.rom
|
2019-09-28 15:37:47 +02:00
|
|
|
NASM_ARGS += -l $(basename $@).lst
|
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-09-28 15:37:47 +02:00
|
|
|
default: fdimage.img
|
2019-03-24 19:30:49 +01:00
|
|
|
|
2019-10-18 16:43:28 +02:00
|
|
|
# Boot sectors
|
2019-09-21 20:05:41 +02:00
|
|
|
boot/%.bs: boot/%.asm
|
2019-09-28 15:37:47 +02:00
|
|
|
$(NASM) $(NASM_ARGS) -DFLOPPY=$(FLOPPY) -o $@ $<
|
2019-09-18 00:41:39 +02:00
|
|
|
|
2019-10-18 16:43:28 +02:00
|
|
|
# BIOS option roms
|
2019-10-18 15:50:42 +02:00
|
|
|
rom/%.rom: rom/%.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom.sh $@
|
|
|
|
|
2019-10-18 16:43:28 +02:00
|
|
|
# Regular COM programs
|
|
|
|
com/%.com: com/%.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
|
|
|
|
2019-10-29 12:08:11 +01:00
|
|
|
bdos/%.bin: bdos/%.asm lib/*.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -o $@ -I bdos $<
|
|
|
|
|
|
|
|
bios/%.bin: bios/%.asm
|
2019-10-25 15:09:53 +02:00
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
|
|
|
|
2019-10-28 11:38:18 +01:00
|
|
|
fdimage.img: boot/fat.bs $(BDOSIMG) $(BIOSIMG) $(DISTFILES)
|
|
|
|
mformat -R 9 -C -i $@ -f $(FLOPPY) -B boot/fat.bs ::
|
|
|
|
dd if=$(BDOSIMG) bs=512 seek=1 count=4 conv=notrunc of=$@
|
|
|
|
dd if=$(BIOSIMG) bs=512 seek=5 count=4 conv=notrunc of=$@
|
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-28 15:37:47 +02:00
|
|
|
find -name '*.lst' -delete
|
2019-10-18 16:43:28 +02:00
|
|
|
rm -f $$(cat .gitignore) boot/*.bs com/*.com rom/*.rom utils/emul
|
2019-04-21 12:14:06 +02:00
|
|
|
|
2019-09-18 13:03:21 +02:00
|
|
|
qemu-floppy: fdimage.img $(ROMS)
|
2019-10-19 14:47:23 +02:00
|
|
|
$(QEMU) $(QEMU_ARGS) -boot a -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
|