gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/cross-platform/gbprinter/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 megaduck gg
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 # GBDK_DEBUG = ON
29 ifdef GBDK_DEBUG
30 LCCFLAGS += -debug -v
31 endif
32
33
34 # You can set the name of the ROM file here
35 PROJECTNAME = GBPrinter
36
37 CFLAGS = -Wf-MMD -Wf-Wp-MP # Header file dependency output (-MMD) for Makefile use + per-header Phoney rules (-MP)
38
39 # EXT?=gb # Only sets extension to default (game boy .gb) if not populated
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 CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
49 ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
50 OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
51
52 # For png2asset: converting map source pngs -> .c -> .o
53 MAPPNGS = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
54 MAPSRCS = $(MAPPNGS:%.png=$(RESOBJSRC)/%.c)
55 MAPOBJS = $(MAPSRCS:$(RESOBJSRC)/%.c=$(OBJDIR)/%.o)
56
57 .PRECIOUS: $(MAPSRCS)
58
59 CFLAGS += -I$(OBJDIR)
60
61 # Builds all targets sequentially
62 all: $(TARGETS)
63
64 compile.bat: Makefile
65 @echo "REM Automatically generated from Makefile" > compile.bat
66 @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
67
68
69 # Use png2asset to convert the png into C formatted map data
70 # -c ... : Set C output file
71 # Convert metasprite .pngs in res/ -> .c files in obj/<platform ext>/src/
72 $(RESOBJSRC)/%.c: $(RESDIR)/%.png
73 $(PNG2ASSET) $< -map -bpp 2 -max_palettes 4 -pack_mode gb -noflip -c $@
74
75 # Compile the map pngs that were converted to .c files
76 # .c files in obj/<platform ext>/src/ -> .o files in obj/
77 $(OBJDIR)/%.o: $(RESOBJSRC)/%.c
78 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
79
80 # Dependencies (using output from -Wf-MMD -Wf-Wp-MP)
81 DEPS = $(OBJS:%.o=%.d)
82
83 -include $(DEPS)
84
85 # Compile .c files in "src/" to .o object files
86 $(OBJDIR)/%.o: $(SRCDIR)/%.c
87 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
88
89 # Compile .c files in "res/" to .o object files
90 $(OBJDIR)/%.o: $(RESDIR)/%.c
91 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
92
93 # Compile .s assembly files in "src/" to .o object files
94 $(OBJDIR)/%.o: $(SRCDIR)/%.s
95 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
96
97 # If needed, compile .c files in "src/" to .s assembly files
98 # (not required if .c is compiled directly to .o)
99 $(OBJDIR)/%.s: $(SRCDIR)/%.c
100 $(LCC) $(LCCFLAGS) $(CFLAGS) -S -o $@ $<
101
102 # Convert and build maps first so they're available when compiling the main sources
103 $(OBJS): $(MAPOBJS)
104
105 # Link the compiled object files into a .gb ROM file
106 $(BINS): $(OBJS)
107 $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(MAPOBJS) $(OBJS)
108
109 clean:
110 @echo Cleaning
111 @for target in $(TARGETS); do \
112 $(MAKE) $$target-clean; \
113 done
114
115 # Include available build targets
116 include Makefile.targets
117
118
119 # create necessary directories after Makefile is parsed but before build
120 # info prevents the command from being pasted into the makefile
121 ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
122 $(info $(shell mkdir -p $(MKDIRS)))
123 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.