Skip to content

Commit 1b97672

Browse files
committed
Fix building with recent Make versions
Also note which version of RGBDS is required in the README
1 parent c90fdf9 commit 1b97672

File tree

4 files changed

+72
-65
lines changed

4 files changed

+72
-65
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
/bin/
22
/obj/
33
/res/
4-
/dep/
5-
quartet.gb
6-
.DS_Store

Makefile

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
ASFLAGS := -p 0xFF -Wall -Wextra -EhL -i src/
2+
ASFLAGS := -p 0xFF -Wall -Wextra -E -i src/
33
LDFLAGS := -d -t
44
FIXFLAGS:= -v
55

@@ -10,124 +10,132 @@ RGBFIX ?= $(RGBDS)rgbfix
1010
RGBGFX ?= $(RGBDS)rgbgfx
1111

1212

13-
BINDIR := bin
14-
OBJDIR := obj
15-
RESDIR := res
16-
DEPDIR := dep
17-
18-
1913
VPATH := src
2014

2115
SRCS := $(wildcard src/*.asm)
22-
OBJS := $(patsubst src/%.asm,$(OBJDIR)/%.o,$(SRCS))
23-
DEPS := $(patsubst src/%.asm,$(DEPDIR)/%.mk,$(SRCS))
16+
OBJS := $(patsubst src/%.asm,obj/%.o,$(SRCS))
17+
DEPS := $(patsubst src/%.asm,obj/%.mk,$(SRCS))
2418

2519
.SECONDEXPANSION:
2620

2721

28-
all: $(BINDIR)/quartet.gb
22+
all: bin/quartet.gb
2923
.PHONY: all
3024

31-
clean:
32-
rm -rf $(BINDIR) $(OBJDIR) $(RESDIR) $(DEPDIR)
25+
clean: tools/propack/Makefile
26+
rm -rf bin obj res
3327
make -C tools/propack clean
3428
.PHONY: clean
3529

3630
# We rely on `quartet.gb` being first, and thus being passed to `-O`
3731
# For some reason, RGBLINK outputs too many bytes?
38-
$(BINDIR)/quartet.gb $(BINDIR)/quartet.sym $(BINDIR)/quartet.map: quartet.gb $(OBJS)
32+
bin/quartet.gb bin/quartet.sym bin/quartet.map: quartet.gb $(OBJS)
33+
@mkdir -p $(@D)
34+
$(RGBLINK) $(LDFLAGS) -o bin/quartet_tmp.gb -n bin/quartet_tmp.sym -m bin/quartet.map -O $^
35+
dd bs=32768 count=1 if=bin/quartet_tmp.gb of=bin/quartet.gb
36+
$(RGBFIX) $(FIXFLAGS) bin/quartet.gb
37+
sed 's/ / Q_/' quartet.sym | cat bin/quartet_tmp.sym - > bin/quartet.sym
38+
rm -f bin/quartet_tmp.gb bin/quartet_tmp.sym
39+
40+
obj/%.mk: src/%.asm
3941
@mkdir -p $(@D)
40-
$(RGBLINK) $(LDFLAGS) -o $(BINDIR)/quartet_tmp.gb -n $(BINDIR)/quartet_tmp.sym -m $(BINDIR)/quartet.map -O $^
41-
dd bs=32768 count=1 if=$(BINDIR)/quartet_tmp.gb of=$(BINDIR)/quartet.gb
42-
$(RGBFIX) $(FIXFLAGS) $(BINDIR)/quartet.gb
43-
sed 's/ / Q_/' quartet.sym | cat $(BINDIR)/quartet_tmp.sym - > $(BINDIR)/quartet.sym
44-
rm -f $(BINDIR)/quartet_tmp.gb $(BINDIR)/quartet_tmp.sym
45-
46-
$(OBJDIR)/%.o $(DEPDIR)/%.mk: src/%.asm
47-
@mkdir -p $(OBJDIR)/$(*D) $(DEPDIR)/$(*D)
48-
$(RGBASM) $(ASFLAGS) -M $(DEPDIR)/$*.mk -MG -MP -MQ $(OBJDIR)/$*.o -MQ $(DEPDIR)/$*.mk -o $(OBJDIR)/$*.o $<
49-
50-
$(RESDIR)/syms.asm: tools/syms.sh quartet.sym
51-
@mkdir -p $(RESDIR)
42+
$(RGBASM) $(ASFLAGS) -M obj/$*.mk -MG -MP -MQ obj/$*.o -MQ obj/$*.mk -o obj/$*.o $<
43+
# DO NOT merge this with the rule above, otherwise Make will assume that the `.o` file is generated,
44+
# even when it isn't!
45+
# This causes weird issues that depend, among other things, on the version of Make.
46+
obj/%.o: obj/%.mk
47+
@touch $@
48+
res/syms.asm: tools/syms.sh quartet.sym
49+
@mkdir -p res
5250
$^ > $@
5351

5452
ifeq ($(filter clean,$(MAKECMDGOALS)),)
55-
-include $(DEPS)
53+
include $(DEPS)
5654
endif
5755

5856

5957
## ASSET PROCESSING
6058

6159

62-
$(RESDIR)/%.ofs.tilemap: tools/apply_ofs.py $(RESDIR)/$$(basename $$*).tilemap
60+
res/%.ofs.tilemap: tools/apply_ofs.py res/$$(basename $$*).tilemap
6361
@mkdir -p $(@D)
6462
$^ $@
6563

6664
%.uniq.2bpp %.uniq.1bpp %.uniq.tilemap: GFXFLAGS += -u
6765
%.vert.2bpp %.vert.1bpp %.vert.tilemap: GFXFLAGS += -h
68-
$(RESDIR)/%.2bpp $(RESDIR)/%.tilemap: $(RESDIR)/%.png
69-
@mkdir -p $(RESDIR)/$(@*)
70-
$(RGBGFX) $(GFXFLAGS) -d 2 -o $(RESDIR)/$*.2bpp -t $(RESDIR)/$*.tilemap $<
71-
$(RESDIR)/%.1bpp $(RESDIR)/%.tilemap: $(RESDIR)/%.png
72-
@mkdir -p $(RESDIR)/$(@*)
73-
$(RGBGFX) $(GFXFLAGS) -d 1 -o $(RESDIR)/$*.1bpp -t $(RESDIR)/$*.tilemap $<
74-
75-
76-
$(RESDIR)/%.bin $(RESDIR)/%.inc: $(RESDIR)/%.asm
77-
$(RGBASM) $(ASFLAGS) -o $(RESDIR)/$*.o $< > $(RESDIR)/$*.inc
78-
$(RGBLINK) $(LDFLAGS) -x -o $(RESDIR)/$*.bin $(RESDIR)/$*.o
66+
res/%.2bpp res/%.tilemap: res/%.png
67+
@mkdir -p res/$(@*)
68+
$(RGBGFX) $(GFXFLAGS) -d 2 -o res/$*.2bpp -t res/$*.tilemap $<
69+
res/%.1bpp res/%.tilemap: res/%.png
70+
@mkdir -p res/$(@*)
71+
$(RGBGFX) $(GFXFLAGS) -d 1 -o res/$*.1bpp -t res/$*.tilemap $<
72+
.PRECIOUS: %.2bpp %.1bpp %.tilemap
73+
74+
75+
res/%.bin res/%.inc: res/%.asm
76+
$(RGBASM) $(ASFLAGS) -o res/$*.o $< > res/$*.inc
77+
$(RGBLINK) $(LDFLAGS) -x -o res/$*.bin res/$*.o
7978
# Additional INCBIN'd dep
80-
$(RESDIR)/winx.bin $(RESDIR)/winx.inc: $(RESDIR)/gb_light.vert.1bpp
81-
$(RESDIR)/sgb_border.bin: $(RESDIR)/sgb_border_tiles.4bpp $(RESDIR)/screen_cover.pal $(RESDIR)/screen_cover.2bpp $(RESDIR)/screen_cover.tilemap $(RESDIR)/screen_cover.2bpp.size
82-
$(RESDIR)/sgb_border.bin: ASFLAGS += -DPAL="`xxd -p -c 48 $(RESDIR)/screen_cover.pal`"
83-
$(RESDIR)/sgb_border.bin: ASFLAGS += -DCOVER_MAP0="`xxd -p -l 126 -c 126 $(RESDIR)/screen_cover.tilemap`"
84-
$(RESDIR)/sgb_border.bin: ASFLAGS += -DCOVER_MAP1="`xxd -p -l 126 -c 126 -s 126 $(RESDIR)/screen_cover.tilemap`"
85-
$(RESDIR)/sgb_border.bin: ASFLAGS += -DCOVER_MAP2="`xxd -p -l 126 -c 126 -s 252 $(RESDIR)/screen_cover.tilemap`"
86-
$(RESDIR)/sgb_border.bin: ASFLAGS += -DCOVER_MAP3="`xxd -p -l 126 -c 126 -s 378 $(RESDIR)/screen_cover.tilemap`"
87-
$(RESDIR)/sgb_border.bin: ASFLAGS += -DCOVER_MAP4="`xxd -p -l 126 -c 126 -s 504 $(RESDIR)/screen_cover.tilemap`"
88-
$(RESDIR)/sgb_border.bin: ASFLAGS += -DCOVER_MAP5="`xxd -p -l 126 -c 126 -s 630 $(RESDIR)/screen_cover.tilemap`"
89-
$(RESDIR)/mus_data.bin: $(RESDIR)/musicdata.bin
79+
res/winx.bin res/winx.inc: res/gb_light.vert.1bpp
80+
res/sgb_border.bin: res/sgb_border_tiles.4bpp res/screen_cover.pal res/screen_cover.2bpp res/screen_cover.tilemap res/screen_cover.2bpp.size
81+
res/sgb_border.bin: ASFLAGS += -DPAL="`xxd -p -c 48 res/screen_cover.pal`"
82+
res/sgb_border.bin: ASFLAGS += -DCOVER_MAP0="`xxd -p -l 126 -c 126 res/screen_cover.tilemap`"
83+
res/sgb_border.bin: ASFLAGS += -DCOVER_MAP1="`xxd -p -l 126 -c 126 -s 126 res/screen_cover.tilemap`"
84+
res/sgb_border.bin: ASFLAGS += -DCOVER_MAP2="`xxd -p -l 126 -c 126 -s 252 res/screen_cover.tilemap`"
85+
res/sgb_border.bin: ASFLAGS += -DCOVER_MAP3="`xxd -p -l 126 -c 126 -s 378 res/screen_cover.tilemap`"
86+
res/sgb_border.bin: ASFLAGS += -DCOVER_MAP4="`xxd -p -l 126 -c 126 -s 504 res/screen_cover.tilemap`"
87+
res/sgb_border.bin: ASFLAGS += -DCOVER_MAP5="`xxd -p -l 126 -c 126 -s 630 res/screen_cover.tilemap`"
88+
res/mus_data.bin: res/musicdata.bin
9089
# 0x700 = 1792
91-
$(RESDIR)/mus_data.bin: ASFLAGS += -DDATA="`xxd -p -c 256 -l 256 -s 1792 src/$(RESDIR)/musicdata.bin`"
92-
$(RESDIR)/sou_trn.bin: $(RESDIR)/sou_trn_data.bin
90+
res/mus_data.bin: ASFLAGS += -DDATA="`xxd -p -c 256 -l 256 -s 1792 src/res/musicdata.bin`"
91+
res/sou_trn.bin: res/sou_trn_data.bin
9392

9493

9594
tools/propack/rnc64: tools/propack/main.c
9695
make -C $(@D) rnc64
9796

9897
# Dalton's decruncher skips the 18-byte header (not useful at runtime)
99-
$(RESDIR)/%.rnc: $(RESDIR)/% tools/propack/rnc64
98+
res/%.rnc: res/% tools/propack/rnc64
10099
tools/propack/rnc64 p $< $@.tmp -m 2 && dd if=$@.tmp of=$@ bs=1 skip=18 && rm $@.tmp
101100

102101

103102
SUPERFAMICONV := tools/superfamiconv/bin/superfamiconv
104103

105104
# TODO: how to reuse its Makefile's dependencies?
106105
# This is currently OK, but only for our purposes...
107-
$(SUPERFAMICONV):
106+
$(SUPERFAMICONV): tools/superfamiconv/Makefile
108107
make -C tools/superfamiconv bin/superfamiconv
109108

110-
$(RESDIR)/sgb_border_tiles.4bpp: $(RESDIR)/sgb_border_tiles.png $(SUPERFAMICONV)
109+
res/sgb_border_tiles.4bpp: res/sgb_border_tiles.png $(SUPERFAMICONV)
111110
$(SUPERFAMICONV) tiles -M snes -W 8 -H 8 -R -B 4 -i $< -d $@
112111

113-
$(RESDIR)/screen_cover.pal: $(RESDIR)/screen_cover.png $(SUPERFAMICONV)
112+
res/screen_cover.pal: res/screen_cover.png $(SUPERFAMICONV)
114113
$(SUPERFAMICONV) palette -M snes -W 8 -H 8 -P 3 -C 4 -0 '#ffffff' -i $< -d $@
115-
$(RESDIR)/screen_cover.2bpp: $(RESDIR)/screen_cover.png $(RESDIR)/screen_cover.pal $(SUPERFAMICONV)
116-
$(SUPERFAMICONV) tiles -M snes -W 8 -H 8 -B 2 -i $< -p $(RESDIR)/screen_cover.pal -d $@
117-
$(RESDIR)/screen_cover.tilemap: $(RESDIR)/screen_cover.png $(RESDIR)/screen_cover.2bpp $(RESDIR)/screen_cover.pal $(SUPERFAMICONV)
118-
$(SUPERFAMICONV) map -M snes -W 8 -H 8 -B 2 -i $< -t $(RESDIR)/screen_cover.2bpp -p $(RESDIR)/screen_cover.pal -d $@
114+
res/screen_cover.2bpp: res/screen_cover.png res/screen_cover.pal $(SUPERFAMICONV)
115+
$(SUPERFAMICONV) tiles -M snes -W 8 -H 8 -B 2 -i $< -p res/screen_cover.pal -d $@
116+
res/screen_cover.tilemap: res/screen_cover.png res/screen_cover.2bpp res/screen_cover.pal $(SUPERFAMICONV)
117+
$(SUPERFAMICONV) map -M snes -W 8 -H 8 -B 2 -i $< -t res/screen_cover.2bpp -p res/screen_cover.pal -d $@
119118

120119

121120
# Useful to know how large a file will be when decompressed
122-
$(RESDIR)/%.size: $(RESDIR)/%
121+
res/%.size: res/%
123122
printf 'SIZE = %u' $$(wc -c $< | cut -d ' ' -f 1) > $@
124123

125124

126125
# The first row is just some window tiles, they're not part of the image proper
127-
$(RESDIR)/draft.%.tilemap: $(RESDIR)/draft.uniq.%.ofs.tilemap
126+
res/draft.%.tilemap: res/draft.uniq.%.ofs.tilemap
128127
dd if=$< of=$@ bs=1 skip=20
129-
$(RESDIR)/gfx.%.bin: $(RESDIR)/console_tiles.vert.2bpp $(RESDIR)/light_tiles.vert.2bpp $(RESDIR)/font.vert.2bpp $(RESDIR)/draft.uniq.2bpp $(RESDIR)/palettes.bin $(RESDIR)/draft.%.tilemap
128+
res/gfx.%.bin: res/console_tiles.vert.2bpp res/light_tiles.vert.2bpp res/font.vert.2bpp res/draft.uniq.2bpp res/palettes.bin res/draft.%.tilemap
130129
cat $^ > $@
131130

132-
$(RESDIR)/data.bin: $(RESDIR)/text.bin $(RESDIR)/winx.bin
131+
res/data.bin: res/text.bin res/winx.bin
133132
cat $^ > $@
133+
134+
# By default, cloning the repo does not init submodules; if that happens, warn the user.
135+
# Note that the real paths aren't used!
136+
# Since RGBASM fails to find the files, it outputs the raw paths, not the actual ones.
137+
hardware.inc/hardware.inc tools/superfamiconv/Makefile tools/propack/Makefile:
138+
@echo '$@ is not present; have you initialized submodules?'
139+
@echo 'Run `git submodule update --init`, then `make clean`, then `make` again.'
140+
@echo 'Tip: to avoid this, use `git clone --recursive` next time!'
141+
@exit 1

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Careful when cloning that this repo uses `hardware.inc`, `superfamiconv` and `rn
1010
You need `quartet.gb` at the root of the repo (not provided) and RGBDS installed.
1111
Be careful that \~3 different revisions of *Quartet* were released; SHA256 of the ROM we used: `dcf0199e5fbc40cdf06131c376f821f275c3d518608de04ce1cfbe4d47c472aa`.
1212

13+
[RGBDS v0.4.2](https://github.com/gbdev/rgbds/releases/v0.4.2) must be used.
14+
1315
Then run `make`.
1416

1517
## Notes

quartet.gb

32 KB
Binary file not shown.

0 commit comments

Comments
 (0)