gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/cross-platform/simple_physics/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 pocket megaduck sms gg nes
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 = -autobank
21 LCCFLAGS_gg = -autobank
22 LCCFLAGS_nes =
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 # Add directory where platform specific meta tile sprites get converted into (obj/<platform ext>/src)
35 # So they can be included with "#include <res/somefile.h>"
36 CFLAGS += -I$(OBJDIR)
37
38 # You can set the name of the ROM file here
39 PROJECTNAME = physics
40
41 SRCDIR = src
42 OBJDIR = obj/$(EXT)
43 RESOBJSRC = obj/$(EXT)/res
44 RESDIR = res
45 BINDIR = build/$(EXT)
46 MKDIRS = $(OBJDIR) $(BINDIR) $(RESOBJSRC) # See bottom of Makefile for directory auto-creation
47
48 BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
49 # For png2asset: converting metasprite source pngs -> .c -> .o
50 METAPNGS = $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.png)))
51 METASRCS = $(METAPNGS:%.png=$(RESOBJSRC)/%.c)
52 METAOBJS = $(METASRCS:$(RESOBJSRC)/%.c=$(OBJDIR)/%.o)
53
54 CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c)))
55 ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s)))
56 OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
57
58
59 # Builds all targets sequentially
60 all: $(TARGETS)
61
62 compile.bat: Makefile
63 @echo "REM Automatically generated from Makefile" > compile.bat
64 @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
65
66
67 # Use png2asset to convert the png into C formatted metasprite data
68 # -sh 48 : Sets sprite height to 48 (width remains automatic)
69 # -spr8x16 : Use 8x16 hardware sprites
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) $< -sh 48 -spr8x8 -noflip -c $@
74
75 # Compile the Metasprite 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 # Compile .c files in "src/" to .o object files
81 $(OBJDIR)/%.o: $(SRCDIR)/%.c
82 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
83
84 # Compile .c files in "res/" to .o object files
85 $(OBJDIR)/%.o: $(RESDIR)/%.c
86 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
87
88 # Compile .s assembly files in "src/" to .o object files
89 $(OBJDIR)/%.o: $(SRCDIR)/%.s
90 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
91
92 # If needed, compile .c files in "src/" to .s assembly files
93 # (not required if .c is compiled directly to .o)
94 $(OBJDIR)/%.s: $(SRCDIR)/%.c
95 $(LCC) $(LCCFLAGS) $(CFLAGS) -S -o $@ $<
96
97 # Convert and build MetaSprites first so they're available when compiling the main sources
98 $(OBJS): $(METAOBJS)
99
100 # Link the compiled object files into a .gb ROM file
101 $(BINS): $(OBJS)
102 $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(METAOBJS) $(OBJS)
103
104 clean:
105 @echo Cleaning
106 @for target in $(TARGETS); do \
107 $(MAKE) $$target-clean; \
108 done
109
110 # Include available build targets
111 include Makefile.targets
112
113
114 # create necessary directories after Makefile is parsed but before build
115 # info prevents the command from being pasted into the makefile
116 ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
117 $(info $(shell mkdir -p $(MKDIRS)))
118 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.