Makefile (2938B)
1# If you move this project you can change the directory 2# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" 3GBDK_HOME = ../../../ 4LCC = $(GBDK_HOME)bin/lcc 5 6# Set platforms to build here, spaced separated. (These are in the separate Makefile.targets) 7# They can also be built/cleaned individually: "make gg" and "make gg-clean" 8# Possible are: gb gbc pocket megaduck sms gg 9TARGETS=gb gg 10 11# Configure platform specific LCC flags here: 12LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT) 13LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb 14LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb 15LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive) 16LCCFLAGS_sms = 17LCCFLAGS_gg = 18 19LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags 20 21LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags 22# LCCFLAGS += -debug # Uncomment to enable debug output 23# LCCFLAGS += -v # Uncomment for lcc verbose output 24 25# You can set the name of the ROM file here 26PROJECTNAME = large-map 27 28CFLAGS = -Wf-MMD 29 30# EXT?=gb # Only sets extension to default (game boy .gb) if not populated 31SRCDIR = src 32OBJDIR = obj/$(EXT) 33RESDIR = res 34BINDIR = build/$(EXT) 35MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation 36 37BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT) 38CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c))) 39ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s))) 40OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o) 41 42# Builds all targets sequentially 43all: $(TARGETS) 44 45# Dependencies 46DEPS = $(OBJS:%.o=%.d) 47 48-include $(DEPS) 49 50# Compile .c files in "src/" to .o object files 51$(OBJDIR)/%.o: $(SRCDIR)/%.c 52 $(LCC) $(CFLAGS) -c -o $@ $< 53 54# Compile .c files in "res/" to .o object files 55$(OBJDIR)/%.o: $(RESDIR)/%.c 56 $(LCC) $(CFLAGS) -c -o $@ $< 57 58# Compile .s assembly files in "src/" to .o object files 59$(OBJDIR)/%.o: $(SRCDIR)/%.s 60 $(LCC) $(CFLAGS) -c -o $@ $< 61 62# If needed, compile .c files i n"src/" to .s assembly files 63# (not required if .c is compiled directly to .o) 64$(OBJDIR)/%.s: $(SRCDIR)/%.c 65 $(LCC) $(CFLAGS) -S -o $@ $< 66 67# Link the compiled object files into a .gb ROM file 68$(BINS): $(OBJS) 69 $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS) 70 71clean: 72 @echo Cleaning 73 @for target in $(TARGETS); do \ 74 $(MAKE) $$target-clean; \ 75 done 76 77# Include available build targets 78include Makefile.targets 79 80 81# create necessary directories after Makefile is parsed but before build 82# info prevents the command from being pasted into the makefile 83ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target 84$(info $(shell mkdir -p $(MKDIRS))) 85endif