-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
122 lines (97 loc) · 3.8 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#=============================================================================#
# Copyright 2020 Matthew D. Steele <mdsteele@alum.mit.edu> #
# #
# This file is part of Big2Small. #
# #
# Big2Small is free software: you can redistribute it and/or modify it under #
# the terms of the GNU General Public License as published by the Free #
# Software Foundation, either version 3 of the License, or (at your option) #
# any later version. #
# #
# Big2Small is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with Big2Small. If not, see <http://www.gnu.org/licenses/>. #
#=============================================================================#
SRCDIR = src
OUTDIR = out
BINDIR = $(OUTDIR)/bin
DATADIR = $(OUTDIR)/data
GENDIR = $(OUTDIR)/gen
OBJDIR = $(OUTDIR)/obj
ROMFILE = $(OUTDIR)/big2small.gb
SYMFILE = $(OUTDIR)/big2small.sym
AHI22BPP = $(BINDIR)/ahi22bpp
BG2MAP = $(BINDIR)/bg2map
SNG2ASM = $(BINDIR)/sng2asm
AHIFILES := $(shell find $(SRCDIR) -name '*.ahi')
ASMFILES := $(shell find $(SRCDIR) -name '*.asm')
BGFILES := $(shell find $(SRCDIR) -name '*.bg')
INCFILES := $(shell find $(SRCDIR) -name '*.inc')
SNGFILES := $(shell find $(SRCDIR) -name '*.sng')
BPPFILES := $(patsubst $(SRCDIR)/%.ahi,$(DATADIR)/%.2bpp,$(AHIFILES))
GENFILES := $(patsubst $(SRCDIR)/%.sng,$(GENDIR)/%.asm,$(SNGFILES))
MAPFILES := $(patsubst $(SRCDIR)/%.bg,$(DATADIR)/%.map,$(BGFILES))
OBJFILES := $(patsubst $(SRCDIR)/%.asm,$(OBJDIR)/%.o,$(ASMFILES)) \
$(patsubst $(GENDIR)/%.asm,$(GENDIR)/%.o,$(GENFILES))
#=============================================================================#
.PHONY: rom
rom: $(ROMFILE)
.PHONY: run
run: $(ROMFILE)
open -a SameBoy $<
.PHONY: test
test:
python3 tests/all.py
.PHONY: clean
clean:
rm -rf $(OUTDIR)
#=============================================================================#
define compile-c99
@echo "Compiling $<"
@mkdir -p $(@D)
@cc -Wall -o $@ $<
endef
$(AHI22BPP): build/ahi22bpp.c
$(compile-c99)
$(DATADIR)/%.2bpp: $(SRCDIR)/%.ahi $(AHI22BPP)
@echo "Converting $<"
@mkdir -p $(@D)
@$(AHI22BPP) < $< > $@
$(BG2MAP): build/bg2map.c
$(compile-c99)
$(DATADIR)/%.map: $(SRCDIR)/%.bg $(BG2MAP)
@echo "Converting $<"
@mkdir -p $(@D)
@$(BG2MAP) < $< > $@
$(SNG2ASM): build/sng2asm.c
$(compile-c99)
$(GENDIR)/%.asm: $(SRCDIR)/%.sng $(SNG2ASM)
@echo "Converting $<"
@mkdir -p $(@D)
@$(SNG2ASM) < $< > $@
.SECONDARY: $(GENFILES)
#=============================================================================#
$(ROMFILE): $(OBJFILES)
@echo "Linking $@"
@mkdir -p $(@D)
@rgblink --dmg --sym $(SYMFILE) -o $@ $^
@echo "Fixing $@"
@rgbfix -v -p 0 $@
define compile-asm
@echo "Compiling $<"
@mkdir -p $(@D)
@rgbasm -Wall -Werror --nop-after-halt -o $@ $<
endef
$(OBJDIR)/mapdata.o: $(SRCDIR)/mapdata.asm $(INCFILES) $(MAPFILES)
$(compile-asm)
$(OBJDIR)/tiledata.o: $(SRCDIR)/tiledata.asm $(INCFILES) $(BPPFILES)
$(compile-asm)
$(OBJDIR)/%.o: $(SRCDIR)/%.asm $(INCFILES)
$(compile-asm)
$(GENDIR)/%.o: $(GENDIR)/%.asm
$(compile-asm)
#=============================================================================#