forked from untoxa/VGM2GBSFX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (89 loc) · 4.19 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
SHELL := /bin/bash
# If you move this project you can change the directory
# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
GBDK_HOME = ../../../gbdk/
LCC = $(GBDK_HOME)bin/lcc
# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
# They can also be built/cleaned individually: "make gg" and "make gg-clean"
# Possible are: gb gbc pocket sms gg
#TARGETS=gb pocket sms gg
TARGETS = gb
CFLAGS =
# Configure platform specific LCC flags here:
LCCFLAGS_gb = -Wl-yt0x19 -Wl-yo4 -Wm-yS -Wm-yn"$(PROJECTNAME)"
LCCFLAGS_pocket = -Wl-yt0x19 -Wl-yo4 -Wm-yS -Wm-yn"$(PROJECTNAME)"
LCCFLAGS_sms = -Wl-yo4 -Wm-yS
LCCFLAGS_gg = -Wl-yo4 -Wm-yS
LCCFLAGS += $(LCCFLAGS_$(EXT)) -Wl-llib/$(PORT)/hUGEDriver.lib # This adds the current platform specific LCC Flags
LCCFLAGS += -Wl-j -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
# LCCFLAGS += -debug # Uncomment to enable debug output
# LCCFLAGS += -v # Uncomment for lcc verbose output
CFLAGS = -Iinclude -Ires -Isrc/$(PORT) -Iobj/$(PLAT)
# You can set the name of the ROM file here
PROJECTNAME = libtest
# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
SRCDIR = src
SRCPLAT = src/$(PORT)
OBJDIR = obj/$(EXT)
RESDIR = res
BINDIR = build/$(EXT)
MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
VGM_RES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.vgm)))
WAV_RES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.wav)))
FX_RES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.sav)))
UGE_RES = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.uge)))
CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(SRCPLAT),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s))) $(foreach dir,$(SRCPLAT),$(notdir $(wildcard $(dir)/*.s)))
OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
RESOBJ = $(VGM_RES:%.vgm=$(OBJDIR)/%.o) $(WAV_RES:%.wav=$(OBJDIR)/%.o) $(FX_RES:%.sav=$(OBJDIR)/%.o) $(UGE_RES:%.uge=$(OBJDIR)/%.o)
DEPENDANT = $(CSOURCES:%.c=$(OBJDIR)/%.o)
# Builds all targets sequentially
all: $(TARGETS)
# Dependencies
DEPS = $(DEPENDANT:%.o=%.d)
-include $(DEPS)
.SECONDEXPANSION:
$(OBJDIR)/%.c: $(RESDIR)/%.vgm $$(wildcard $(RESDIR)/%.vgm.meta)
python utils/vgm2data.py `cat <$<.meta 2>/dev/null` -o $@ $<
.SECONDEXPANSION:
$(OBJDIR)/%.c: $(RESDIR)/%.wav $$(wildcard $(RESDIR)/%.wav.meta)
python utils/wav2data.py `cat <$<.meta 2>/dev/null` -o $@ $<
.SECONDEXPANSION:
$(OBJDIR)/%.c: $(RESDIR)/%.sav $$(wildcard $(RESDIR)/%.sav.meta)
python utils/fxhammer2data.py `cat <$<.meta 2>/dev/null` -o $@ $<
.SECONDEXPANSION:
$(OBJDIR)/%.c: $(RESDIR)/%.uge $$(wildcard $(RESDIR)/%.uge.meta)
utils/uge2source $< `cat <$<.meta 2>/dev/null` $(basename $(notdir $<)) $@
$(OBJDIR)/%.o: $(OBJDIR)/%.c
$(LCC) $(CFLAGS) -c -o $@ $<
# Compile .c files in "src/" to .o object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(LCC) -Wf-MMD $(CFLAGS) -c -o $@ $<
# Compile .c files in "src/<target>/" to .o object files
$(OBJDIR)/%.o: $(SRCPLAT)/%.c
$(LCC) -Wf-MMD $(CFLAGS) -c -o $@ $<
# Compile .c files in "res/" to .o object files
$(OBJDIR)/%.o: $(RESDIR)/%.c
$(LCC) -Wf-MMD $(CFLAGS) -c -o $@ $<
# Compile .s assembly files in "src/<target>/" to .o object files
$(OBJDIR)/%.o: $(SRCPLAT)/%.s
$(LCC) $(CFLAGS) -c -o $@ $<
# Compile .s assembly files in "src/" to .o object files
$(OBJDIR)/%.o: $(SRCDIR)/%.s
$(LCC) $(CFLAGS) -c -o $@ $<
# Link the compiled object files into a .gb ROM file
$(BINS): $(RESOBJ) $(OBJS)
$(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $^
clean:
@echo Cleaning
@for target in $(TARGETS); do \
$(MAKE) $$target-clean; \
done
# Include available build targets
include Makefile.targets
# create necessary directories after Makefile is parsed but before build
# info prevents the command from being pasted into the makefile
ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
$(info $(shell mkdir -p $(MKDIRS)))
endif