cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

Makefile (2986B)


      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 pocket megaduck sms gg msxdos
     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      =
     18LCCFLAGS_msxdos  =
     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
     26CFLAGS      = -Iinclude
     27
     28# You can set the name of the ROM file here
     29PROJECTNAME = test
     30
     31# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
     32SRCDIR      = src
     33OBJDIR      = obj/$(EXT)
     34RESDIR      = res
     35BINDIR      = build/$(EXT)
     36MKDIRS      = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
     37
     38BINS	    = $(OBJDIR)/$(PROJECTNAME).$(EXT)
     39CSOURCES    = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
     40ASMSOURCES  = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
     41OBJS        = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
     42
     43# Builds all targets sequentially
     44all: $(TARGETS)
     45
     46# Compile .c files in "src/" to .o object files
     47$(OBJDIR)/%.o:	$(SRCDIR)/%.c
     48	$(LCC) $(CFLAGS) -c -o $@ $<
     49
     50# Compile .c files in "res/" to .o object files
     51$(OBJDIR)/%.o:	$(RESDIR)/%.c
     52	$(LCC) $(CFLAGS) -c -o $@ $<
     53
     54# Compile .s assembly files in "src/" to .o object files
     55$(OBJDIR)/%.o:	$(SRCDIR)/%.s
     56	$(LCC) $(CFLAGS) -c -o $@ $<
     57
     58# If needed, compile .c files i n"src/" to .s assembly files
     59# (not required if .c is compiled directly to .o)
     60$(OBJDIR)/%.s:	$(SRCDIR)/%.c
     61	$(LCC) $(CFLAGS) -S -o $@ $<
     62
     63# Link the compiled object files into a .gb ROM file
     64$(BINS):	$(OBJS)
     65	$(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
     66	rm -f $(BINDIR)/*.map $(BINDIR)/*.ihx $(BINDIR)/*.bin
     67
     68clean:
     69	@echo Cleaning
     70	@for target in $(TARGETS); do \
     71		$(MAKE) $$target-clean; \
     72	done
     73
     74# Include available build targets
     75include Makefile.targets
     76
     77
     78# create necessary directories after Makefile is parsed but before build
     79# info prevents the command from being pasted into the makefile
     80ifneq ($(strip $(EXT)),)           # Only make the directories if EXT has been set by a target
     81$(info $(shell mkdir -p $(MKDIRS)))
     82endif