ref: 6a21963799575fa8a88ed55cde5408ef67c92d63
parent: e1c3fee92651a5b3550974e9fbd152840e796654
author: yenatch <[email protected]>
date: Tue Sep 10 21:20:52 EDT 2013
scan source files for Makefile dependencies preprocessing should work with multiple object files now
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
PYTHON := python
.SUFFIXES: .asm .tx .o .gbc .png .2bpp .lz
+.SECONDEXPANSION:
TEXTFILES := $(shell find ./ -type f -name '*.asm')
TEXTQUEUE :=
@@ -10,6 +11,8 @@
LZ_GFX := $(shell find gfx/ -type f -name '*.lz')
TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp')
+$(shell $(foreach obj, $(OBJS), $(eval OBJ_$(obj:.o=) := $(shell $(PYTHON) scan_includes.py $(obj:.o=.asm)))))
+
all: baserom.gbc pokecrystal.gbc
cmp baserom.gbc pokecrystal.gbc
clean:
@@ -24,9 +27,10 @@
$(eval TEXTQUEUE := $(TEXTQUEUE) $<)
@rm -f $@
-$(OBJS): $(TEXTFILES:.asm=.tx) $(LZ_GFX) $(TWOBPP_GFX)
+$(OBJS): $$(patsubst %.o,%.tx,$$@) $$(patsubst %.asm,%.tx,$$(OBJ_$$(patsubst %.o,%,$$@)))
@echo "Preprocessing .asm to .tx..."
@$(PYTHON) prequeue.py $(TEXTQUEUE)
+ $(eval TEXTQUEUE := )
rgbasm -o $@ $(@:.o=.tx)
pokecrystal.gbc: $(OBJS)
@@ -52,4 +56,7 @@
$(PYTHON) extras/pokemontools/gfx.py png-to-lz $<
.png.2bpp:
$(PYTHON) extras/pokemontools/gfx.py png-to-lz $<
-
+%.2bpp:
+ @:
+%.1bpp:
+ @:
--- /dev/null
+++ b/scan_includes.py
@@ -1,0 +1,27 @@
+# coding: utf-8
+
+# Recursively scan an asm file for rgbasm INCLUDEs and INCBINs.
+# This is used to generate dependencies for each rgbasm object file.
+
+import sys
+
+def scan_for_includes(filename):
+ filenames = []
+ for line in open(filename, 'r').readlines():
+ if 'INCLUDE' in line or 'INCBIN' in line:
+ line = line.split(';')[0]
+ if 'INCLUDE' in line or 'INCBIN' in line:
+ filenames += [line.split('"')[1]]
+ return filenames
+
+def recursive_scan_for_includes(filename):
+ filenames = []
+ if '.asm' in filename or '.tx' in filename:
+ for include in scan_for_includes(filename):
+ filenames += [include] + recursive_scan_for_includes(include)
+ return filenames
+
+if len(sys.argv) > 1:
+ for arg in sys.argv[1:]:
+ sys.stdout.write(' '.join(recursive_scan_for_includes(arg)))
+