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/platformer_template/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 
     13 PNG2ASSET = $(GBDK_HOME)/bin/png2asset 
     14 LCC = $(GBDK_HOME)/bin/lcc 
     15 
     16 # Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
     17 # They can also be built/cleaned individually: "make gg" and "make gg-clean"
     18 # Possible are: gb gbc pocket megaduck sms gg
     19 TARGETS=gb pocket megaduck sms gg nes
     20 
     21 # You can set flags for LCC here
     22 # For example, you can uncomment the line below to turn on debug output
     23 # LCCFLAGS = -debug
     24 
     25 # You can set the name of the .gb ROM file here
     26 PROJECTNAME    = platformer_template
     27 
     28 SRCDIR      = src
     29 DISTDIR      = dist
     30 OBJDIR      = obj/$(EXT)
     31 RESDIR      = res
     32 GENDIR      = gen/$(EXT)/src
     33 BINDIR      = build/$(EXT)
     34 MKDIRS      = $(GENDIR) $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
     35 BINS	    = $(OBJDIR)/$(PROJECTNAME).$(EXT)
     36 CSOURCES    = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) 
     37 GENSOURCES    = $(foreach dir,$(GENDIR), $(wildcard $(dir)/*.c))
     38 ASMSOURCES  = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
     39 OBJS       = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
     40 
     41 LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -Wb-ext=.rel $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
     42 
     43 
     44 # Configure platform specific LCC flags here:
     45 LCCFLAGS_gb      = -Wm-ys -Wl-yt0x1B -autobank # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
     46 LCCFLAGS_pocket  = -Wm-ys -Wl-yt0x1B -autobank # Usually the same as required for .gb
     47 LCCFLAGS_duck    = -Wm-ys -Wl-yt0x1B -autobank # Usually the same as required for .gb
     48 LCCFLAGS_gbc     = -Wm-ys -Wl-yt0x1B -Wm-yc -autobank # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
     49 LCCFLAGS_sms     = -Wm-ys -Wl-yt0x1B -autobank
     50 LCCFLAGS_gg      = -Wm-ys -Wl-yt0x1B -autobank
     51 LCCFLAGS_nes     = -Wm-ys -Wl-yt0x1B -autobank
     52 
     53 all: $(TARGETS)
     54 
     55 compile.bat: Makefile
     56 	@echo "REM Automatically generated from Makefile" > compile.bat
     57 	@make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
     58 
     59 
     60 # png2asset settings for backgrounds
     61 PNG2ASSET_BKG_SETTINGS_gg=-pack_mode sms -bpp 4
     62 PNG2ASSET_BKG_SETTINGS_sms=-pack_mode sms -bpp 4
     63 PNG2ASSET_BKG_SETTINGS_nes=-noflip -bpp 2 -pack_mode nes
     64 PNG2ASSET_BKG_SETTINGS_gb=
     65 PNG2ASSET_BKG_SETTINGS_gbc=
     66 PNG2ASSET_BKG_SETTINGS_duck=
     67 PNG2ASSET_BKG_SETTINGS_pocket=
     68 
     69 # png2asset settings for sprites
     70 PNG2ASSET_SPRITE_SETTINGS_gg=-noflip -pack_mode sms -bpp 4
     71 PNG2ASSET_SPRITE_SETTINGS_sms=-noflip -pack_mode sms -bpp 4
     72 PNG2ASSET_SPRITE_SETTINGS_nes=
     73 PNG2ASSET_SPRITE_SETTINGS_gb=
     74 PNG2ASSET_SPRITE_SETTINGS_gbc=
     75 PNG2ASSET_SPRITE_SETTINGS_duck=
     76 PNG2ASSET_SPRITE_SETTINGS_pocket=
     77 
     78 
     79 
     80 png2asset:
     81 	$(PNG2ASSET) res/graphics/player-character-$(SPRITES)-sprites.png -c $(GENDIR)/PlayerCharacterSprites.c -px 12 -py 6 -spr8x16 -keep_palette_order -sw 24 -sh 32 $(PNG2ASSET_SPRITE_SETTINGS_$(EXT)) -b 255
     82 	$(PNG2ASSET) res/graphics/world1-tileset.png -c $(GENDIR)/World1Tileset.c -keep_palette_order -noflip -map $(PNG2ASSET_BKG_SETTINGS_$(EXT)) -b 255
     83 	$(PNG2ASSET) res/graphics/world2-tileset.png -c $(GENDIR)/World2Tileset.c -keep_palette_order -noflip -map $(PNG2ASSET_BKG_SETTINGS_$(EXT)) -b 255
     84 	$(PNG2ASSET) res/graphics/world1-area1.png -c $(GENDIR)/World1Area1.c -noflip -map -maps_only -source_tileset res/graphics/world1-tileset.png $(PNG2ASSET_BKG_SETTINGS_$(EXT))  -b 255
     85 	$(PNG2ASSET) res/graphics/world1-area2.png -c $(GENDIR)/World1Area2.c -noflip -map -maps_only -source_tileset res/graphics/world1-tileset.png $(PNG2ASSET_BKG_SETTINGS_$(EXT)) -b 255
     86 	$(PNG2ASSET) res/graphics/world2-area1.png -c $(GENDIR)/World2Area1.c -noflip -map -maps_only -source_tileset res/graphics/world2-tileset.png $(PNG2ASSET_BKG_SETTINGS_$(EXT)) -b 255
     87 	$(PNG2ASSET) res/graphics/title-screen.png -c $(GENDIR)/TitleScreen.c -noflip -map $(PNG2ASSET_BKG_SETTINGS_$(EXT))  -b 255
     88 	$(PNG2ASSET) res/graphics/next-level.png -c $(GENDIR)/NextLevel.c -noflip -map $(PNG2ASSET_BKG_SETTINGS_$(EXT)) -b 255
     89 
     90 
     91 # Compile .c files in "src/" to .o object files
     92 $(OBJDIR)/%.o:	$(SRCDIR)/%.c 
     93 	$(LCC) $(LCCFLAGS) $(CFLAGS) -I$(GENDIR) -Ires -c -o $@ $<
     94 
     95 # Compile .s assembly files in "src/" to .o object files
     96 $(OBJDIR)/%.o:	$(SRCDIR)/%.s
     97 	$(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
     98 
     99 # If needed, compile .c files in "src/" to .s assembly files
    100 # (not required if .c is compiled directly to .o)
    101 $(OBJDIR)/%.s:	$(SRCDIR)/%.c
    102 	$(LCC) $(LCCFLAGS) $(CFLAGS) -S -o $@ $<
    103 
    104 # Link the compiled object files into a .gb ROM file
    105 $(BINS):	$(OBJS) 
    106 	$(LCC) $(LCCFLAGS) $(CFLAGS) -I$(GENDIR) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS) $(GENSOURCES)
    107 
    108 
    109 prepare:
    110 	mkdir -p $(OBJDIR)
    111 	mkdir -p $(DISTDIR)
    112 	mkdir -p $(GENDIR)
    113 
    114 clean:
    115 	@echo Cleaning
    116 	@for target in $(TARGETS); do \
    117 		$(MAKE) $$target-clean; \
    118 	done
    119 
    120 # Include available build targets
    121 include Makefile.targets
    122 
    123 
    124 # create necessary directories after Makefile is parsed but before build
    125 # info prevents the command from being pasted into the makefile
    126 ifneq ($(strip $(EXT)),)           # Only make the directories if EXT has been set by a target
    127 $(info $(shell mkdir -p $(MKDIRS)))
    128 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.