cscg22-gearboy

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

Makefile (2905B)


      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
     10
     11# Configure platform specific LCC flags here:
     12LCCFLAGS_gb      = -Wm-ys -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
     13LCCFLAGS_pocket  = -Wm-ys -Wl-yt0x1B # Usually the same as required for .gb
     14LCCFLAGS_duck    = -Wm-ys -Wl-yt0x1B # Usually the same as required for .gb
     15LCCFLAGS_gbc     = -Wm-ys -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 = pong
     27
     28# EXT?=gb # Only sets extension to default (game boy .gb) if not populated
     29SRCDIR      = src
     30OBJDIR      = obj/$(EXT)
     31RESDIR      = res
     32BINDIR      = build/$(EXT)
     33MKDIRS      = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
     34
     35BINS	    = $(OBJDIR)/$(PROJECTNAME).$(EXT)
     36CSOURCES    = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
     37ASMSOURCES  = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
     38OBJS       = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
     39
     40# Builds all targets sequentially
     41all: $(TARGETS)
     42
     43# Compile .c files in "src/" to .o object files
     44$(OBJDIR)/%.o:	$(SRCDIR)/%.c
     45	$(LCC) $(CFLAGS) -c -o $@ $<
     46
     47# Compile .c files in "res/" to .o object files
     48$(OBJDIR)/%.o:	$(RESDIR)/%.c
     49	$(LCC) $(CFLAGS) -c -o $@ $<
     50
     51# Compile .s assembly files in "src/" to .o object files
     52$(OBJDIR)/%.o:	$(SRCDIR)/%.s
     53	$(LCC) $(CFLAGS) -c -o $@ $<
     54
     55# If needed, compile .c files i n"src/" to .s assembly files
     56# (not required if .c is compiled directly to .o)
     57$(OBJDIR)/%.s:	$(SRCDIR)/%.c
     58	$(LCC) $(CFLAGS) -S -o $@ $<
     59
     60# Link the compiled object files into a .gb ROM file
     61$(BINS):	$(OBJS)
     62	$(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
     63
     64clean:
     65	@echo Cleaning
     66	@for target in $(TARGETS); do \
     67		$(MAKE) $$target-clean; \
     68	done
     69
     70# Include available build targets
     71include Makefile.targets
     72
     73
     74# create necessary directories after Makefile is parsed but before build
     75# info prevents the command from being pasted into the makefile
     76ifneq ($(strip $(EXT)),)           # Only make the directories if EXT has been set by a target
     77$(info $(shell mkdir -p $(MKDIRS)))
     78endif