-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (52 loc) · 2.11 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
#
# A Makefile that compiles all .c in "source" and "words" subdirectories
# and all .s files in the "asm" subdirectory and places the output in
# an "objects" subdirectory
#
# If you move this project you can change the directory
# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
GBDK_HOME = C:/GBDK/
LCC = $(GBDK_HOME)bin/lcc
# You can set flags for LCC here
LCCFLAGS = -Wall -Wl-ya1 -Wl-yoA -Wl-yt0x10 -Wm-yn"WORDLEBOY" -Iinclude -autobank
# -Wl-ya1: 1 external RAM bank
# -Wl-yoA: Automatic number of ROM banks
# -Wl-yt0x10: Cartridge mapper 0x10 (MBC3 with persistent RAM and RTC)
# -Wm-yn"WORDLEBOY": Set title in header to WORDLEBOY
# -autobank: in translation units assigned to bank 255, automatically assign them banks
# You can set the name of the .gb ROM file here
PROJECTNAME = WordleBoy
# ASMDIR = asm
SRCDIR = source
OBJDIR = objects
WORDDIR = words
BINS = $(PROJECTNAME).gb
CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(WORDDIR),$(notdir $(wildcard $(dir)/*.c)))
# ASMSOURCES = $(foreach dir,$(ASMDIR),$(notdir $(wildcard $(dir)/*.s)))
# OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o)
all: prepare $(BINS)
compile.bat: Makefile
@echo "REM Automatically generated from Makefile" > compile.bat
@make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
# Compile .c files in "source/" to .o object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(LCC) $(LCCFLAGS) -c -o $@ $<
# Compile .c files in "words/" to .o object files
$(OBJDIR)/%.o: $(WORDDIR)/%.c
$(LCC) $(LCCFLAGS) -c -o $@ $<
# Compile .s assembly files in "asm/" to .o object files
# $(OBJDIR)/%.o: $(ASMDIR)/%.s
# $(LCC) $(LCCFLAGS) -c -o $@ $<
# If needed, compile .c files in "source/" to .s assembly files
# (not required if .c is compiled directly to .o)
$(OBJDIR)/%.s: $(SRCDIR)/%.c
$(LCC) $(LCCFLAGS) -S -o $@ $<
# Link the compiled object files into a .gb ROM file
$(BINS): $(OBJS)
$(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS)
prepare:
mkdir -p $(OBJDIR)
clean:
rm -f *.gb *.ihx *.cdb *.adb *.noi *.map *.sym
rm -rf $(OBJDIR)