gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/examples/cross-platform/bcd/Makefile
1 SHELL := /bin/bash
2
3 # If you move this project you can change the directory
4 # to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/"
5 ifndef GBDK_HOME
6 GBDK_HOME = ../../../
7 endif
8
9 LCC = $(GBDK_HOME)/bin/lcc
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 megaduck sms gg nes
15
16 # Configure platform specific LCC flags here:
17 LCCFLAGS_gb = -Wl-yt0x1B # Set an MBC for banking (1B-ROM+MBC5+RAM+BATT)
18 LCCFLAGS_pocket = -Wl-yt0x1B # Usually the same as required for .gb
19 LCCFLAGS_duck = -Wl-yt0x1B # Usually the same as required for .gb
20 LCCFLAGS_gbc = -Wl-yt0x1B -Wm-yc # Same as .gb with: -Wm-yc (gb & gbc) or Wm-yC (gbc exclusive)
21 LCCFLAGS_sms =
22 LCCFLAGS_gg =
23 LCCFLAGS_nes =
24
25 LCCFLAGS += $(LCCFLAGS_$(EXT)) # This adds the current platform specific LCC Flags
26
27 LCCFLAGS += -Wl-j -Wm-yoA -Wm-ya4 -autobank -Wb-ext=.rel -Wb-v # MBC + Autobanking related flags
28
29 # GBDK_DEBUG = ON
30 ifdef GBDK_DEBUG
31 LCCFLAGS += -debug -v -Wl-u
32 endif
33
34
35 # You can set the name of the ROM file here
36 PROJECTNAME = bcd
37
38 # EXT?=gb # Only sets extension to default (game boy .gb) if not populated
39 SRCDIR = src
40 OBJDIR = obj/$(EXT)
41 RESDIR = res
42 BINDIR = build/$(EXT)
43 MKDIRS = $(OBJDIR) $(BINDIR) # See bottom of Makefile for directory auto-creation
44
45 BINS = $(OBJDIR)/$(PROJECTNAME).$(EXT)
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 OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o)
49
50 # Builds all targets sequentially
51 all: $(TARGETS)
52
53 compile.bat: Makefile
54 @echo "REM Automatically generated from Makefile" > compile.bat
55 @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat
56
57
58 # Compile .c files in "src/" to .o object files
59 $(OBJDIR)/%.o: $(SRCDIR)/%.c
60 $(eval BOFLAG = $(shell echo "$<" | sed -n 's/.*\.bo\([0-9]\+\).*/\-Wf-bo\1/p'))
61 # RAM bank flag is not supported for the NES, the other platforms can use it
62 ifneq ($(strip $(PLAT)),nes)
63 $(eval BAFLAG = $(shell echo "$<" | sed -n 's/.*\.ba\([0-9]\+\).*/\-Wf-ba\1/p'))
64 endif
65 $(LCC) $(LCCFLAGS) $(CFLAGS) $(BOFLAG) $(BAFLAG) -c -o $@ $<
66
67 # Compile .c files in "res/" to .o object files
68 $(OBJDIR)/%.o: $(RESDIR)/%.c
69 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
70
71 # Compile .s assembly files in "src/" to .o object files
72 $(OBJDIR)/%.o: $(SRCDIR)/%.s
73 $(LCC) $(LCCFLAGS) $(CFLAGS) -c -o $@ $<
74
75 # If needed, compile .c files in "src/" to .s assembly files
76 # (not required if .c is compiled directly to .o)
77 $(OBJDIR)/%.s: $(SRCDIR)/%.c
78 $(LCC) $(LCCFLAGS) $(CFLAGS) -S -o $@ $<
79
80 # Link the compiled object files into a .gb ROM file
81 $(BINS): $(OBJS)
82 $(LCC) $(LCCFLAGS) $(CFLAGS) -o $(BINDIR)/$(PROJECTNAME).$(EXT) $(OBJS)
83
84 clean:
85 @echo Cleaning
86 @for target in $(TARGETS); do \
87 $(MAKE) $$target-clean; \
88 done
89
90 # Include available build targets
91 include Makefile.targets
92
93
94 # create necessary directories after Makefile is parsed but before build
95 # info prevents the command from being pasted into the makefile
96 ifneq ($(strip $(EXT)),) # Only make the directories if EXT has been set by a target
97 $(info $(shell mkdir -p $(MKDIRS)))
98 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.