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/large_map/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 gbc gg sms nes
     14 
     15 # Configure platform specific LCC flags here:
     16 LCCFLAGS_gb      = -Wl-yt0x1B -autobank # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
     17 LCCFLAGS_pocket  = -Wl-yt0x1B -autobank # Usually the same as required for .gb
     18 LCCFLAGS_duck    = -Wl-yt0x1B -autobank # Usually the same as required for .gb
     19 LCCFLAGS_gbc     = -Wl-yt0x1B -Wm-yc -autobank # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
     20 LCCFLAGS_sms     =
     21 LCCFLAGS_gg      =
     22 LCCFLAGS_nes     = -autobank
     23 
     24 LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
     25 
     26 LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
     27 
     28 P2AFLAGS_gb     = -map -bpp 2 -max_palettes 4 -pack_mode gb -noflip
     29 P2AFLAGS_gbc    = -map -use_map_attributes -bpp 2 -max_palettes 8 -pack_mode gb
     30 P2AFLAGS_pocket = -map -bpp 2 -max_palettes 4 -pack_mode gb -noflip
     31 P2AFLAGS_duck   = -map -bpp 2 -max_palettes 4 -pack_mode gb -noflip
     32 P2AFLAGS_sms    = -map -use_map_attributes -bpp 4 -max_palettes 2 -pack_mode sms
     33 P2AFLAGS_gg     = -map -use_map_attributes -bpp 4 -max_palettes 2 -pack_mode sms
     34 P2AFLAGS_nes    = -map -bpp 2 -max_palettes 4 -pack_mode nes -noflip -use_nes_attributes -b 0
     35 
     36 P2AFLAGS = $(P2AFLAGS_$(EXT))
     37 
     38 # GBDK_DEBUG = ON
     39 ifdef GBDK_DEBUG
     40 	LCCFLAGS += -debug -v
     41 endif
     42 
     43 
     44 # You can set the name of the ROM file here
     45 PROJECTNAME = large-map
     46 
     47 CFLAGS = -Wf-MMD -Wf-Wp-MP # Header file dependency output (-MMD) for Makefile use + per-header Phoney rules (-MP)
     48 
     49 # EXT?=gb # Only sets extension to default (game boy .gb) if not populated
     50 SRCDIR      = src
     51 OBJDIR      = obj/$(EXT)
     52 RESOBJSRC   = obj/$(EXT)/res
     53 RESDIR      = res
     54 BINDIR      = build/$(EXT)
     55 MKDIRS      = $(OBJDIR) $(BINDIR) $(RESOBJSRC) # See bottom of Makefile for directory auto-creation
     56 
     57 BINS	    = $(OBJDIR)/$(PROJECTNAME).$(EXT)
     58 CSOURCES    = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
     59 ASMSOURCES  = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
     60 OBJS        = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
     61 
     62 # For png2asset: converting map source pngs -> .c -> .o
     63 MAPPNGS    = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
     64 MAPSRCS    = $(MAPPNGS:%.png=$(RESOBJSRC)/%.c)
     65 MAPOBJS    = $(MAPSRCS:$(RESOBJSRC)/%.c=$(OBJDIR)/%.o)
     66 
     67 .PRECIOUS: $(MAPSRCS)
     68 
     69 CFLAGS += -I$(OBJDIR) 
     70 
     71 # Builds all targets sequentially
     72 all: $(TARGETS)
     73 
     74 compile.bat: Makefile
     75 	@echo "REM Automatically generated from Makefile" > compile.bat
     76 	@make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
     77 
     78 
     79 # Use png2asset to convert the png into C formatted map data
     80 # -c ...   : Set C output file
     81 # Convert metasprite .pngs in res/ -> .c files in obj/<platform ext>/src/
     82 $(RESOBJSRC)/%.c:	$(RESDIR)/%.png
     83 	$(PNG2ASSET) $< $(P2AFLAGS) -c $@
     84 
     85 # Compile the map pngs that were converted to .c files
     86 # .c files in obj/<platform ext>/src/ -> .o files in obj/
     87 $(OBJDIR)/%.o:	$(RESOBJSRC)/%.c
     88 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
     89 
     90 # Dependencies (using output from -Wf-MMD -Wf-Wp-MP)
     91 DEPS = $(OBJS:%.o=%.d)
     92 
     93 -include $(DEPS)
     94 
     95 # Compile .c files in "src/" to .o object files
     96 $(OBJDIR)/%.o:	$(SRCDIR)/%.c
     97 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
     98 
     99 # Compile .c files in "res/" to .o object files
    100 $(OBJDIR)/%.o:	$(RESDIR)/%.c
    101 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
    102 
    103 # Compile .s assembly files in "src/" to .o object files
    104 $(OBJDIR)/%.o:	$(SRCDIR)/%.s
    105 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
    106 
    107 # If needed, compile .c files in "src/" to .s assembly files
    108 # (not required if .c is compiled directly to .o)
    109 $(OBJDIR)/%.s:	$(SRCDIR)/%.c
    110 	$(LCC) $(LCCFLAGS) $(CFLAGS) -S -o $@ $<
    111 
    112 # Convert and build maps first so they're available when compiling the main sources
    113 $(OBJS):	$(MAPOBJS)
    114 
    115 # Link the compiled object files into a .gb ROM file
    116 $(BINS):	$(OBJS)
    117 	$(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(MAPOBJS) $(OBJS)
    118 
    119 clean:
    120 	@echo Cleaning
    121 	@for target in $(TARGETS); do \
    122 		$(MAKE) $$target-clean; \
    123 	done
    124 
    125 # Include available build targets
    126 include Makefile.targets
    127 
    128 
    129 # create necessary directories after Makefile is parsed but before build
    130 # info prevents the command from being pasted into the makefile
    131 ifneq ($(strip $(EXT)),)           # Only make the directories if EXT has been set by a target
    132 $(info $(shell mkdir -p $(MKDIRS)))
    133 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.