summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authormid-kid <esteve.varela@gmail.com>2020-09-09 23:57:39 +0200
committermid-kid <esteve.varela@gmail.com>2020-09-09 23:58:51 +0200
commitbf5d9d07f67b2f46450adae5646cb670d7b6e70a (patch)
tree767509bc46e73053b9b623b9ac41f6717ef78541 /Makefile
parentb248d00f396d576074070e836c967ad814519bfb (diff)
Set up initial structure
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile48
1 files changed, 48 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a5c11e8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,48 @@
+name := picross
+baserom := DMGAKVJ0.1
+
+dir_source := source
+dir_build := build
+dir_assets := assets
+dir_tools := tools
+
+RGBASM := rgbasm
+RGBGFX := rgbgfx
+RGBLINK := rgblink
+RGBFIX := rgbfix
+
+RGBASMFLAGS := -p 0xff -L
+RGBLINKFLAGS := -p 0xff -d -t
+RGBFIXFLAGS := -p 0xff -c -m 0x1b -r 0x03 -k "01" -i "AKVJ" -t "POKEPICROSS"
+
+rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
+objects := $(patsubst $(dir_source)/%.asm, $(dir_build)/%.o, $(call rwildcard, $(dir_source)/, *.asm))
+objects += $(dir_build)/shim.o
+
+.SECONDEXPANSION:
+
+.PHONY: all
+all: $(name).gbc
+ cmp $(name).gbc $(baserom)
+
+.PHONY: clean
+clean:
+ rm -rf $(name).gbc $(name).sym $(name).map $(dir_build)
+
+$(name).gbc: layout.link $(objects) | $(baserom)
+ $(RGBLINK) $(RGBLINKFLAGS) -O $(baserom) -l $< -n $(@:.gbc=.sym) -m $(@:.gbc=.map) -o $@ $(filter-out $<, $^)
+ $(RGBFIX) $(RGBFIXFLAGS) -v $@
+
+$(dir_build)/shim.asm: shim.sym
+ $(dir_tools)/makeshim.py $< > $@
+
+$(dir_build)/%.o: $(dir_build)/%.asm | $$(dir $$@)
+ $(RGBASM) $(RGBASMFLAGS) -i $(dir_build)/ -i $(dir_source)/ -M $(@:.o=.d) -o $@ $<
+$(dir_build)/%.o: $(dir_source)/%.asm | $$(dir $$@)
+ $(RGBASM) $(RGBASMFLAGS) -i $(dir_build)/ -i $(dir_source)/ -M $(@:.o=.d) -o $@ $<
+
+.PRECIOUS: %/
+%/:
+ mkdir -p $@
+
+-include $(patsubst %.o, %.d, $(objects))