Files
5150/Makefile
2025-09-24 00:51:56 +02:00

85 lines
2.4 KiB
Makefile

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 crt0.c
ia16-elf-gcc -o crc16.bin -Os -nostdlib crc16.s crt0.c
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 $@ $^
bootsectors = fat12boot.bin wozmon.bin
$(bootsectors):
ia16-elf-objcopy -O binary $? $@
truncate -s 510 $@
printf "\125\252" >> $@
fat12boot.elf: fat12boot.o fat12.o bootsect.S
fat12boot.elf: LDFLAGS += -T bootsect.ld
fat12boot.bin: fat12boot.elf
polmon.elf: LDFLAGS += -T flat0600.ld
polmon.elf: polmon.o
polmon.com: polmon.elf
ia16-elf-objcopy -O binary $? $@
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
.PHONY: clean
clean: ## Remove generated files
rm -rf wozmon.bin crc16.bin readfloppy.bin writefloppy.bin fat12boot.bin
.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 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=debug.bin -o . --target=export .
docker build --build-arg TARGET=dosdbt.bin -o . --target=export .
docker build --build-arg TARGET=format.bin -o . --target=export .
docker build --build-arg TARGET=polmon.com -o . --target=export .
docker build --build-arg TARGET=fat12boot.bin -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