-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
97 lines (76 loc) · 3.42 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
# 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
RGBGFX = ../rgbds/rgbgfx
GBCOMPRESS = $(GBDK_HOME)bin/gbcompress
PYTHON = python
# 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 megaduck sms gg
TARGETS=gbc gb pocket # megaduck sms gg
# Configure platform specific link flags here:
LCCFLAGS_gb = -Wm-ys #
LCCFLAGS_pocket = -Wm-ys # Usually the same as required for .gb
LCCFLAGS_duck = -Wm-ys # Usually the same as required for .gb
LCCFLAGS_gbc = -Wm-ys -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
LCCFLAGS_sms =
LCCFLAGS_gg =
LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
LCCFLAGS += -Wl-j -Wl-m -Wl-w -Wm-yo4 -Wm-ya1 -Wm-yt3 -Wm-ynPORKLIKE
LCCFLAGS += -Wl-b_CALIGNED=0x0200 -Wl-b_CODE=0x300 -Wl-b_DALIGNED=0xc100 -Wl-b_DATA=0xcf00
# LCCFLAGS += -debug # Uncomment to enable debug output
# LCCFLAGS += -v # Uncomment for lcc verbose output
# Configure platform specific compiler flags here:
CFLAGS_gb =
CFLAGS_pocket =
CFLAGS_duck =
CFLAGS_gbc = -DCGB_SUPPORT
CFLAGS_sms =
CFLAGS_gg =
CFLAGS += $(CFLAGS_$(EXT)) # This adds the current platform specific C Flags
# You can set the name of the ROM file here
PROJECTNAME = porklike
# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
SRCDIR = src
IMGDIR = img
OBJDIR = obj/$(EXT)
BINDIR = build/$(EXT)
MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
CSOURCES = bank0.c gen.c main.c sound.c title.c rand.c mob.c pickup.c ai.c gameplay.c inventory.c palette.c spr.c float.c msg.c sprite.c targeting.c gameover.c animate.c joy.c
ASMSOURCES = util.s music.s aligned.s
IMGSOURCES = bg.png shared.png sprites.png dead.png title.png
BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o) $(IMGSOURCES:%.png=$(OBJDIR)/tile%.o)
# Builds all targets sequentially
all: $(TARGETS)
# Generated file dependencies
$(SRCDIR)/main.c: $(OBJDIR)/tilebg.o $(OBJDIR)/tileshared.o $(OBJDIR)/tilesprites.o $(OBJDIR)/tiledead.o
$(SRCDIR)/title.c: $(OBJDIR)/tiletitle.o
# Compile .c files in "src/" to .o object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(LCC) $(CFLAGS) -Wf-MD -I$(OBJDIR) -c -o $@ $<
# Compile .s assembly files in "src/" to .o object files
$(OBJDIR)/%.o: $(SRCDIR)/%.s
$(LCC) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/tile%.o: $(IMGDIR)/%.png
$(RGBGFX) -u $< -o $(basename $@).bin
$(GBCOMPRESS) $(basename $@).bin $(basename $@).binz
$(PYTHON) ref/bin2c.py $(basename $@).binz -o $(basename $@).c
$(LCC) $(CFLAGS) -c -o $@ $(basename $@).c
# Link the compiled object files into a .gb ROM file
$(BINS): $(OBJS)
$(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
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
-include $(OBJDIR)/%.d