summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorSanqui <gsanky@gmail.com>2018-05-27 00:09:14 +0200
committerSanqui <gsanky@gmail.com>2018-05-27 00:11:32 +0200
commit775d9f7ef0f8436039567e9071cd39c405e998b5 (patch)
tree73799d68cdf822e41093bc123f3a29827e46c7be /Makefile
Initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile51
1 files changed, 51 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6b95aa7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,51 @@
+.PHONY: all compare clean text
+
+.SUFFIXES:
+.SUFFIXES: .asm .o .gbc .png
+.SECONDEXPANSION:
+
+ROMS := pokegold-spaceworld.gb
+BASEROM := baserom.gb
+OBJS := main.o wram.o
+
+# Link objects together to build a rom.
+all: $(ROMS) compare
+
+tools:
+ $(MAKE) -C tools/
+
+define DEP
+$1: $2 $$(shell tools/scan_includes $2)
+ rgbasm -E -o $$@ $$<
+endef
+
+ifeq (,$(filter clean tools,$(MAKECMDGOALS)))
+$(info $(shell $(MAKE) -C tools))
+
+$(foreach obj, $(OBJS), $(eval $(call DEP,$(obj),$(obj:.o=.asm))))
+
+endif
+
+$(ROMS): $(OBJS)
+ rgblink -n $(ROMS:.gb=.sym) -m $(ROMS:.gb=.map) -O $(BASEROM) -o $@ $^
+ rgbfix -f -v -k 01 -l 0x33 -m 0x03 -p 0 -r 3 -t "POKEMON2GOLD" $@
+
+compare: $(ROMS) $(BASEROM)
+ cmp $^
+
+# Remove files generated by the build process.
+clean:
+ rm -rf $(ROMS) $(OBJS) $(ROMS:.gbc=.sym) build/*
+ find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pcm' \) -exec rm {} +
+
+%.2bpp: %.png
+ rgbgfx -o $@ $<
+
+%.1bpp: %.png
+ rgbgfx -d1 -o $@ $<
+
+%.tilemap: %.png
+ rgbgfx -t $@ $<
+%.gbcpal: %.png
+ rgbgfx -p $@ $<
+