git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/examples/gb/linkerfile/Makefile

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

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.