2020-03-02 13:10:21 +01:00
|
|
|
PROGRAMS = hello.com
|
2021-02-18 20:38:56 +01:00
|
|
|
KERNEL = @rdos.com
|
|
|
|
DISTFILES = $(KERNEL) $(PROGRAMS)
|
2020-03-01 17:43:23 +01:00
|
|
|
ROMS =
|
2019-04-21 12:14:06 +02:00
|
|
|
|
2020-09-17 10:59:22 +02:00
|
|
|
QEMU = qemu-system-i386
|
2020-03-01 17:43:23 +01:00
|
|
|
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
2019-03-24 19:30:49 +01:00
|
|
|
|
2020-09-17 10:59:22 +02:00
|
|
|
VERSION = $(shell git log -1 --format=%cd --date=format:%Y%m%d)
|
2020-10-11 23:33:01 +02:00
|
|
|
PRODUCT = rdos
|
|
|
|
LABEL = $(PRODUCT) $(VERSION)
|
2020-09-17 10:59:22 +02:00
|
|
|
|
2020-03-01 17:43:23 +01:00
|
|
|
NASM = nasm
|
2020-10-11 23:33:01 +02:00
|
|
|
NASM_ARGS = -s -Ilib -DPRODUCT=$(PRODUCT) -DVERSION=$(VERSION)
|
2020-03-01 13:03:35 +01:00
|
|
|
|
2020-10-20 23:03:47 +02:00
|
|
|
QEMU_ARGS += $(shell test -w /dev/kvm && echo --enable-kvm)
|
2020-03-01 17:43:23 +01:00
|
|
|
|
|
|
|
ifdef DEBUG
|
2020-08-15 22:58:40 +02:00
|
|
|
ROMS += dprintf.rom
|
2021-01-23 18:44:15 +01:00
|
|
|
NASM_ARGS += -l $(basename $@).lst -DDEBUG=1
|
2020-03-01 17:43:23 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef DISPLAY
|
|
|
|
QEMU_ARGS += --display curses
|
|
|
|
endif
|
|
|
|
|
2021-02-03 01:27:44 +01:00
|
|
|
SYS = host/sys.elf
|
|
|
|
FIXROM = host/fix-rom.elf
|
|
|
|
|
2021-01-23 18:44:15 +01:00
|
|
|
.PHONY: default clean qemu-floppy5 qemu-floppy3
|
2021-02-03 01:27:44 +01:00
|
|
|
.PRECIOUS: $(DISTFILES)
|
2020-03-01 17:43:23 +01:00
|
|
|
|
2020-09-17 07:57:46 +02:00
|
|
|
default: fd1440.img
|
2020-03-01 17:43:23 +01:00
|
|
|
|
|
|
|
# Host utils
|
2021-02-03 01:27:44 +01:00
|
|
|
host/%.elf: host/%.c
|
2020-03-01 17:43:23 +01:00
|
|
|
$(CC) -o $@ $<
|
|
|
|
|
|
|
|
# COM programs
|
2020-03-30 14:13:21 +02:00
|
|
|
%.com: com/%.asm
|
2020-03-31 21:46:59 +02:00
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
2020-03-01 17:43:23 +01:00
|
|
|
|
|
|
|
# Bootloaders, first sector on partition
|
2020-03-30 14:13:21 +02:00
|
|
|
%.bs: boot/%.asm
|
2020-03-31 21:46:59 +02:00
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
2020-03-01 18:08:25 +01:00
|
|
|
|
2021-02-07 17:17:31 +01:00
|
|
|
@rdos.com: kernel/*.asm
|
2020-04-27 15:56:41 +02:00
|
|
|
|
2020-04-06 21:20:15 +02:00
|
|
|
# Special case: variations of FAT vbr
|
|
|
|
fat1.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT12 -DCHS -o $@ $<
|
|
|
|
|
|
|
|
fat4.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT16 -DCHS -o $@ $<
|
|
|
|
|
|
|
|
fat6.bs: boot/fat.asm
|
|
|
|
$(NASM) $(NASM_ARGS) -DFAT16 -DCHS -DLARGE -o $@ $<
|
|
|
|
|
2020-03-01 18:08:25 +01:00
|
|
|
# BIOS option roms
|
2021-02-03 01:27:44 +01:00
|
|
|
%.rom: rom/%.asm $(FIXROM)
|
|
|
|
$(NASM) $(NASM_ARGS) -o $@ $< && $(FIXROM) $@
|
2020-03-01 17:43:23 +01:00
|
|
|
|
2021-02-03 01:27:44 +01:00
|
|
|
fd%.img: $(DISTFILES) $(SYS)
|
|
|
|
mformat -C -i $@ -f $* -c 2 -v "$(LABEL)" ::
|
2020-09-20 19:58:19 +02:00
|
|
|
mcopy -i $@ $(DISTFILES) ::
|
2021-02-18 20:38:56 +01:00
|
|
|
$(SYS) $@ $(KERNEL)
|
2020-04-21 20:22:32 +02:00
|
|
|
|
2021-02-18 20:38:56 +01:00
|
|
|
hdd.img: mbr.bs $(KERNEL) fd1440.img
|
2021-02-18 20:00:54 +01:00
|
|
|
dd if=mbr.bs bs=512 count=1 of=$@
|
2021-02-18 20:38:56 +01:00
|
|
|
dd if=$(KERNEL) bs=512 seek=1 of=$@
|
2021-02-18 20:00:54 +01:00
|
|
|
dd if=fd1440.img bs=512 seek=63 of=$@
|
|
|
|
|
2019-03-24 19:30:49 +01:00
|
|
|
clean:
|
2020-03-01 17:43:23 +01:00
|
|
|
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
|
2021-02-03 01:27:44 +01:00
|
|
|
rm -f host/*.elf
|
2020-03-01 17:43:23 +01:00
|
|
|
|
2020-12-18 19:29:26 +01:00
|
|
|
qemu-floppy3: fd1440.img $(ROMS)
|
2020-09-17 07:57:46 +02:00
|
|
|
$(QEMU) $(QEMU_ARGS) -boot a -fda fd1440.img
|
2020-03-01 17:43:23 +01:00
|
|
|
|
2020-12-18 19:29:26 +01:00
|
|
|
qemu-floppy5: fd360.img $(ROMS)
|
2021-01-21 23:28:57 +01:00
|
|
|
$(QEMU) $(QEMU_ARGS) -boot a -fda fd360.img
|
2021-02-18 20:00:54 +01:00
|
|
|
|
|
|
|
qemu-hdd: hdd.img $(ROMS)
|
|
|
|
$(QEMU) $(QEMU_ARGS) -boot c -hda hdd.img
|
2021-04-04 23:41:22 +02:00
|
|
|
|
|
|
|
qemu-uartctrl: uartctrl.rom
|
|
|
|
$(QEMU) $(QEMU_ARGS) -option-rom uartctrl.rom -serial stdio
|