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/cross-platform/gbdecompress/Makefile

      1 # If you move this project you can change the directory
      2 # to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
      3 ifndef GBDK_HOME
      4 	GBDK_HOME = ../../../
      5 endif
      6 
      7 LCC = $(GBDK_HOME)/bin/lcc
      8 PNG2ASSET = $(GBDK_HOME)/bin/png2asset
      9 
     10 # Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
     11 # They can also be built/cleaned individually: "make gg" and "make gg-clean"
     12 # Possible are: gb gbc pocket megaduck sms gg
     13 TARGETS=gb pocket megaduck sms gg
     14 
     15 # Configure platform specific LCC flags here:
     16 LCCFLAGS_gb      = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
     17 LCCFLAGS_pocket  = -Wl-yt0x1B # Usually the same as required for .gb
     18 LCCFLAGS_duck    = -Wl-yt0x1B # Usually the same as required for .gb
     19 LCCFLAGS_gbc     = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
     20 LCCFLAGS_sms     =
     21 LCCFLAGS_gg      =
     22 
     23 LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
     24 
     25 LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
     26 
     27 # GBDK_DEBUG = ON
     28 ifdef GBDK_DEBUG
     29 	LCCFLAGS += -debug -v
     30 endif
     31 
     32 
     33 # Add directory where platform specific meta tile sprites get converted into (obj/<platform ext>/src)
     34 # So they can be included with "#include <res/somefile.h>"
     35 CFLAGS += -I$(OBJDIR)
     36 
     37 # You can set the name of the ROM file here
     38 PROJECTNAME = gbdecompress
     39 
     40 SRCDIR      = src
     41 OBJDIR      = obj/$(EXT)
     42 RESOBJSRC   = obj/$(EXT)/res
     43 RESDIR      = res
     44 BINDIR      = build/$(EXT)
     45 MKDIRS      = $(OBJDIR) $(BINDIR) $(RESOBJSRC) # See bottom of Makefile for directory auto-creation
     46 
     47 BINS	    = $(OBJDIR)/$(PROJECTNAME).$(EXT)
     48 # For png2asset: converting metasprite source pngs -> .c -> .o
     49 METAPNGS    = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
     50 METASRCS    = $(METAPNGS:%.png=$(RESOBJSRC)/%.c)
     51 METAOBJS    = $(METASRCS:$(RESOBJSRC)/%.c=$(OBJDIR)/%.o)
     52 
     53 CSOURCES    = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
     54 ASMSOURCES  = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
     55 OBJS        = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
     56 
     57 
     58 # Builds all targets sequentially
     59 all: $(TARGETS)
     60 
     61 compile.bat: Makefile
     62 	@echo "REM Automatically generated from Makefile" > compile.bat
     63 	@make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
     64 
     65 
     66 # Use png2asset to convert the png into C formatted metasprite data
     67 # -sh 48   : Sets sprite height to 48 (width remains automatic)
     68 # -spr8x16 : Use 8x16 hardware sprites
     69 # -c ...   : Set C output file
     70 # Convert metasprite .pngs in res/ -> .c files in obj/<platform ext>/src/
     71 $(RESOBJSRC)/%.c:	$(RESDIR)/%.png
     72 	$(PNG2ASSET) $< -sh 48 -spr8x16 -noflip -c $@
     73 
     74 # Compile the Metasprite pngs that were converted to .c files
     75 # .c files in obj/<platform ext>/src/ -> .o files in obj/
     76 $(OBJDIR)/%.o:	$(RESOBJSRC)/%.c
     77 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
     78 
     79 # Compile .c files in "src/" to .o object files
     80 $(OBJDIR)/%.o:	$(SRCDIR)/%.c
     81 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
     82 
     83 # Compile .c files in "res/" to .o object files
     84 $(OBJDIR)/%.o:	$(RESDIR)/%.c
     85 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
     86 
     87 # Compile .s assembly files in "src/" to .o object files
     88 $(OBJDIR)/%.o:	$(SRCDIR)/%.s
     89 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
     90 
     91 # If needed, compile .c files in "src/" to .s assembly files
     92 # (not required if .c is compiled directly to .o)
     93 $(OBJDIR)/%.s:	$(SRCDIR)/%.c
     94 	$(LCC) $(LCCFLAGS) $(CFLAGS) -S -o $@ $<
     95 
     96 # Convert and build MetaSprites first so they're available when compiling the main sources
     97 $(OBJS):	$(METAOBJS)
     98 
     99 # Link the compiled object files into a .gb ROM file
    100 $(BINS):	$(OBJS)
    101 	$(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(METAOBJS) $(OBJS)
    102 
    103 clean:
    104 	@echo Cleaning
    105 	@for target in $(TARGETS); do \
    106 		$(MAKE) $$target-clean; \
    107 	done
    108 
    109 # Include available build targets
    110 include Makefile.targets
    111 
    112 
    113 # create necessary directories after Makefile is parsed but before build
    114 # info prevents the command from being pasted into the makefile
    115 ifneq ($(strip $(EXT)),)           # Only make the directories if EXT has been set by a target
    116 $(info $(shell mkdir -p $(MKDIRS)))
    117 endif

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