rdos/Makefile

88 lines
2.0 KiB
Makefile
Raw Normal View History

2020-03-02 13:10:21 +01:00
PROGRAMS = hello.com
DISTFILES = kernel.bs $(PROGRAMS)
2020-03-01 17:43:23 +01:00
ROMS =
QEMU = qemu-system-i386
2020-03-01 17:43:23 +01:00
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
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-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)
QEMU_ARGS += $(shell test -w /dev/kvm && echo --enable-kvm)
2020-03-01 17:43:23 +01:00
ifdef DEBUG
ROMS += dprintf.rom
2020-03-01 17:43:23 +01:00
NASM_ARGS += -l $(basename $@).lst
endif
ifndef DISPLAY
QEMU_ARGS += --display curses
endif
.PHONY: default bootstrap clean qemu-rom qemu-floppy qemu-pxe
default: fd1440.img
2020-03-01 17:43:23 +01:00
# Host utils
2020-03-01 18:08:25 +01:00
utils/%: %.c
2020-03-01 17:43:23 +01:00
mkdir -p utils
$(CC) -o $@ $<
# COM programs
%.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
%.bs: boot/%.asm
2020-03-31 21:46:59 +02:00
$(NASM) $(NASM_ARGS) -o $@ $<
2020-03-01 18:08:25 +01:00
2020-04-27 15:56:41 +02:00
kernel.bs: kernel/*.asm
# 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
%.rom: rom/%.asm utils/fix-rom
2020-03-31 21:46:59 +02:00
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom $@
2020-03-01 17:43:23 +01:00
fd%.img: fat1.bs $(DISTFILES)
mformat -C -i $@ -f $* -v "$(LABEL)" -B fat1.bs ::
mcopy -i $@ $(DISTFILES) ::
mattrib -i $@ +s ::kernel.bs
2020-03-01 17:43:23 +01:00
hdimage.img: mbr.bs fd1440.img
2020-09-19 10:22:50 +02:00
cat mbr.bs fd1440.img >$@
clean:
2020-03-01 17:43:23 +01:00
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
2020-03-01 18:08:25 +01:00
rm -rf utils
2020-03-01 17:43:23 +01:00
qemu-floppy3: fd1440.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot a -fda fd1440.img
2020-03-01 17:43:23 +01:00
qemu-floppy5: fd360.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot a -fda fd360.img
2020-09-19 10:22:50 +02:00
qemu-hdd: hdimage.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot c -hda hdimage.img
2020-03-01 17:43:23 +01:00
2020-03-16 18:24:39 +01:00
qemu-pxe: pxeboot.0 $(ROMS)
2020-03-01 17:43:23 +01:00
$(QEMU) $(QEMU_ARGS) -boot n \
-option-rom /usr/share/qemu/pxe-rtl8139.rom \
-device e1000,netdev=mynet0,mac=52:54:00:12:34:56 \
2020-03-16 18:24:39 +01:00
-netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9,tftp=$(CURDIR),bootfile=pxeboot.0
2020-05-29 00:32:30 +02:00
qemu-rom: kernel.rom
$(QEMU) $(QEMU_ARGS) --option-rom kernel.rom