From 8396935a07863484d1ce8a620511fbe645980fde Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 11 Jul 2014 11:02:04 -0700 Subject: Comment the makefile. --- Makefile | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ec1ca455..7b297059 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,22 @@ +# If your default python is 3, you may want to change this to python27. PYTHON := python + +# md5sum -c is used to compare rom hashes. The options may vary across platforms. MD5 := md5sum -c --quiet +# Clear the default suffixes. .SUFFIXES: .SUFFIXES: .asm .tx .o .gbc + .PHONY: all clean red blue yellow compare -.PRECIOUS: %.2bpp + +# Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: +# Suppress annoying intermediate file deletion messages. +.PRECIOUS: %.2bpp + +# Filepath shortcuts to avoid overly long recipes. poketools := extras/pokemontools gfx := $(PYTHON) $(poketools)/gfx.py pic := $(PYTHON) $(poketools)/pic.py @@ -16,6 +26,8 @@ pre := $(PYTHON) prequeue.py versions := red blue yellow +# Collect file dependencies for objects in red/, blue/ and yellow/. +# These aren't provided by rgbds by default, so we have to look for file includes ourselves. $(foreach ver, $(versions), \ $(eval $(ver)_asm := $(shell find $(ver) -iname '*.asm')) \ $(eval $(ver)_obj := $($(ver)_asm:.asm=.o)) \ @@ -26,6 +38,7 @@ $(foreach obj, $(all_obj), \ ) +# Build Red/Blue. Yellow is WIP. roms := pokered.gbc pokeblue.gbc all: $(roms) @@ -40,22 +53,34 @@ clean: find . \( -iname '*.tx' -o -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + +# Image files are added to a queue to reduce build time. They're converted when building parent objects. +%.2bpp: %.png ; $(eval 2bppq += $<) @rm -f $@ +%.1bpp: %.png ; $(eval 1bppq += $<) @rm -f $@ +%.pic: %.2bpp ; $(eval picq += $<) @rm -f $@ + +# Source files are not fed directly into rgbasm. +# A python preprocessor runs over them first, replacing ascii strings with correct character codes. +# It spits out the new file with extension .tx. +# The text preprocessor also uses a queue. %.asm: ; -%.tx: %.asm - $(eval txq += $<) - @rm -f $@ +%.tx: %.asm ; $(eval txq += $<) @rm -f $@ $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) + @# The queue payloads are here. + @# These are made silent since there may be hundreds of targets. @$(pre) $(txq); $(eval txq :=) @$(gfx) 2bpp $(2bppq); $(eval 2bppq :=) @$(gfx) 1bpp $(1bppq); $(eval 1bppq :=) @$(pic) compress $(picq); $(eval picq :=) + @# rgbasm -h for manual halt-nops. rgbasm -h -o $@ $*.tx +# Link objects together to build a rom. +# Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. link = rgblink -n $*.sym -m $*.map -dmg_opt := -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -cgb_opt := -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 +dmg_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 +cgb_opt = -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 pokered.gbc: $(red_obj) $(link) -o $@ $^ @@ -68,14 +93,3 @@ pokeblue.gbc: $(blue_obj) pokeyellow.gbc: $(yellow_obj) $(link) -o $@ $^ rgbfix $(cgb_opt) -t "POKEMON YELLOW" $@ - - -%.2bpp: %.png - $(eval 2bppq += $<) - @rm -f $@ -%.1bpp: %.png - $(eval 1bppq += $<) - @rm -f $@ -%.pic: %.2bpp - $(eval picq += $<) - @rm -f $@ -- cgit v1.3.1-sl0p From 8f7135aa693f8606aa90aa1d4f099ee965c5fe84 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 11 Jul 2014 11:50:02 -0700 Subject: Reorganize makefile targets for clarity. --- Makefile | 62 +++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 25 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 7b297059..12e23297 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,39 @@ +# Build Red/Blue. Yellow is WIP. +roms := pokered.gbc pokeblue.gbc + + +.PHONY: all clean red blue yellow compare + +all: $(roms) +red: pokered.gbc +blue: pokeblue.gbc +yellow: pokeyellow.gbc + +versions := red blue yellow + + +# Header options for rgbfix. +dmg_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 +cgb_opt = -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 + +red_opt = $(dmg_opt) -t "POKEMON RED" +blue_opt = $(dmg_opt) -t "POKEMON BLUE" +yellow_opt = $(cgb_opt) -t "POKEMON YELLOW" + + + # If your default python is 3, you may want to change this to python27. PYTHON := python # md5sum -c is used to compare rom hashes. The options may vary across platforms. -MD5 := md5sum -c --quiet +MD5 := md5sum -c --quiet +compare: + @$(MD5) roms.md5 # Clear the default suffixes. .SUFFIXES: .SUFFIXES: .asm .tx .o .gbc -.PHONY: all clean red blue yellow compare - # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: @@ -24,7 +48,6 @@ includes := $(PYTHON) $(poketools)/scan_includes.py pre := $(PYTHON) prequeue.py -versions := red blue yellow # Collect file dependencies for objects in red/, blue/ and yellow/. # These aren't provided by rgbds by default, so we have to look for file includes ourselves. @@ -38,21 +61,6 @@ $(foreach obj, $(all_obj), \ ) -# Build Red/Blue. Yellow is WIP. -roms := pokered.gbc pokeblue.gbc - -all: $(roms) -red: pokered.gbc -blue: pokeblue.gbc -yellow: pokeyellow.gbc - -compare: - @$(MD5) roms.md5 -clean: - rm -f $(roms) $(all_obj) - find . \( -iname '*.tx' -o -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + - - # Image files are added to a queue to reduce build time. They're converted when building parent objects. %.2bpp: %.png ; $(eval 2bppq += $<) @rm -f $@ %.1bpp: %.png ; $(eval 1bppq += $<) @rm -f $@ @@ -77,19 +85,23 @@ $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) # Link objects together to build a rom. + # Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. -link = rgblink -n $*.sym -m $*.map -dmg_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -cgb_opt = -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 +link = rgblink -n $*.sym -m $*.map pokered.gbc: $(red_obj) $(link) -o $@ $^ - rgbfix $(dmg_opt) -t "POKEMON RED" $@ + rgbfix $(red_opt) $@ pokeblue.gbc: $(blue_obj) $(link) -o $@ $^ - rgbfix $(dmg_opt) -t "POKEMON BLUE" $@ + rgbfix $(blue_opt) $@ pokeyellow.gbc: $(yellow_obj) $(link) -o $@ $^ - rgbfix $(cgb_opt) -t "POKEMON YELLOW" $@ + rgbfix $(yellow_opt) $@ + + +clean: + rm -f $(roms) $(all_obj) + find . \( -iname '*.tx' -o -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + -- cgit v1.3.1-sl0p From 9ab6327361190b04b27a2ada2a83210e1cb963b5 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 11 Jul 2014 12:01:05 -0700 Subject: Remove inline comments in an object recipe. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 12e23297..0d8db6bd 100644 --- a/Makefile +++ b/Makefile @@ -73,14 +73,14 @@ $(foreach obj, $(all_obj), \ %.asm: ; %.tx: %.asm ; $(eval txq += $<) @rm -f $@ +# Assemble source files into objects. +# Queue payloads are here. These are made silent since there may be hundreds of targets. +# Use rgbasm -h to use halts without nops. $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) - @# The queue payloads are here. - @# These are made silent since there may be hundreds of targets. @$(pre) $(txq); $(eval txq :=) @$(gfx) 2bpp $(2bppq); $(eval 2bppq :=) @$(gfx) 1bpp $(1bppq); $(eval 1bppq :=) @$(pic) compress $(picq); $(eval picq :=) - @# rgbasm -h for manual halt-nops. rgbasm -h -o $@ $*.tx -- cgit v1.3.1-sl0p From dbef0efa6c44245907bea443fdee58c937ee54c7 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 11 Jul 2014 12:14:39 -0700 Subject: Add image suffixes to the makefile. Explicitly define png dependencies (none). This keeps make from looking for nonexistent dependencies with extensions like ".png.o". This doesn't make it go any faster, but it at least makes debug easier. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0d8db6bd..b61c0502 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ compare: # Clear the default suffixes. .SUFFIXES: -.SUFFIXES: .asm .tx .o .gbc +.SUFFIXES: .asm .tx .o .gbc .png .2bpp .1bpp .pic # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: @@ -62,6 +62,7 @@ $(foreach obj, $(all_obj), \ # Image files are added to a queue to reduce build time. They're converted when building parent objects. +%.png: ; %.2bpp: %.png ; $(eval 2bppq += $<) @rm -f $@ %.1bpp: %.png ; $(eval 1bppq += $<) @rm -f $@ %.pic: %.2bpp ; $(eval picq += $<) @rm -f $@ -- cgit v1.3.1-sl0p From 4ad367ba98b15a8b03d25963cd7b9a8125d2285f Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 13 Jul 2014 20:42:46 -0700 Subject: Combine poke%.gbc build targets into a generalized one. Now only one target is needed for all versions. $$* also works instead of %, but in a pattern rule % is probably clearer. --- Makefile | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b61c0502..37a9ea76 100644 --- a/Makefile +++ b/Makefile @@ -90,17 +90,9 @@ $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) # Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. link = rgblink -n $*.sym -m $*.map -pokered.gbc: $(red_obj) +poke%.gbc: $$(%_obj) $(link) -o $@ $^ - rgbfix $(red_opt) $@ - -pokeblue.gbc: $(blue_obj) - $(link) -o $@ $^ - rgbfix $(blue_opt) $@ - -pokeyellow.gbc: $(yellow_obj) - $(link) -o $@ $^ - rgbfix $(yellow_opt) $@ + rgbfix $($*_opt) $@ clean: -- cgit v1.3.1-sl0p From 8dd46620bc7e17c4c582a391fb95c9e29ef58576 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 16 Jul 2014 15:28:46 -0700 Subject: Add a comment to the "compare" target. --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 37a9ea76..e3616361 100644 --- a/Makefile +++ b/Makefile @@ -27,9 +27,15 @@ PYTHON := python # md5sum -c is used to compare rom hashes. The options may vary across platforms. MD5 := md5sum -c --quiet + + +# The compare target is a shortcut to check that the build matches the original roms exactly. +# This is for contributors to make sure a change didn't affect the contents of the rom. +# More thorough comparison can be made by diffing the output of hexdump -C against both roms. compare: @$(MD5) roms.md5 + # Clear the default suffixes. .SUFFIXES: .SUFFIXES: .asm .tx .o .gbc .png .2bpp .1bpp .pic -- cgit v1.3.1-sl0p From f1667eb6b533eafbb5121ac605401df69960f6df Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 19 Sep 2014 13:09:37 -0700 Subject: Fix the symfile and mapfile filenames. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e3616361..20e86bb2 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,7 @@ $(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep)) # Link objects together to build a rom. # Make a symfile for debugging. rgblink will segfault if a mapfile isn't made too. -link = rgblink -n $*.sym -m $*.map +link = rgblink -n poke$*.sym -m poke$*.map poke%.gbc: $$(%_obj) $(link) -o $@ $^ -- cgit v1.3.1-sl0p