rdos/Makefile

87 lines
1.9 KiB
Makefile
Raw Normal View History

2020-03-01 17:43:23 +01:00
FLOPPY = 360
2020-03-02 13:10:21 +01:00
PROGRAMS = hello.com
2020-03-01 17:43:23 +01:00
DISTFILES = $(PROGRAMS)
ROMS =
2020-03-01 17:43:23 +01:00
QEMU_ARCH = $(shell uname -m)
QEMU = qemu-system-$(QEMU_ARCH)
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
2020-03-01 17:43:23 +01:00
NASM = nasm
2020-03-16 18:24:39 +01:00
NASM_ARGS = -s -I. -Ilib -w-macro-params -DFLOPPY=$(FLOPPY)
2020-03-01 17:43:23 +01:00
EMUL = utils/emul
ifdef KVM
QEMU_ARGS += --enable-kvm
endif
ifdef DEBUG
ROMS += rom/debug.rom
NASM_ARGS += -l $(basename $@).lst
endif
ifndef DISPLAY
QEMU_ARGS += --display curses
endif
.PHONY: default bootstrap clean qemu-rom qemu-floppy qemu-pxe
default: fdimage.img
# 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 $@ $<
2020-03-01 18:08:25 +01:00
cp437.bin: cp437.bmp utils/bmp2font
2020-03-01 17:43:23 +01:00
utils/bmp2font $< $@
2020-03-01 18:08:25 +01:00
vga11.com: cp437.bin
2020-03-01 17:43:23 +01:00
# COM programs
%.com: %.asm
2020-03-01 18:08:25 +01:00
$(NASM) $(NASM_ARGS) -DBASE=0x0100 -DCOM -o $@ $<
2020-03-01 17:43:23 +01:00
# Bootloaders, first sector on partition
%.bs: %.asm
2020-03-01 18:08:25 +01:00
$(NASM) $(NASM_ARGS) -DBASE=0x7C00 -DBOOT -o $@ $<
2020-03-01 17:43:23 +01:00
: check boot signature
2020-03-01 18:20:03 +01:00
test "$$(echo $$(xxd -p -l 2 -s 510 $@))" == 55aa
2020-03-01 17:43:23 +01:00
# Network bootstrap protocol as used for PXE
%.0: %.asm
2020-03-01 18:08:25 +01:00
$(NASM) $(NASM_ARGS) -DBASE=0x7C00 -DNBP -o $@ $<
# BIOS option roms
2020-03-02 13:10:21 +01:00
%.rom: rom/%.asm utils/fix-rom
2020-03-01 18:08:25 +01:00
$(NASM) $(NASM_ARGS) -DBASE=0x0000 -DROM -o $@ $< && utils/fix-rom $@
2020-03-01 17:43:23 +01:00
2020-03-02 13:10:21 +01:00
fdimage.img: fat.bs $(DISTFILES)
mformat -C -i $@ -f $(FLOPPY) -B fat.bs ::
2020-03-01 17:43:23 +01:00
mcopy -i $@ $(DISTFILES) ::
2020-03-16 18:24:39 +01:00
hdimage.img: mbr.bs fdimage.img
cat mbr.bs fdimage.img >$@
part.img: fat32.bs
dd if=/dev/zero bs=1024 count=33k of=$@
mformat -F -i part.img -B fat32.bs ::
2019-09-18 00:41:39 +02:00
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-floppy: fdimage.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot a -fda fdimage.img
2020-03-16 18:24:39 +01:00
qemu-hdd: part.img $(ROMS)
$(QEMU) $(QEMU_ARGS) -boot c -hda part.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