gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/gb/hicolor/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
9 # You can set flags for LCC here
10 LCCFLAGS += -Wm-yC # GB Color required for Hi Color
11 LCCFLAGS += -Wf-MMD -Wf-Wp-MP # Header file dependency output (-MMD) for Makefile use + per-header Phoney rules (-MP)
12 LCCFLAGS += -Wl-yt0x19 # MBC5
13 LCCFLAGS += -autobank -Wb-v -Wb-ext=.rel # Auto-bank packing
14
15 # For testing only: randomize autobank assignment
16 # LCCFLAGS += -Wb-random -Wb-max=3 -Wb-v
17
18 # For Hi Color:
19 PNG2HICOLORGB = $(GBDK_HOME)/bin/png2hicolorgb
20 # Use conversion method type 1, Faster Adaptive attribute sizing for Left / Right side of screen, C source output
21 # Bank 255 for auto-banking
22 HICOLOR_FLAGS = --type=1 -L=1 -R=1 --csource --bank=255
23 # Add the object dir as an include dir since that's
24 # where the converted png source files will get generated
25 LCCFLAGS += -I$(OBJDIR) -I$(SRCDIR)
26
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 .gb ROM file here
35 PROJECTNAME = hicolor_pic
36
37 BINDIR = bin
38 SRCDIR = src
39 OBJDIR = obj
40 RESDIR = res
41 HICOLORDIR = $(RESDIR)/hicolor
42 MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
43
44
45 BINS = $(BINDIR)/$(PROJECTNAME).gbc
46 CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
47 ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
48
49 # For Hi Color:
50 # The HICOLORS entries should be first in the OBJS list so they get generated before anything which might depend on them
51 HICOLORS = $(foreach dir,$(HICOLORDIR),$(notdir $(wildcard $(dir)/*.png)))
52 HICOLOR_SRCS = $(HICOLORS:%.png=$(OBJDIR)/%.c)
53 OBJS = $(HICOLORS:%.png=$(OBJDIR)/%.o) $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
54
55 all: $(BINS)
56
57 # Dependencies (using output from -Wf-MMD -Wf-Wp-MP)
58 DEPS = $(OBJS:%.o=%.d)
59
60 -include $(DEPS)
61
62
63 # == Start Hi Color conversion ==
64
65 # Convert png images in res/hicolor to .c files (which incbin the generated .til/.map/.pal/.atr files)
66 # The resulting C files will get compiled to object files afterward
67 .SECONDEXPANSION:
68 $(OBJDIR)/%.c: $(HICOLORDIR)/%.png
69 $(PNG2HICOLORGB) $< $(HICOLOR_FLAGS) -o $@
70
71 # Prevent make from deleting intermediary generated hi-color C source files
72 .SECONDARY: $(HICOLOR_SRCS)
73
74 # Compile hicolor .c files in "obj/" to .o object files
75 $(OBJDIR)/%.o: $(OBJDIR)/%.c
76 $(LCC) $(LCCFLAGS) -c -o $@ $<
77
78 # == End Hi Color conversion ==
79
80
81 # Compile .c files in "src/" to .o object files
82 $(OBJDIR)/%.o: $(SRCDIR)/%.c
83 $(LCC) $(LCCFLAGS) -c -o $@ $<
84
85 # Compile .c files in "res/" to .o object files
86 $(OBJDIR)/%.o: $(RESDIR)/%.c
87 $(LCC) $(LCCFLAGS) -c -o $@ $<
88
89 # Compile .s assembly files in "src/" to .o object files
90 $(OBJDIR)/%.o: $(SRCDIR)/%.s
91 $(LCC) $(LCCFLAGS) -c -o $@ $<
92
93 # If needed, compile .c files in "src/" to .s assembly files
94 # (not required if .c is compiled directly to .o)
95 $(OBJDIR)/%.s: $(SRCDIR)/%.c
96 $(LCC) $(LCCFLAGS) -S -o $@ $<
97
98 # Link the compiled object files into a .gb ROM file
99 $(BINS): $(OBJS)
100 $(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS)
101
102
103 clean:
104 rm -f $(OBJDIR)/*.* $(BINDIR)/*.*
105
106 compile.bat: Makefile
107 @echo "REM Automatically generated from Makefile" > compile.bat
108 @make -sn | sed y/\\//\\\\/ | sed s/mkdir\ -p\/mkdir\/ | grep -v make >> compile.bat
109
110 # create necessary directories after Makefile is parsed but before build
111 # info prevents the command from being pasted into the makefile
112 $(info $(shell mkdir -p $(MKDIRS)))
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.