cscg22-gearboy

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

Makefile (3263B)


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