gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/gb/apa_image/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 LCC = $(GBDK_HOME)/bin/lcc
13 PNG2ASSET = $(GBDK_HOME)/bin/png2asset
14
15 # GBDK_DEBUG = ON
16 ifdef GBDK_DEBUG
17 LCCFLAGS += -debug -v
18 endif
19
20
21 # Add directory where image gets converted into (obj/)
22 # So they can be included with "#include <res/somefile.h>"
23 LCCFLAGS += -I$(OBJDIR)
24
25 # Make the ROM CGB compatible (but not exclusive)
26 LCCFLAGS += -Wm-yc
27
28 # You can set the name of the .gb ROM file here
29 PROJECTNAME = apa_image
30
31 SRCDIR = src
32 OBJDIR = obj
33 RESOBJSRC = obj/res
34 RESDIR = res
35 MKDIRS = $(OBJDIR) $(BINDIR) $(RESOBJSRC) # See bottom of Makefile for directory auto-creation
36
37 BINS = $(OBJDIR)/$(PROJECTNAME).gb
38
39 # For png2asset: converting source pngs -> .c -> .o
40 IMGPNGS = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
41 IMGSOURCES = $(IMGPNGS:%.png=$(RESOBJSRC)/%.c)
42 IMGOBJS = $(IMGSOURCES:$(RESOBJSRC)/%.c=$(OBJDIR)/%.o)
43
44 CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
45 ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
46 OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
47
48 all: $(BINS)
49
50 compile.bat: Makefile
51 @echo "REM Automatically generated from Makefile" > compile.bat
52 @make -sn | sed y/\\//\\\\/ | sed s/mkdir\ -p\/mkdir\/ | grep -v make >> compile.bat
53
54 # Use png2asset to convert the png into C formatted metasprite data
55 # -keep_duplicate_tiles : Don't remove duplicate tiles
56 # -map : Use "map style" output, not metasprite
57 # -tiles_only : Only keep tiles, no map (since APA mode expects tiles in linear order)
58 # -bpp 2 : Use 2bpp output
59 # -c ... : Set C output file
60 # Convert metasprite .pngs in res/ -> .c files in obj/<platform ext>/src/
61 $(RESOBJSRC)/%.c: $(RESDIR)/%.png
62 $(PNG2ASSET) $< -keep_duplicate_tiles -map -bpp 2 -tiles_only -c $@
63
64 # Compile the pngs that were converted to .c files
65 # .c files in obj/res/ -> .o files in obj/
66 $(OBJDIR)/%.o: $(RESOBJSRC)/%.c
67 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
68
69 # Compile .c files in "src/" to .o object files
70 $(OBJDIR)/%.o: $(SRCDIR)/%.c
71 $(LCC) $(LCCFLAGS) -c -o $@ $<
72
73 # Compile .c files in "res/" to .o object files
74 $(OBJDIR)/%.o: $(RESDIR)/%.c
75 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
76
77 # Compile .s assembly files in "src/" to .o object files
78 $(OBJDIR)/%.o: $(SRCDIR)/%.s
79 $(LCC) $(LCCFLAGS) -c -o $@ $<
80
81 # If needed, compile .c files in "src/" to .s assembly files
82 # (not required if .c is compiled directly to .o)
83 $(OBJDIR)/%.s: $(SRCDIR)/%.c
84 $(LCC) $(LCCFLAGS) -S -o $@ $<
85
86 # Convert images first so they're available when compiling the main sources
87 $(OBJS): $(IMGOBJS)
88
89 # Link the compiled object files into a .gb ROM file
90 $(BINS): $(OBJS)
91 $(LCC) $(LCCFLAGS) -o $(BINS) $(IMGOBJS) $(OBJS)
92
93 clean:
94 rm -f $(OBJDIR)/*.*
95 rm -f $(RESOBJSRC)/*.*
96
97
98 # create necessary directories after Makefile is parsed but before build
99 # info prevents the command from being pasted into the makefile
100 $(info $(shell mkdir -p $(MKDIRS)))
101
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.