cscg22-gearboy

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

Makefile (1811B)


      1#
      2# A Makefile that compiles all .c and .s files in "src" and "res" 
      3# subdirectories and places the output in a "obj" subdirectory
      4#
      5
      6# If you move this project you can change the directory 
      7# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
      8GBDK_HOME = ../../../
      9
     10LCC = $(GBDK_HOME)bin/lcc 
     11
     12LCCFLAGS = -msm83:ap
     13# You can set flags for LCC here
     14# For example, you can uncomment the line below to turn on debug output
     15# LCCFLAGS += -debug
     16
     17# You can set the name of the .pocket ROM file here
     18PROJECTNAME    = Example
     19
     20SRCDIR      = src
     21OBJDIR      = obj
     22RESDIR      = res
     23BINS	    = $(OBJDIR)/$(PROJECTNAME).pocket
     24CSOURCES    = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
     25ASMSOURCES  = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
     26OBJS       = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
     27
     28all:	prepare $(BINS)
     29
     30compile.bat: Makefile
     31	@echo "REM Automatically generated from Makefile" > compile.bat
     32	@make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
     33
     34# Compile .c files in "src/" to .o object files
     35$(OBJDIR)/%.o:	$(SRCDIR)/%.c
     36	$(LCC) $(LCCFLAGS) -c -o $@ $<
     37
     38# Compile .c files in "res/" to .o object files
     39$(OBJDIR)/%.o:	$(RESDIR)/%.c
     40	$(LCC) $(LCCFLAGS) -c -o $@ $<
     41
     42# Compile .s assembly files in "src/" to .o object files
     43$(OBJDIR)/%.o:	$(SRCDIR)/%.s
     44	$(LCC) $(LCCFLAGS) -c -o $@ $<
     45
     46# If needed, compile .c files i n"src/" to .s assembly files
     47# (not required if .c is compiled directly to .o)
     48$(OBJDIR)/%.s:	$(SRCDIR)/%.c
     49	$(LCC) $(LCCFLAGS) -S -o $@ $<
     50
     51# Link the compiled object files into a .pocket ROM file
     52$(BINS):	$(OBJS)
     53	$(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS)
     54
     55prepare:
     56	mkdir -p $(OBJDIR)
     57
     58clean:
     59#	rm -f  *.pocket *.ihx *.cdb *.adb *.noi *.map
     60	rm -f  $(OBJDIR)/*.*
     61