cscg22-gearboy

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

Makefile (1976B)


      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
     12# You can set flags for LCC here
     13# For example, you can uncomment the line below to turn on debug output
     14LCCFLAGS = -msm83:ap
     15# LCCFLAGS += -debug
     16# LCCFLAGS += -v
     17
     18# You can set the name of the .pocket ROM file here
     19PROJECTNAME    = Example
     20
     21SRCDIR      = src
     22OBJDIR      = obj
     23RESDIR      = res
     24BINS	    = $(OBJDIR)/$(PROJECTNAME).pocket
     25CSOURCES    = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
     26ASMSOURCES  = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
     27OBJS       = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
     28
     29all:	prepare $(BINS)
     30
     31compile.bat: Makefile
     32	@echo "REM Automatically generated from Makefile" > compile.bat
     33	@make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
     34
     35# Compile .c files in "src/" to .o object files
     36$(OBJDIR)/%.o:	$(SRCDIR)/%.c
     37	$(LCC) $(LCCFLAGS) -c -o $@ $<
     38
     39# Compile .c files in "res/" to .o object files
     40$(OBJDIR)/%.o:	$(RESDIR)/%.c
     41	$(LCC) $(LCCFLAGS) -c -o $@ $<
     42
     43# Compile .s assembly files in "src/" to .o object files
     44$(OBJDIR)/%.o:	$(SRCDIR)/%.s
     45	$(LCC) $(LCCFLAGS) -c -o $@ $<
     46
     47# If needed, compile .c files i n"src/" to .s assembly files
     48# (not required if .c is compiled directly to .o)
     49$(OBJDIR)/%.s:	$(SRCDIR)/%.c
     50	$(LCC) $(LCCFLAGS) -S -o $@ $<
     51
     52
     53$(OBJDIR)/linkfile.lk:	$(OBJS)
     54	rm -f $@
     55	@for obj in $(OBJS); do \
     56		echo $$obj >>$@; \
     57	done
     58
     59# Link the compiled object files (via linkerfile) into a .pocket ROM file
     60$(BINS):	$(OBJDIR)/linkfile.lk
     61		$(LCC) $(LCCFLAGS) -o $(BINS) -Wl-f$<
     62
     63prepare:
     64	mkdir -p $(OBJDIR)
     65	mkdir -p $(RESDIR)
     66
     67clean:
     68#	rm -f  *.pocket *.ihx *.cdb *.adb *.noi *.map
     69	rm -f  $(OBJDIR)/*.*
     70