better makefile

This commit is contained in:
Dario48 2026-05-23 17:16:15 +02:00
commit cbc088b049

View file

@ -2,28 +2,31 @@ cl65 ?= cl65
.PHONY: build debug clean
build: smb.nes
build: bin/smb.nes
debug: OBJ_DEBUG_ARGS = --create-dep obj/nes/smb.d -v -g
debug: ROM_DEBUG_ARGS = -Wl --dbgfile,smb.nes.dbg
debug: build
obj/nes/smbdishl.o: src/smbdishl.s src/smb_chr.chr
obj/nes/smbdishl.o: src/smbdishl.s src/smb_chr.chr obj/nes/
$(cl65) -t none -c $(OBJ_DEBUG_ARGS) --include-dir src -o $@ $<
smb.nes smb.map: obj/nes/smbdishl.o src/nes.cfg
$(cl65) -t none --mapfile smb.map $(ROM_DEBUG_ARGS) -o smb.nes -C src/nes.cfg $<
bin/smb.nes bin/smb.map: obj/nes/smbdishl.o src/nes.cfg bin/
$(cl65) -t none --mapfile bin/smb.map $(ROM_DEBUG_ARGS) -o bin/smb.nes -C src/nes.cfg $<
src/smb_chr.chr:
if [ -s chr/smb_chr.chr ]; then \
if [ -s src/smb_chr.chr ]; then \
cmp -s $@ chr/smb_chr.chr || cp chr/smb_chr.chr $@ \
src/smb_chr.chr: chr/smb_chr.chr
if [ -s $< ]; then \
if [ -s $@ ]; then \
cmp -s $@ $< || cp $< $@; \
else \
cp chr/smb_chr.chr \
fi \
cp $< $@; \
fi; \
else \
[ -s src/smb_chr.chr ] || $(error missing chr)\
[ -s $@ ] || { echo "missing chr" >&2; exit 1; };\
fi
obj/nes/ bin/:
mkdir -p $@
clean:
rm -f smb.nes.dbg smb.map smb.nes smb.nes.ndx obj/nes/smbdishl.o obj/nes/smb.d
rm -f smb.nes.dbg bin/ smb.nes.ndx obj/