dev-image = 5150-dev %.bin: %.asm nasm $< -o $@ crc16.s: crc16.c ia16-elf-gcc -S -Os -o crc16.s crc16.c crc16.bin: crc16.s ia16-elf-gcc -o crc16.bin -Os -nostdlib crc16.s CC = ia16-elf-gcc CXX = ia16-elf-gcc LD = ia16-elf-gcc CXXFLAGS = -mregparmcall -ffunction-sections -Os -flto CFLAGS = -mregparmcall -ffunction-sections -Os -flto LDFLAGS = -mregparmcall -Wl,--gc-sections -Os -nostdlib -flto %.elf: $(LD) $(LDFLAGS) $(CPPFLAGS) -o $@ $^ %.com: %.elf ia16-elf-objcopy -O binary $< $@ bootsectors = fat12boot.bin wozmon.bin $(bootsectors): ia16-elf-objcopy -O binary $< $@ fat12boot.elf: fat12boot.o fat12.o bootsect.S fat12boot.elf: LDFLAGS += -T bootsect.ld fat12boot.bin: fat12boot.elf polmon.elf: LDFLAGS += -T flat1000.ld polmon.elf: polmon.o stdlib.o polio.elf: LDFLAGS += -T flat0600.ld polio.elf: polio-main.o polio.s fat12.o paracomm.o wozmon.o: polmon.cc wozmon.o: CPPFLAGS = -DWOZMON=1 wozmon.o: $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< wozmon.elf: wozmon.o bootsect.S wozmon.elf: LDFLAGS += -T bootsect.ld wozmon.elf: CPPFLAGS += -DNOBPB wozmon.bin: wozmon.elf paracli.elf: LDFLAGS += -T doscom.ld paracli.elf: paracli.s paracomm.o mushroom.elf: LDFLAGS += -T doscom.ld mushroom.elf: mushroom.s paracomm.o polos.img: fat12boot.bin polmon.com polio.com mushroom.com dd if=/dev/zero of=$@ bs=512 count=720 mformat -i $@ -t 40 -h 2 -s 9 mcopy -i $@ polio.com ::/ mcopy -i $@ polmon.com ::/ mcopy -i $@ mushroom.com ::/ dd if=fat12boot.bin of=$@ conv=notrunc .PHONY: clean clean: ## Remove generated files rm -rf *.bin *.elf *.o *.com polos.img .PHONY: dev-image dev-image: docker build -t $(dev-image) --target dev . .PHONY: dev dev: dev-image ## Launch a dev container docker run -it --rm -v $(CURDIR):/workspace $(dev-image) .PHONY: binaries binaries: ## Build all small binaries docker build --build-arg TARGET=readfloppy.bin -o . --target=export . docker build --build-arg TARGET=writefloppy.bin -o . --target=export . docker build --build-arg TARGET=crc16.bin -o . --target=export . docker build --build-arg TARGET=wozmon.bin -o . --target=export . docker build --build-arg TARGET=hello.bin -o . --target=export . docker build --build-arg TARGET=copy.bin -o . --target=export . docker build --build-arg TARGET=call.bin -o . --target=export . docker build --build-arg TARGET=format.bin -o . --target=export . docker build --build-arg TARGET=readio.bin -o . --target=export . docker build --build-arg TARGET=writeio.bin -o . --target=export . .PHONY: floppy floppy: ## Make a bootable floppy image docker build --build-arg TARGET=polos.img -o . --target=export . .PHONY: help help: ## Show this help @echo Noteworthy targets: @egrep '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' .DEFAULT_GOAL := help