From 5637db47fd974ed9b639ac10698cffaacdd4ab60 Mon Sep 17 00:00:00 2001 From: Joppe Blondel Date: Wed, 7 Oct 2026 14:42:54 +0200 Subject: [PATCH] Fixed some build system stuff --- Makefile | 19 +++++-------------- apps/basic/Makefile | 16 +++------------- memory.mk | 2 +- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 1e5ff47..5cb1186 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,10 @@ FILES := bios SOURCES := $(addprefix ./, $(addsuffix .asm, $(FILES))) TARGETS := $(addprefix $(BUILDDIR)/, $(addsuffix .bin, $(FILES))) -TOPTARGETS := all clean size +TOPTARGETS := all clean $(TOPTARGETS): $(SUBDIRS) -all: $(BUILDDIR) $(BUILDDIR)/rom.bin size +all: $(BUILDDIR) $(BUILDDIR)/rom.bin clean: rm -rf $(BUILDDIR) @@ -25,17 +25,7 @@ $(BUILDDIR)/%.bin: ./%.asm $(BUILDDIR)/memory.inc echo '>$<' $(ASM) $(ASMFLAGS) $< $@ -size: - @for file in $(TARGETS); do \ - if [ -f "$$file" ]; then \ - echo "$$file: $$(wc -c < "$$file") bytes"; \ - else \ - echo "$$file: Not built yet (run 'make')"; \ - fi \ - done - $(MAKE) -C apps/basic size --no-print-directory - -$(BUILDDIR)/basic.bin: +$(BUILDDIR)/basic.bin: $(BUILDDIR)/memory.inc $(MAKE) -C apps/basic $(or $(MAKECMDGOALS),all) --no-print-directory $(BUILDDIR)/memory.inc: memory.mk @@ -44,6 +34,8 @@ $(BUILDDIR)/memory.inc: memory.mk /^[A-Z][A-Z0-9_]*[[:space:]]*:=[[:space:]]*/ { print $$1 " .equ " $$3 }' $< > $@ $(BUILDDIR)/rom.bin: $(BUILDDIR)/bios.bin $(BUILDDIR)/basic.bin + echo "bios: $(shell wc -c < $(BUILDDIR)/bios.bin) / $$(($(BIOS_ROM_SIZE)+0))" + echo "basic: $(shell wc -c < $(BUILDDIR)/basic.bin) / $$(($(BASIC_ROM_SIZE)+0))" objcopy --pad-to=$$(($(BIOS_ROM_START)+$(BIOS_ROM_SIZE))) \ -I binary $(BUILDDIR)/bios.bin -O binary $(BUILDDIR)/bios_padded.bin objcopy --pad-to=$(BASIC_ROM_SIZE) \ @@ -52,4 +44,3 @@ $(BUILDDIR)/rom.bin: $(BUILDDIR)/bios.bin $(BUILDDIR)/basic.bin .PHONY: $(TOPTARGETS) $(SUBDIRS) - diff --git a/apps/basic/Makefile b/apps/basic/Makefile index 92a9f8f..f9f4d29 100644 --- a/apps/basic/Makefile +++ b/apps/basic/Makefile @@ -9,10 +9,10 @@ SUBDIRS := SOURCES := $(addprefix ./, $(addsuffix .asm, $(FILES))) TARGETS := $(addprefix $(BUILDDIR)/, $(addsuffix .bin, $(FILES))) -TOPTARGETS := all clean size +TOPTARGETS := all clean $(TOPTARGETS): $(SUBDIRS) -all: $(BUILDDIR) $(TARGETS) size +all: $(BUILDDIR) $(TARGETS) clean: rm -rf $(BUILDDIR) @@ -20,21 +20,11 @@ clean: $(BUILDDIR): mkdir -p $(BUILDDIR) -$(BUILDDIR)/%.bin: ./%.asm +$(BUILDDIR)/%.bin: ./%.asm $(BUILDDIR)/memory.inc echo '>$<' $(ASM) $(ASMFLAGS) $< $@ -size: - @for file in $(TARGETS); do \ - if [ -f "$$file" ]; then \ - echo "$$file: $$(wc -c < "$$file") bytes"; \ - else \ - echo "$$file: Not built yet (run 'make')"; \ - fi \ - done - $(SUBDIRS): $(MAKE) -C $@ $(or $(MAKECMDGOALS),all) --no-print-directory .PHONY: $(TOPTARGETS) $(SUBDIRS) - diff --git a/memory.mk b/memory.mk index dd4a7a0..90bd7fd 100644 --- a/memory.mk +++ b/memory.mk @@ -17,4 +17,4 @@ BASIC_ROM_START := 0x0400 BASIC_ROM_SIZE := 0x2000 BIOS_RAM_START := 0xc000 -BASIC_RAM_START := 0xd000 +BASIC_RAM_START := 0xc800