rdos/Makefile

83 lines
1.8 KiB
Makefile
Raw Normal View History

PROGRAMS = hello.com sys.com
2021-02-18 20:38:56 +01:00
KERNEL = @rdos.com
DISTFILES = $(KERNEL) $(PROGRAMS)
VERSION = $(shell git log -1 --format=%cd --date=format:%Y%m%d)
PRODUCT = rdos
QEMU = qemu-system-i386
QEMU_ARGS += $(shell test -w /dev/kvm && echo --enable-kvm)
METRIC = stat -c '%8s %n'
2020-03-01 17:43:23 +01:00
NASM = nasm
NASM_ARGS = -s -Isrc --before "cpu 8086" -DPRODUCT=$(PRODUCT) -DVERSION=$(VERSION)
2020-03-01 17:43:23 +01:00
ifndef DISPLAY
QEMU_ARGS += --display curses
endif
SYS = host/sys.elf
.PHONY: default clean qemu-floppy5 qemu-floppy3
2021-12-11 17:46:00 +01:00
.PRECIOUS: %.com
2020-03-01 17:43:23 +01:00
default: fd1440.img
2020-03-01 17:43:23 +01:00
# Host utils
host/%.elf: host/%.c
2020-03-01 17:43:23 +01:00
$(CC) -o $@ $<
# COM programs
2021-12-11 17:46:00 +01:00
%.com: src/%.asm src/*.inc
$(NASM) $(NASM_ARGS) -l $(@:.com=.lst) -o $@ $<
$(METRIC) $@
2020-03-01 17:43:23 +01:00
2021-12-29 01:46:49 +01:00
%.hex: src/%.asm src/*.inc
$(NASM) $(NASM_ARGS) -f ith -l $(@:.hex=.lst) -o $@ $<
2020-03-01 17:43:23 +01:00
# Bootloaders, first sector on partition
%.bs: boot/%.asm
2020-03-31 21:46:59 +02:00
$(NASM) $(NASM_ARGS) -o $@ $<
2020-03-01 18:08:25 +01:00
@rdos.com: kernel/*.asm
2020-04-27 15:56:41 +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 $@ $<
fd%.img: $(DISTFILES) $(SYS)
mformat -C -i $@ -f $* -v "$(PRODUCT) $(VERSION)" ::
mcopy -i $@ $(DISTFILES) ::
2021-02-18 20:38:56 +01:00
$(SYS) $@ $(KERNEL)
2021-02-18 20:38:56 +01:00
hdd.img: mbr.bs $(KERNEL) fd1440.img
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=$@
dd if=fd1440.img bs=512 seek=63 of=$@
clean:
2021-12-29 01:46:49 +01:00
rm -f *.com *.bs *.0 *.lst *.img *.bin *.hex
rm -f host/*.elf
2020-03-01 17:43:23 +01:00
2021-12-14 18:46:22 +01:00
qemu-floppy3: fd1440.img
$(QEMU) $(QEMU_ARGS) -boot a -fda fd1440.img
2020-03-01 17:43:23 +01:00
2021-12-14 18:46:22 +01:00
qemu-floppy5: fd360.img
2021-01-21 23:28:57 +01:00
$(QEMU) $(QEMU_ARGS) -boot a -fda fd360.img
2021-12-14 18:46:22 +01:00
qemu-hdd: hdd.img
$(QEMU) $(QEMU_ARGS) -boot c -hda hdd.img
2021-12-11 17:46:00 +01:00
dosbox-%: %.com fd1440.img
2021-12-14 18:44:18 +01:00
dosbox -c "mount P $(CURDIR)" -c P: -c "IMGMOUNT A: FD1440.IMG -t floppy" -c "$< $(ARGS)" -c pause -c exit
2021-12-11 17:46:00 +01:00
emu2-%: %.com
emu2 $< $(ARGS)