mirror of
https://github.com/pret/pokeyellow.git
synced 2025-01-29 22:52:25 +00:00
64da1f5d6b
Previously this wasn't working, but now the Makefile uses pokegold's technique for running scan_includes. It also enables and fixes some rgbds warnings ("Non-local labels without a colon are deprecated").
137 lines
3.4 KiB
Makefile
137 lines
3.4 KiB
Makefile
roms := pokered.gbc pokeblue.gbc
|
|
|
|
rom_obj := \
|
|
audio.o \
|
|
home.o \
|
|
main.o \
|
|
maps.o \
|
|
text.o \
|
|
wram.o \
|
|
gfx/pics.o \
|
|
gfx/sprites.o \
|
|
gfx/tilesets.o
|
|
|
|
pokered_obj := $(rom_obj:.o=_red.o)
|
|
pokeblue_obj := $(rom_obj:.o=_blue.o)
|
|
|
|
|
|
### Build tools
|
|
|
|
MD5 := md5sum -c
|
|
|
|
RGBDS ?=
|
|
RGBASM ?= $(RGBDS)rgbasm
|
|
RGBFIX ?= $(RGBDS)rgbfix
|
|
RGBGFX ?= $(RGBDS)rgbgfx
|
|
RGBLINK ?= $(RGBDS)rgblink
|
|
|
|
|
|
### Build targets
|
|
|
|
.SUFFIXES:
|
|
.SECONDEXPANSION:
|
|
.PRECIOUS:
|
|
.SECONDARY:
|
|
.PHONY: all red blue clean tidy compare tools
|
|
|
|
all: $(roms)
|
|
red: pokered.gbc
|
|
blue: pokeblue.gbc
|
|
|
|
# For contributors to make sure a change didn't affect the contents of the rom.
|
|
compare: $(roms)
|
|
@$(MD5) roms.md5
|
|
|
|
clean:
|
|
rm -f $(roms) $(pokered_obj) $(pokeblue_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym)
|
|
find gfx \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -delete
|
|
$(MAKE) clean -C tools/
|
|
|
|
tidy:
|
|
rm -f $(roms) $(pokered_obj) $(pokeblue_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym)
|
|
$(MAKE) clean -C tools/
|
|
|
|
tools:
|
|
$(MAKE) -C tools/
|
|
|
|
|
|
RGBASMFLAGS = -h -Weverything
|
|
# Create a sym/map for debug purposes if `make` run with `DEBUG=1`
|
|
ifeq ($(DEBUG),1)
|
|
RGBASMFLAGS += -E
|
|
endif
|
|
|
|
$(pokered_obj): RGBASMFLAGS += -D _RED
|
|
$(pokeblue_obj): RGBASMFLAGS += -D _BLUE
|
|
|
|
# The dep rules have to be explicit or else missing files won't be reported.
|
|
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
|
|
# It doesn't look like $(shell) can be deferred so there might not be a better way.
|
|
define DEP
|
|
$1: $2 $$(shell tools/scan_includes $2)
|
|
$$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$<
|
|
endef
|
|
|
|
# Build tools when building the rom.
|
|
# This has to happen before the rules are processed, since that's when scan_includes is run.
|
|
ifeq (,$(filter clean tools,$(MAKECMDGOALS)))
|
|
|
|
$(info $(shell $(MAKE) -C tools))
|
|
|
|
# Dependencies for objects (drop _red and _blue from asm file basenames)
|
|
$(foreach obj, $(pokered_obj), $(eval $(call DEP,$(obj),$(obj:_red.o=.asm))))
|
|
$(foreach obj, $(pokeblue_obj), $(eval $(call DEP,$(obj),$(obj:_blue.o=.asm))))
|
|
|
|
endif
|
|
|
|
|
|
%.asm: ;
|
|
|
|
pokered_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON RED"
|
|
pokeblue_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON BLUE"
|
|
|
|
%.gbc: $$(%_obj) layout.link
|
|
$(RGBLINK) -d -m $*.map -n $*.sym -l layout.link -o $@ $(filter %.o,$^)
|
|
$(RGBFIX) $($*_opt) $@
|
|
|
|
|
|
### Misc file-specific graphics rules
|
|
|
|
gfx/battle/attack_anim_1.2bpp: tools/gfx += --trim-whitespace
|
|
gfx/battle/attack_anim_2.2bpp: tools/gfx += --trim-whitespace
|
|
|
|
gfx/intro_credits/blue_jigglypuff_1.2bpp: $(RGBGFX) += -h
|
|
gfx/intro_credits/blue_jigglypuff_2.2bpp: $(RGBGFX) += -h
|
|
gfx/intro_credits/blue_jigglypuff_3.2bpp: $(RGBGFX) += -h
|
|
gfx/intro_credits/red_nidorino_1.2bpp: $(RGBGFX) += -h
|
|
gfx/intro_credits/red_nidorino_2.2bpp: $(RGBGFX) += -h
|
|
gfx/intro_credits/red_nidorino_3.2bpp: $(RGBGFX) += -h
|
|
|
|
gfx/intro_credits/the_end.2bpp: tools/gfx += --interleave --png=$<
|
|
|
|
gfx/slots/red_slots_1.2bpp: tools/gfx += --trim-whitespace
|
|
gfx/slots/blue_slots_1.2bpp: tools/gfx += --trim-whitespace
|
|
|
|
gfx/tilesets/%.2bpp: tools/gfx += --trim-whitespace
|
|
gfx/tilesets/reds_house.2bpp: tools/gfx += --preserve=0x48
|
|
|
|
gfx/trade/game_boy.2bpp: tools/gfx += --remove-duplicates
|
|
|
|
|
|
### Catch-all graphics rules
|
|
|
|
%.png: ;
|
|
|
|
%.2bpp: %.png
|
|
$(RGBGFX) $(rgbgfx) -o $@ $<
|
|
$(if $(tools/gfx),\
|
|
tools/gfx $(tools/gfx) -o $@ $@)
|
|
|
|
%.1bpp: %.png
|
|
$(RGBGFX) -d1 $(rgbgfx) -o $@ $<
|
|
$(if $(tools/gfx),\
|
|
tools/gfx $(tools/gfx) -d1 -o $@ $@)
|
|
|
|
%.pic: %.2bpp
|
|
tools/pkmncompress $< $@
|