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