84 lines
1.7 KiB
Makefile
84 lines
1.7 KiB
Makefile
FLOPPY = 360
|
|
|
|
PROGRAMS = hello.com
|
|
DISTFILES = $(PROGRAMS) kernel.bs
|
|
ROMS =
|
|
|
|
QEMU_ARCH = $(shell uname -m)
|
|
QEMU = qemu-system-$(QEMU_ARCH)
|
|
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
|
|
|
NASM = nasm
|
|
NASM_ARGS = -s -DFLOPPY=$(FLOPPY)
|
|
|
|
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
|
|
utils/%: %.c
|
|
mkdir -p utils
|
|
$(CC) -o $@ $<
|
|
|
|
cp437.bin: cp437.bmp utils/bmp2font
|
|
utils/bmp2font $< $@
|
|
|
|
vga11.com: cp437.bin
|
|
|
|
# COM programs
|
|
%.com: com/%.asm
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
|
|
|
# Bootloaders, first sector on partition
|
|
%.bs: boot/%.asm
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
|
|
|
# BIOS option roms
|
|
%.rom: rom/%.asm utils/fix-rom
|
|
$(NASM) $(NASM_ARGS) -o $@ $< && utils/fix-rom $@
|
|
|
|
fdimage.img: fat.bs $(DISTFILES)
|
|
mformat -C -i $@ -f $(FLOPPY) -B fat.bs ::
|
|
mcopy -i $@ $(DISTFILES) ::
|
|
|
|
hdimage.img: mbr.bs fdimage.img
|
|
cat mbr.bs fdimage.img >$@
|
|
|
|
part.img: fat32.bs $(DISTFILES)
|
|
dd if=/dev/zero bs=1024 count=33k of=$@
|
|
mformat -i $@ -F -B fat32.bs ::
|
|
mmd -i $@ ::rdos
|
|
mcopy -i $@ $(DISTFILES) ::rdos
|
|
mattrib -i $@ +s ::rdos ::rdos/kernel.bs
|
|
|
|
clean:
|
|
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
|
|
rm -rf utils
|
|
|
|
qemu-floppy: fdimage.img $(ROMS)
|
|
$(QEMU) $(QEMU_ARGS) -boot a -fda fdimage.img
|
|
|
|
qemu-hdd: part.img $(ROMS)
|
|
$(QEMU) $(QEMU_ARGS) -boot c -hda part.img
|
|
|
|
qemu-pxe: pxeboot.0 $(ROMS)
|
|
$(QEMU) $(QEMU_ARGS) -boot n \
|
|
-option-rom /usr/share/qemu/pxe-rtl8139.rom \
|
|
-device e1000,netdev=mynet0,mac=52:54:00:12:34:56 \
|
|
-netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9,tftp=$(CURDIR),bootfile=pxeboot.0
|