Source

kx / boot / boot.mk

BOOTSRCPATH=boot/

boot: $(BOOTSRCPATH)boot.img

clean_boot:
	rm $(BOOTSRCPATH)*.o $(BOOTSRCPATH)*.elf $(BOOTSRCPATH)*.bin $(BOOTSRCPATH)*.img

$(BOOTSRCPATH)boot.img: $(BOOTSRCPATH)boot0.bin
	# create an empty floppy image
	dd if=/dev/zero of=$@ bs=512 count=1440

	# copy mbr (boot0.bin)
	dd if=$(BOOTSRCPATH)boot0.bin of=$@ bs=512 seek=0 conv=notrunc

$(BOOTSRCPATH)boot0.bin: $(BOOTSRCPATH)boot0.elf
	$(OBJCOPY) -O binary -j .text $^ $@

$(BOOTSRCPATH)boot0.elf: $(BOOTSRCPATH)boot0.o
	$(LD) -o $@ $^ -T $(BOOTSRCPATH)boot0.ld

$(BOOTSRCPATH)boot0.o: $(BOOTSRCPATH)boot0.S
	$(AS) -o $@ $^