forked from Canite/SlimeTrials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (101 loc) · 4.26 KB
/
Makefile
File metadata and controls
125 lines (101 loc) · 4.26 KB
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
123
124
125
#
# A Makefile that compiles all .c and .s files in "src" and "res"
# subdirectories and places the output in a "obj" subdirectory
#
# If you move this project you can change the directory
# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
ifdef OS
GBDK_HOME = "F:/gbdk/"
RGBDS_HOME = "F:/GBDev/rgbds-0.6.1-win64/"
EMULATOR = "F:/bgb/bgb.exe"
HUGE_HOME = "F:/hugetracker"
else
GBDK_HOME = /home/canight/gbdk/
RGBDS_HOME = /home/canight/rgbds
HUGE_HOME = /home/canight/hugetracker
EMULATOR = java
EMULATORFLAGS += -jar /home/canight/Downloads/emulicious/Emulicious.jar
endif
SRCDIR = src
OBJDIR = obj
RESDIR = res
EXTDIR = ext
UTILDIR = utils
# Configure platform specific LCC flags here:
LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
LCC = $(GBDK_HOME)bin/lcc
PNGCONVERTER = $(GBDK_HOME)bin/png2asset
PNGCONVERTERFLAGS = -tiles_only -spr8x8 -noflip -keep_palette_order -repair_indexed_pal -no_palettes -b 255
RGBASM = $(RGBDS_HOME)/rgbasm
UGE2SOURCE = $(HUGE_HOME)/uge2source
# You can set flags for LCC here
CFLAGS += -Iinclude -Iext -debug
LCCFLAGS += $(LCCFLAGS_gb)
LCCFLAGS += -Wl-j -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v
LCCFLAGS += -Wl-l$(EXTDIR)/hUGEDriver.lib
# LCCFLAGS += -v # Uncomment for lcc verbose output
RGB2SDAS = python $(UTILDIR)/rgb2sdas.py
# You can set the name of the .gb ROM file here
PROJECTNAME = SlimeTrials
BINS = $(OBJDIR)/$(PROJECTNAME).gb
CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.asm)))
EXTASMSOURCES = $(foreach dir,$(EXTDIR),$(notdir $(wildcard $(dir)/*.asm)))
IMAGEFILES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
TILEDFILES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.tmj)))
HUGEFILES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.uge)))
SFXFILES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.sav)))
OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.asm=$(OBJDIR)/%.o) $(EXTASMSOURCES:%.asm=$(OBJDIR)/%.o)
RESOBJS = $(IMAGEFILES:%.png=$(RESDIR)/%.c) $(TILEDFILES:%.tmj=$(RESDIR)/%.c) $(HUGEFILES:%.uge=$(RESDIR)/%.c) $(SFXFILES:%.sav=$(RESDIR)/%.c)
all: prepare $(BINS)
compile.bat: Makefile
@echo "REM Automatically generated from Makefile" > compile.bat
@make -sn | sed y/\\//\\\\/ | sed s/mkdir\ -p\/mkdir\/ | grep -v make >> compile.bat
# Compile .png files in "res/" to bin files
$(RESDIR)/%.c: $(RESDIR)/%.png
$(PNGCONVERTER) $< $(PNGCONVERTERFLAGS) -o $@
$(LCC) $(CFLAGS) -c -o $(OBJDIR)/$(*F).o $@
$(RESDIR)/%.c: $(RESDIR)/%.tmj
$(UTILDIR)/convert_tile_json.py -i $< -o $@
$(LCC) $(CFLAGS) -c -o $(OBJDIR)/$(*F).o $@
$(RESDIR)/%.c: $(RESDIR)/%.uge
$(UGE2SOURCE) $< -b 255 $(*F) $@
$(UTILDIR)/create_huge_header.py -i $@
$(LCC) $(CFLAGS) -c -o $(OBJDIR)/$(*F).o $@
$(RESDIR)/%.c: $(RESDIR)/%.sav
$(UTILDIR)/fxhammer2data.py -o $@ $<
$(LCC) $(CFLAGS) -c -o $(OBJDIR)/$(*F).o $@
# Compile .c files in "src/" to .o object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(LCC) $(CFLAGS) -c -o $@ $<
# Compile .c files in "res/" to .o object files
$(OBJDIR)/%.o: $(RESDIR)/%.c
$(LCC) $(CFLAGS) -c -o $@ $<
# Compile .s assembly files in "src/" to .o object files
$(OBJDIR)/%.o: $(SRCDIR)/%.asm
$(LCC) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/%.o: $(OBJDIR)/%.obj
$(RGB2SDAS) $(RGB2SDASFLAGS) -o$@ $<
# Compile external .s assembly files in "src/" to .o object files
$(OBJDIR)/%.obj: $(EXTDIR)/%.asm
$(RGBASM) -i.. -DGBDK -o$@ $<
# If needed, compile .c files in "src/" to .s assembly files
# (not required if .c is compiled directly to .o)
$(OBJDIR)/%.s: $(SRCDIR)/%.c
$(LCC) $(CFLAGS) -S -o $@ $<
# Link the compiled object files into a .gb ROM file
$(BINS): $(RESOBJS) $(OBJS)
$(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINS) $(OBJS)
prepare:
mkdir -p $(OBJDIR)
clean:
# rm -f *.gb *.ihx *.cdb *.adb *.noi *.map
rm -f $(OBJDIR)/*.*
rm -f $(RESDIR)/*.c
rm -f $(RESDIR)/*.h
rm -f $(RESDIR)/*.2bpp
run:
$(EMULATOR) $(EMULATORFLAGS) $(OBJDIR)/$(PROJECTNAME).gb