gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/cross-platform/rle_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 GBCOMPRESS = $(GBDK_HOME)/bin/gbcompress
10
11 # Set platforms to build here, spaced separated. (These are in the separate Makefile.targets)
12 # They can also be built/cleaned individually: "make gg" and "make gg-clean"
13 # Possible are: gb gbc pocket megaduck sms gg
14 #TARGETS=gb pocket sms gg
15 TARGETS=gb gg sms nes
16
17 # Configure platform specific LCC flags here:
18 LCCFLAGS_gb = -Wl-yt0x19 -Wl-yo4 -Wm-yn"$(PROJECTNAME)"
19 LCCFLAGS_pocket = -Wl-yt0x19 -Wl-yo4 -Wm-yn"$(PROJECTNAME)"
20 LCCFLAGS_duck = -Wl-yt0x19 -Wl-yo4 -Wm-yn"$(PROJECTNAME)"
21 LCCFLAGS_sms = -Wl-yo4
22 LCCFLAGS_gg = -Wl-yo4
23 LCCFLAGS_nes =
24
25 LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
26
27 LCCFLAGS += -Wl-j -Wm-yoA -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
28
29 # GBDK_DEBUG = ON
30 ifdef GBDK_DEBUG
31 LCCFLAGS += -debug -v
32 endif
33
34 CFLAGS = -Wf-Iinclude
35
36 # Add directory where platform specific meta tile sprites get converted into (obj/<platform ext>/src)
37 # So they can be included with "#include <res/somefile.h>"
38 CFLAGS += -I$(OBJDIR) -I$(RESALLDIR)
39
40 # You can set the name of the ROM file here
41 PROJECTNAME = rledecompress
42
43 SRCDIR = src
44 OBJDIR = obj/$(EXT)
45 # In this example the converted output is the same on all platforms, and so shared for INCBIN() path simplicity
46 RESALLDIR = obj/all
47 RESDIR = res
48 BINDIR = build/$(EXT)
49 MKDIRS = $(OBJDIR) $(BINDIR) $(RESALLDIR) # See bottom of Makefile for directory auto-creation
50
51 BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
52
53 # For .png -> png2asset -> .bin -> gbcompress -> .c -> compile -> .o
54 # When exporting to .bin the single png input file gets split into _map.bin and _tiles.bin, etc output files along with a header file
55 PNGS = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
56
57 # In this example, only the Map is compressed and not the Tiles
58 #
59 # So there is one list of uncompressed Tiles from pngs
60 PNG_RAW_TILEBINS = $(PNGS:%.png=$(RESALLDIR)/%_tiles.bin) # tiles don't get compressed
61 #
62 # And another list of compressed Maps from the same pngs
63 PNG_RAW_MAPBINS = $(PNGS:%.png=$(RESALLDIR)/%_map.bin)
64 PNG_COMP_MAPBINS = $(PNG_RAW_MAPBINS:$(RESALLDIR)%_map.bin=$(RESALLDIR)%_map.bin.rle)
65
66
67 CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
68 ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
69 OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
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 # ===== Start png conversion and compression =====
80
81 # For .png -> png2asset -> .bin -> gbcompress -> .bin.rle
82
83 # Use png2asset to convert the png into binary blob files for compression
84 # All of the multiple targets (map, tiles) will get generated
85 # by the single prerequisite of the matching %.png
86 $(RESALLDIR)/%_tiles.bin $(RESALLDIR)/%_map.bin: $(RESDIR)/%.png
87 $(PNG2ASSET) $< -o $(subst _map,,$(subst _tiles,,$@)) -bin -use_metafile
88
89 # Then compress the binary files and output as .c files
90 # Generate a variable name for the compressed C output based on stripping the path and extension from the output filename
91 $(RESALLDIR)/%.bin.rle: $(RESALLDIR)/%.bin
92 $(GBCOMPRESS) --alg=rle -v $< $@
93
94 # ===== End png conversion and compression =====
95
96
97
98 # Compile .c files in "src/" to .o object files
99 $(OBJDIR)/%.o: $(SRCDIR)/%.c
100 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
101
102 # Compile .c files in "res/" to .o object files
103 $(OBJDIR)/%.o: $(RESDIR)/%.c
104 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
105
106 # Compile .s assembly files in "src/" to .o object files
107 $(OBJDIR)/%.o: $(SRCDIR)/%.s
108 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
109
110 # If needed, compile .c files in "src/" to .s assembly files
111 # (not required if .c is compiled directly to .o)
112 $(OBJDIR)/%.s: $(SRCDIR)/%.c
113 $(LCC) $(LCCFLAGS) $(CFLAGS) -S -o $@ $<
114
115
116 # Convert png images first so they're available when compiling the main sources
117 $(OBJS): $(PNG_RAW_TILEBINS) $(PNG_COMP_MAPBINS)
118
119 # Link the compiled object files into a .gb ROM file
120 $(BINS): $(OBJS)
121 $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
122
123 clean:
124 @echo Cleaning
125 @for target in $(TARGETS); do \
126 $(MAKE) $$target-clean; \
127 done
128
129 # Include available build targets
130 include Makefile.targets
131
132 # make -d to debug
133 # With builtin rules turned off for less noise:
134 # MAKEFLAGS += --no-builtin-rules
135
136
137 # create necessary directories after Makefile is parsed but before build
138 # info prevents the command from being pasted into the makefile
139 ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
140 $(info $(shell mkdir -p $(MKDIRS)))
141 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.