-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
98 lines (75 loc) · 3.25 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
all: earthbound
.SUFFIXES:
%: %,v
%: RCS/%,v
%: RCS/%
%: s.%
%: SCCS/s.%
SRCDIR = src/bankconfig
BUILDDIR = build
CA65FLAGS = -t none --cpu 65816 --bin-include-dir src --include-dir src --include-dir include --bin-include-dir $(BUILDDIR)
LD65FLAGS = -C snes.cfg
JPID = JP
USID = US
USPROTOID = US19950327
.PHONY: earthbound proto19950327 mother2 depsjp depsusa depsusaproto extract extractproto extractjp
earthbound: depsusa build/earthbound.sfc
proto19950327: depsusaproto build/earthbound-1995-03-27.sfc
mother2: depsjp build/mother2.sfc
ifeq ($(MAKECMDGOALS),mother2)
CA65FLAGS += -D JPN
include $(wildcard $(BUILDDIR)/$(JPID)/*.dep)
else ifeq ($(MAKECMDGOALS),proto19950327)
CA65FLAGS += -D USA -D PROTOTYPE19950327
include $(wildcard $(BUILDDIR)/$(USPROTOID)/*.dep)
else ifneq ($(if $(MAKECMDGOALS),$(filter all earthbound,$(MAKECMDGOALS)),itsthedefaulttarget),)
# The above ifneq condition will trigger if either
# - MAKECMDGOALS is empty (there is no specified make target, so build the default target), or
# - the target is all/earthbound
CA65FLAGS += -D USA
include $(wildcard $(BUILDDIR)/$(USID)/*.dep)
endif
# windows/posix mkdir differences, yay!
ifeq ($(shell echo "check_quotes"),"check_quotes")
mkdir = mkdir $(subst /,\,$(1)) > nul 2>&1 || (exit 0)
else
mkdir = mkdir -p $(1)
endif
JPSRCS = $(wildcard $(SRCDIR)/$(JPID)/*.asm)
JPOBJS = $(subst $(SRCDIR), $(BUILDDIR), $(patsubst %.asm, %.o, $(JPSRCS)))
USSRCS = $(wildcard $(SRCDIR)/$(USID)/*.asm)
USOBJS = $(subst $(SRCDIR), $(BUILDDIR), $(patsubst %.asm, %.o, $(USSRCS)))
USPROTOSRCS = $(wildcard $(SRCDIR)/$(USPROTOID)/*.asm)
USPROTOOBJS = $(subst $(SRCDIR), $(BUILDDIR), $(patsubst %.asm, %.o, $(USPROTOSRCS)))
$(BUILDDIR)/%.dep: $(SRCDIR)/%.asm
@$(call mkdir, $(@D))
ca65 $(CA65FLAGS) --listing "$(strip $(subst $(SRCDIR), $(BUILDDIR), $(patsubst %.dep,%.lst,$@)))" --create-dep "$(strip $(subst $(SRCDIR), $(BUILDDIR), $@))" -o "$(patsubst %.dep,%.o,$@)" "$<"
build/mother2.sfc: $(JPOBJS)
ld65 $(LD65FLAGS) --mapfile "$(patsubst %.sfc,%.map,$@)" -o "$@" $^
build/earthbound.sfc: $(USOBJS)
ld65 $(LD65FLAGS) --mapfile "$(patsubst %.sfc,%.map,$@)" -o "$@" $^
build/earthbound-1995-03-27.sfc: $(USPROTOOBJS)
ld65 $(LD65FLAGS) --mapfile "$(patsubst %.sfc,%.map,$@)" -o "$@" $^
build/mother2.dbg: $(JPOBJS)
ld65 $(LD65FLAGS) --dbgfile "$@" $^
build/earthbound.dbg: $(USOBJS)
ld65 $(LD65FLAGS) --dbgfile "$@" $^
build/earthbound-1995-03-27.dbg: $(USPROTOOBJS)
ld65 $(LD65FLAGS) --dbgfile "$@" $^
# ca65 requires all bin files to be present for generating .dep files, so make sure they're present first
depsjp: $(BUILDDIR)/main.spc700.bin $(subst $(SRCDIR), $(BUILDDIR), $(JPSRCS:.asm=.dep))
depsusa: $(BUILDDIR)/main.spc700.bin $(subst $(SRCDIR), $(BUILDDIR), $(USSRCS:.asm=.dep))
depsusaproto: $(BUILDDIR)/main.spc700.bin $(subst $(SRCDIR), $(BUILDDIR), $(USPROTOSRCS:.asm=.dep))
extract:
ebbinex "earthbound.yml" "donor.sfc"
extractproto:
ebbinex "earthbound-1995-03-27.yml" "donor-1995-03-27.sfc"
extractjp:
ebbinex "mother2.yml" "donorm2.sfc"
$(BUILDDIR)/%.o: $(SRCDIR)/%.asm
@$(call mkdir, $(@D))
ca65 $(CA65FLAGS) --listing "$(strip $(subst $(SRCDIR), $(BUILDDIR), $(patsubst %.o,%.lst,$@)))" -o "$@" "$<"
$(BUILDDIR)/%.spc700.bin: src/spc700/%.spc700.s
spcasm -f plain "$<" "$@"
%.bin: %.uncompressed
inhal -n $< $@