76 lines
1.6 KiB
Makefile
76 lines
1.6 KiB
Makefile
PROGRAMS = hello.com
|
|
DISTFILES = kernel.bs $(PROGRAMS)
|
|
ROMS =
|
|
|
|
QEMU = qemu-system-i386
|
|
QEMU_ARGS = $(addprefix --option-rom ,$(ROMS))
|
|
|
|
VERSION = $(shell git log -1 --format=%cd --date=format:%Y%m%d)
|
|
PRODUCT = rdos
|
|
LABEL = $(PRODUCT) $(VERSION)
|
|
|
|
NASM = nasm
|
|
NASM_ARGS = -s -Ilib -DPRODUCT=$(PRODUCT) -DVERSION=$(VERSION)
|
|
|
|
QEMU_ARGS += $(shell test -w /dev/kvm && echo --enable-kvm)
|
|
|
|
ifdef DEBUG
|
|
ROMS += dprintf.rom
|
|
NASM_ARGS += -l $(basename $@).lst -DDEBUG=1
|
|
endif
|
|
|
|
ifndef DISPLAY
|
|
QEMU_ARGS += --display curses
|
|
endif
|
|
|
|
SYS = host/sys.elf
|
|
FIXROM = host/fix-rom.elf
|
|
|
|
.PHONY: default clean qemu-floppy5 qemu-floppy3
|
|
.PRECIOUS: $(DISTFILES)
|
|
|
|
default: fd1440.img
|
|
|
|
# Host utils
|
|
host/%.elf: host/%.c
|
|
$(CC) -o $@ $<
|
|
|
|
# COM programs
|
|
%.com: com/%.asm
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
|
|
|
# Bootloaders, first sector on partition
|
|
%.bs: boot/%.asm
|
|
$(NASM) $(NASM_ARGS) -o $@ $<
|
|
|
|
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 $@ $<
|
|
|
|
# BIOS option roms
|
|
%.rom: rom/%.asm $(FIXROM)
|
|
$(NASM) $(NASM_ARGS) -o $@ $< && $(FIXROM) $@
|
|
|
|
fd%.img: $(DISTFILES) $(SYS)
|
|
mformat -C -i $@ -f $* -c 2 -v "$(LABEL)" ::
|
|
mcopy -i $@ $(DISTFILES) ::
|
|
$(SYS) $@ hello.com
|
|
|
|
clean:
|
|
rm -f *.com *.bs *.0 *.lst *.img *.bin *.rom
|
|
rm -f host/*.elf
|
|
|
|
qemu-floppy3: fd1440.img $(ROMS)
|
|
$(QEMU) $(QEMU_ARGS) -boot a -fda fd1440.img
|
|
|
|
qemu-floppy5: fd360.img $(ROMS)
|
|
$(QEMU) $(QEMU_ARGS) -boot a -fda fd360.img
|