2023-11-12 00:20:09 +00:00
|
|
|
# GBA rom header
|
|
|
|
TITLE := POKEMON EMER
|
|
|
|
GAME_CODE := BPEE
|
|
|
|
MAKER_CODE := 01
|
|
|
|
REVISION := 0
|
|
|
|
MODERN ?= 0
|
2024-09-14 03:38:50 +00:00
|
|
|
KEEP_TEMPS ?= 0
|
2023-11-12 00:20:09 +00:00
|
|
|
|
|
|
|
# `File name`.gba ('_modern' will be appended to the modern builds)
|
|
|
|
FILE_NAME := pokeemerald
|
|
|
|
BUILD_DIR := build
|
2019-08-06 23:30:57 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Builds the ROM using a modern compiler
|
|
|
|
MODERN ?= 0
|
|
|
|
# Compares the ROM to a checksum of the original - only makes sense using when non-modern
|
|
|
|
COMPARE ?= 0
|
|
|
|
|
|
|
|
ifeq (modern,$(MAKECMDGOALS))
|
|
|
|
MODERN := 1
|
|
|
|
endif
|
2021-06-02 00:40:11 +00:00
|
|
|
ifeq (compare,$(MAKECMDGOALS))
|
|
|
|
COMPARE := 1
|
|
|
|
endif
|
|
|
|
|
2023-11-11 09:51:04 +00:00
|
|
|
# Default make rule
|
|
|
|
all: rom
|
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Toolchain selection
|
|
|
|
TOOLCHAIN := $(DEVKITARM)
|
2020-12-17 02:24:44 +00:00
|
|
|
# don't use dkP's base_tools anymore
|
|
|
|
# because the redefinition of $(CC) conflicts
|
|
|
|
# with when we want to use $(CC) to preprocess files
|
|
|
|
# thus, manually create the variables for the bin
|
|
|
|
# files, or use arm-none-eabi binaries on the system
|
2021-01-04 16:35:59 +00:00
|
|
|
# if dkP is not installed on this system
|
2020-12-17 02:24:44 +00:00
|
|
|
ifneq (,$(TOOLCHAIN))
|
2023-11-12 00:20:09 +00:00
|
|
|
ifneq ($(wildcard $(TOOLCHAIN)/bin),)
|
|
|
|
export PATH := $(TOOLCHAIN)/bin:$(PATH)
|
|
|
|
endif
|
2020-12-17 00:54:12 +00:00
|
|
|
endif
|
2019-08-06 23:30:57 +00:00
|
|
|
|
2019-07-24 14:38:48 +00:00
|
|
|
PREFIX := arm-none-eabi-
|
2019-06-29 02:26:11 +00:00
|
|
|
OBJCOPY := $(PREFIX)objcopy
|
2021-06-16 15:03:23 +00:00
|
|
|
OBJDUMP := $(PREFIX)objdump
|
2020-12-17 02:24:44 +00:00
|
|
|
AS := $(PREFIX)as
|
|
|
|
LD := $(PREFIX)ld
|
|
|
|
|
2018-09-23 00:56:17 +00:00
|
|
|
EXE :=
|
2023-11-12 00:20:09 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
EXE := .exe
|
2021-06-02 00:40:11 +00:00
|
|
|
endif
|
|
|
|
|
2021-01-04 16:35:59 +00:00
|
|
|
# use arm-none-eabi-cpp for macOS
|
|
|
|
# as macOS's default compiler is clang
|
|
|
|
# and clang's preprocessor will warn on \u
|
|
|
|
# when preprocessing asm files, expecting a unicode literal
|
|
|
|
# we can't unconditionally use arm-none-eabi-cpp
|
|
|
|
# as installations which install binutils-arm-none-eabi
|
|
|
|
# don't come with it
|
2020-12-17 02:24:44 +00:00
|
|
|
ifneq ($(MODERN),1)
|
2021-01-04 16:35:59 +00:00
|
|
|
ifeq ($(shell uname -s),Darwin)
|
|
|
|
CPP := $(PREFIX)cpp
|
|
|
|
else
|
|
|
|
CPP := $(CC) -E
|
|
|
|
endif
|
2020-12-17 02:24:44 +00:00
|
|
|
else
|
2021-01-04 16:35:59 +00:00
|
|
|
CPP := $(PREFIX)cpp
|
2020-12-17 02:24:44 +00:00
|
|
|
endif
|
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
ROM_NAME := $(FILE_NAME).gba
|
|
|
|
OBJ_DIR_NAME := $(BUILD_DIR)/emerald
|
|
|
|
MODERN_ROM_NAME := $(FILE_NAME)_modern.gba
|
|
|
|
MODERN_OBJ_DIR_NAME := $(BUILD_DIR)/modern
|
|
|
|
|
2020-12-17 02:24:44 +00:00
|
|
|
ELF_NAME := $(ROM_NAME:.gba=.elf)
|
|
|
|
MAP_NAME := $(ROM_NAME:.gba=.map)
|
|
|
|
MODERN_ELF_NAME := $(MODERN_ROM_NAME:.gba=.elf)
|
|
|
|
MODERN_MAP_NAME := $(MODERN_ROM_NAME:.gba=.map)
|
2016-11-01 18:35:16 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Pick our active variables
|
|
|
|
ifeq ($(MODERN),0)
|
|
|
|
ROM := $(ROM_NAME)
|
|
|
|
OBJ_DIR := $(OBJ_DIR_NAME)
|
|
|
|
else
|
|
|
|
ROM := $(MODERN_ROM_NAME)
|
|
|
|
OBJ_DIR := $(MODERN_OBJ_DIR_NAME)
|
|
|
|
endif
|
|
|
|
ELF := $(ROM:.gba=.elf)
|
|
|
|
MAP := $(ROM:.gba=.map)
|
|
|
|
SYM := $(ROM:.gba=.sym)
|
2017-10-11 02:28:32 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Commonly used directories
|
2017-10-11 02:28:32 +00:00
|
|
|
C_SUBDIR = src
|
|
|
|
ASM_SUBDIR = asm
|
2019-04-28 17:12:26 +00:00
|
|
|
DATA_SRC_SUBDIR = src/data
|
2017-10-11 02:28:32 +00:00
|
|
|
DATA_ASM_SUBDIR = data
|
2017-12-21 22:24:11 +00:00
|
|
|
SONG_SUBDIR = sound/songs
|
2018-09-23 00:56:17 +00:00
|
|
|
MID_SUBDIR = sound/songs/midi
|
2017-10-11 02:28:32 +00:00
|
|
|
|
|
|
|
C_BUILDDIR = $(OBJ_DIR)/$(C_SUBDIR)
|
|
|
|
ASM_BUILDDIR = $(OBJ_DIR)/$(ASM_SUBDIR)
|
|
|
|
DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR)
|
2017-12-21 22:24:11 +00:00
|
|
|
SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR)
|
2018-09-23 00:56:17 +00:00
|
|
|
MID_BUILDDIR = $(OBJ_DIR)/$(MID_SUBDIR)
|
2017-10-11 02:28:32 +00:00
|
|
|
|
2024-08-31 04:10:55 +00:00
|
|
|
SHELL := bash -o pipefail
|
2023-11-12 00:20:09 +00:00
|
|
|
|
|
|
|
# Set flags for tools
|
2019-06-26 12:13:38 +00:00
|
|
|
ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN)
|
2016-01-07 08:45:06 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
INCLUDE_DIRS := include
|
|
|
|
INCLUDE_CPP_ARGS := $(INCLUDE_DIRS:%=-iquote %)
|
|
|
|
INCLUDE_SCANINC_ARGS := $(INCLUDE_DIRS:%=-I %)
|
|
|
|
|
|
|
|
O_LEVEL ?= 2
|
2024-09-18 14:37:34 +00:00
|
|
|
CPPFLAGS := $(INCLUDE_CPP_ARGS) -Wno-trigraphs -DMODERN=$(MODERN)
|
2019-06-26 12:13:38 +00:00
|
|
|
ifeq ($(MODERN),0)
|
2023-11-12 00:20:09 +00:00
|
|
|
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef
|
|
|
|
CC1 := tools/agbcc/bin/agbcc$(EXE)
|
|
|
|
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O$(O_LEVEL) -fhex-asm -g
|
|
|
|
LIBPATH := -L ../../tools/agbcc/lib
|
|
|
|
LIB := $(LIBPATH) -lgcc -lc -L../../libagbsyscall -lagbsyscall
|
2019-06-26 12:13:38 +00:00
|
|
|
else
|
2023-11-12 00:20:09 +00:00
|
|
|
# Note: The makefile must be set up to not call these if modern == 0
|
|
|
|
MODERNCC := $(PREFIX)gcc
|
|
|
|
PATH_MODERNCC := PATH="$(PATH)" $(MODERNCC)
|
|
|
|
CC1 := $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet
|
|
|
|
override CFLAGS += -mthumb -mthumb-interwork -O$(O_LEVEL) -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
|
|
|
|
LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libnosys.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libc.a))"
|
|
|
|
LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall
|
2019-06-29 02:26:11 +00:00
|
|
|
endif
|
2023-11-12 00:20:09 +00:00
|
|
|
# Enable debug info if set
|
|
|
|
ifeq ($(DINFO),1)
|
|
|
|
override CFLAGS += -g
|
2019-06-29 02:26:11 +00:00
|
|
|
endif
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Variable filled out in other make files
|
2023-11-11 09:51:04 +00:00
|
|
|
AUTO_GEN_TARGETS :=
|
|
|
|
include make_tools.mk
|
2023-11-12 00:20:09 +00:00
|
|
|
# Tool executables
|
2023-11-11 09:51:04 +00:00
|
|
|
GFX := $(TOOLS_DIR)/gbagfx/gbagfx$(EXE)
|
|
|
|
AIF := $(TOOLS_DIR)/aif2pcm/aif2pcm$(EXE)
|
|
|
|
MID := $(TOOLS_DIR)/mid2agb/mid2agb$(EXE)
|
|
|
|
SCANINC := $(TOOLS_DIR)/scaninc/scaninc$(EXE)
|
|
|
|
PREPROC := $(TOOLS_DIR)/preproc/preproc$(EXE)
|
|
|
|
RAMSCRGEN := $(TOOLS_DIR)/ramscrgen/ramscrgen$(EXE)
|
|
|
|
FIX := $(TOOLS_DIR)/gbafix/gbafix$(EXE)
|
|
|
|
MAPJSON := $(TOOLS_DIR)/mapjson/mapjson$(EXE)
|
|
|
|
JSONPROC := $(TOOLS_DIR)/jsonproc/jsonproc$(EXE)
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2021-06-16 18:43:35 +00:00
|
|
|
PERL := perl
|
2023-11-12 00:20:09 +00:00
|
|
|
SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c
|
2021-06-16 18:43:35 +00:00
|
|
|
|
2019-07-23 20:17:00 +00:00
|
|
|
MAKEFLAGS += --no-print-directory
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2018-01-13 06:30:08 +00:00
|
|
|
# Clear the default suffixes
|
2015-11-14 05:57:22 +00:00
|
|
|
.SUFFIXES:
|
2018-01-13 06:30:43 +00:00
|
|
|
# Don't delete intermediate files
|
|
|
|
.SECONDARY:
|
2018-01-13 06:30:08 +00:00
|
|
|
# Delete files that weren't built properly
|
|
|
|
.DELETE_ON_ERROR:
|
2015-11-14 05:57:22 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
RULES_NO_SCAN += libagbsyscall clean clean-assets tidy tidymodern tidynonmodern generated clean-generated
|
|
|
|
.PHONY: all rom modern compare
|
|
|
|
.PHONY: $(RULES_NO_SCAN)
|
2019-07-23 20:17:00 +00:00
|
|
|
|
|
|
|
infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
|
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Check if we need to scan dependencies based on the chosen rule OR user preference
|
|
|
|
NODEP ?= 0
|
|
|
|
# Check if we need to pre-build tools and generate assets based on the chosen rule.
|
|
|
|
SETUP_PREREQS ?= 1
|
|
|
|
# Disable dependency scanning for rules that don't need it.
|
|
|
|
ifneq (,$(MAKECMDGOALS))
|
|
|
|
ifeq (,$(filter-out $(RULES_NO_SCAN),$(MAKECMDGOALS)))
|
|
|
|
NODEP := 1
|
|
|
|
SETUP_PREREQS := 0
|
|
|
|
endif
|
2019-07-23 20:17:00 +00:00
|
|
|
endif
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2024-10-15 03:52:11 +00:00
|
|
|
.SHELLSTATUS ?= 0
|
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
ifeq ($(SETUP_PREREQS),1)
|
|
|
|
# If set on: Default target or a rule requiring a scan
|
|
|
|
# Forcibly execute `make tools` since we need them for what we are doing.
|
2024-10-15 03:52:11 +00:00
|
|
|
$(foreach line, $(shell $(MAKE) -f make_tools.mk | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
|
|
|
|
ifneq ($(.SHELLSTATUS),0)
|
|
|
|
$(error Errors occurred while building tools. See error messages above for more details)
|
|
|
|
endif
|
2023-11-12 00:20:09 +00:00
|
|
|
# Oh and also generate mapjson sources before we use `SCANINC`.
|
2024-10-15 03:52:11 +00:00
|
|
|
$(foreach line, $(shell $(MAKE) generated | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
|
|
|
|
ifneq ($(.SHELLSTATUS),0)
|
|
|
|
$(error Errors occurred while generating map-related sources. See error messages above for more details)
|
|
|
|
endif
|
2019-07-23 20:17:00 +00:00
|
|
|
endif
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Collect sources
|
2019-09-04 19:11:57 +00:00
|
|
|
C_SRCS_IN := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c)
|
|
|
|
C_SRCS := $(foreach src,$(C_SRCS_IN),$(if $(findstring .inc.c,$(src)),,$(src)))
|
2017-10-11 02:28:32 +00:00
|
|
|
C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS))
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
C_ASM_SRCS := $(wildcard $(C_SUBDIR)/*.s $(C_SUBDIR)/*/*.s $(C_SUBDIR)/*/*/*.s)
|
2019-08-06 18:08:13 +00:00
|
|
|
C_ASM_OBJS := $(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o,$(C_ASM_SRCS))
|
|
|
|
|
2017-10-11 02:28:32 +00:00
|
|
|
ASM_SRCS := $(wildcard $(ASM_SUBDIR)/*.s)
|
|
|
|
ASM_OBJS := $(patsubst $(ASM_SUBDIR)/%.s,$(ASM_BUILDDIR)/%.o,$(ASM_SRCS))
|
2016-11-01 15:29:13 +00:00
|
|
|
|
2020-11-12 16:04:38 +00:00
|
|
|
# get all the data/*.s files EXCEPT the ones with specific rules
|
2020-11-19 01:53:42 +00:00
|
|
|
REGULAR_DATA_ASM_SRCS := $(filter-out $(DATA_ASM_SUBDIR)/maps.s $(DATA_ASM_SUBDIR)/map_events.s, $(wildcard $(DATA_ASM_SUBDIR)/*.s))
|
2020-11-12 16:04:38 +00:00
|
|
|
|
2017-10-11 02:28:32 +00:00
|
|
|
DATA_ASM_SRCS := $(wildcard $(DATA_ASM_SUBDIR)/*.s)
|
|
|
|
DATA_ASM_OBJS := $(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o,$(DATA_ASM_SRCS))
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2017-12-21 22:24:11 +00:00
|
|
|
SONG_SRCS := $(wildcard $(SONG_SUBDIR)/*.s)
|
|
|
|
SONG_OBJS := $(patsubst $(SONG_SUBDIR)/%.s,$(SONG_BUILDDIR)/%.o,$(SONG_SRCS))
|
|
|
|
|
2018-09-23 00:56:17 +00:00
|
|
|
MID_SRCS := $(wildcard $(MID_SUBDIR)/*.mid)
|
|
|
|
MID_OBJS := $(patsubst $(MID_SUBDIR)/%.mid,$(MID_BUILDDIR)/%.o,$(MID_SRCS))
|
|
|
|
|
2024-09-18 14:37:34 +00:00
|
|
|
OBJS := $(C_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $(SONG_OBJS) $(MID_OBJS)
|
2017-10-11 02:28:32 +00:00
|
|
|
OBJS_REL := $(patsubst $(OBJ_DIR)/%,%,$(OBJS))
|
2015-11-14 05:57:22 +00:00
|
|
|
|
2018-11-14 22:59:30 +00:00
|
|
|
SUBDIRS := $(sort $(dir $(OBJS)))
|
2021-06-02 00:40:11 +00:00
|
|
|
$(shell mkdir -p $(SUBDIRS))
|
2018-11-14 22:59:30 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Pretend rules that are actually flags defer to `make all`
|
|
|
|
modern: all
|
|
|
|
compare: all
|
2021-06-16 15:03:23 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Other rules
|
2019-09-09 01:26:46 +00:00
|
|
|
rom: $(ROM)
|
2019-09-03 19:33:11 +00:00
|
|
|
ifeq ($(COMPARE),1)
|
|
|
|
@$(SHA1) rom.sha1
|
|
|
|
endif
|
2015-11-14 05:57:22 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
syms: $(SYM)
|
2015-11-14 05:57:22 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
clean: tidy clean-tools clean-generated clean-assets
|
|
|
|
@$(MAKE) clean -C libagbsyscall
|
2019-07-20 00:54:02 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
clean-assets:
|
2019-06-29 22:32:04 +00:00
|
|
|
rm -f $(MID_SUBDIR)/*.s
|
2019-01-31 21:51:20 +00:00
|
|
|
rm -f $(DATA_ASM_SUBDIR)/layouts/layouts.inc $(DATA_ASM_SUBDIR)/layouts/layouts_table.inc
|
|
|
|
rm -f $(DATA_ASM_SUBDIR)/maps/connections.inc $(DATA_ASM_SUBDIR)/maps/events.inc $(DATA_ASM_SUBDIR)/maps/groups.inc $(DATA_ASM_SUBDIR)/maps/headers.inc
|
2023-11-12 00:20:09 +00:00
|
|
|
find sound -iname '*.bin' -exec rm {} +
|
|
|
|
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.rl' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
|
2019-01-31 21:51:20 +00:00
|
|
|
find $(DATA_ASM_SUBDIR)/maps \( -iname 'connections.inc' -o -iname 'events.inc' -o -iname 'header.inc' \) -exec rm {} +
|
2015-11-14 05:57:22 +00:00
|
|
|
|
2021-05-05 20:07:21 +00:00
|
|
|
tidy: tidynonmodern tidymodern
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2020-12-17 02:24:44 +00:00
|
|
|
tidynonmodern:
|
|
|
|
rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME)
|
|
|
|
rm -rf $(OBJ_DIR_NAME)
|
|
|
|
|
|
|
|
tidymodern:
|
|
|
|
rm -f $(MODERN_ROM_NAME) $(MODERN_ELF_NAME) $(MODERN_MAP_NAME)
|
|
|
|
rm -rf $(MODERN_OBJ_DIR_NAME)
|
2022-09-11 18:14:49 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Other rules
|
2015-11-14 05:57:22 +00:00
|
|
|
include graphics_file_rules.mk
|
2019-01-31 21:51:20 +00:00
|
|
|
include map_data_rules.mk
|
2018-09-11 22:18:10 +00:00
|
|
|
include spritesheet_rules.mk
|
2019-04-28 17:12:26 +00:00
|
|
|
include json_data_rules.mk
|
2023-11-15 00:36:35 +00:00
|
|
|
include audio_rules.mk
|
2015-11-14 05:57:22 +00:00
|
|
|
|
2024-10-15 03:52:11 +00:00
|
|
|
# NOTE: Tools must have been built prior (FIXME)
|
|
|
|
# so you can't really call this rule directly
|
2024-08-29 18:01:01 +00:00
|
|
|
generated: $(AUTO_GEN_TARGETS)
|
2024-11-03 22:53:53 +00:00
|
|
|
@: # Silence the "Nothing to be done for `generated'" message, which some people were confusing for an error.
|
|
|
|
|
2024-08-29 18:01:01 +00:00
|
|
|
|
2024-09-14 03:38:50 +00:00
|
|
|
%.s: ;
|
2015-11-14 05:57:22 +00:00
|
|
|
%.png: ;
|
|
|
|
%.pal: ;
|
2017-12-28 08:09:11 +00:00
|
|
|
%.aif: ;
|
|
|
|
|
2024-09-14 03:38:50 +00:00
|
|
|
%.1bpp: %.png ; $(GFX) $< $@
|
|
|
|
%.4bpp: %.png ; $(GFX) $< $@
|
|
|
|
%.8bpp: %.png ; $(GFX) $< $@
|
|
|
|
%.gbapal: %.pal ; $(GFX) $< $@
|
|
|
|
%.gbapal: %.png ; $(GFX) $< $@
|
|
|
|
%.lz: % ; $(GFX) $< $@
|
|
|
|
%.rl: % ; $(GFX) $< $@
|
2016-01-07 08:45:06 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
clean-generated:
|
|
|
|
-rm -f $(AUTO_GEN_TARGETS)
|
2019-01-31 21:51:20 +00:00
|
|
|
|
2019-06-26 12:13:38 +00:00
|
|
|
ifeq ($(MODERN),0)
|
2024-08-29 18:01:01 +00:00
|
|
|
$(C_BUILDDIR)/libc.o: CC1 := $(TOOLS_DIR)/agbcc/bin/old_agbcc$(EXE)
|
2017-10-11 02:28:32 +00:00
|
|
|
$(C_BUILDDIR)/libc.o: CFLAGS := -O2
|
|
|
|
$(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork
|
|
|
|
$(C_BUILDDIR)/agb_flash.o: CFLAGS := -O -mthumb-interwork
|
|
|
|
$(C_BUILDDIR)/agb_flash_1m.o: CFLAGS := -O -mthumb-interwork
|
|
|
|
$(C_BUILDDIR)/agb_flash_mx.o: CFLAGS := -O -mthumb-interwork
|
2023-11-12 00:20:09 +00:00
|
|
|
$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
|
2017-11-04 01:56:18 +00:00
|
|
|
$(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding
|
2024-08-29 18:01:01 +00:00
|
|
|
$(C_BUILDDIR)/librfu_intr.o: CC1 := $(TOOLS_DIR)/agbcc/bin/agbcc_arm$(EXE)
|
2020-02-16 18:49:36 +00:00
|
|
|
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -O2 -mthumb-interwork -quiet
|
|
|
|
else
|
2020-05-09 12:49:51 +00:00
|
|
|
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
|
2023-11-12 00:20:09 +00:00
|
|
|
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
|
2019-06-26 12:13:38 +00:00
|
|
|
endif
|
2017-11-04 01:56:18 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Dependency rules (for the *.c & *.s sources to .o files)
|
|
|
|
# Have to be explicit or else missing files won't be reported.
|
2019-01-06 13:01:22 +00:00
|
|
|
|
2021-05-04 14:08:54 +00:00
|
|
|
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
|
2023-11-12 00:20:09 +00:00
|
|
|
# It doesn't look like $(shell) can be deferred so there might not be a better way (Icedude_907: there is soon).
|
2021-05-04 14:08:54 +00:00
|
|
|
|
2024-10-15 03:47:07 +00:00
|
|
|
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c
|
2024-09-14 03:38:50 +00:00
|
|
|
ifneq ($(KEEP_TEMPS),1)
|
2024-10-15 03:47:07 +00:00
|
|
|
@echo "$(CC1) <flags> -o $@ $<"
|
|
|
|
@$(CPP) $(CPPFLAGS) $< | $(PREPROC) -i $< charmap.txt | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ -
|
2021-05-04 14:08:54 +00:00
|
|
|
else
|
2024-10-15 03:47:07 +00:00
|
|
|
@$(CPP) $(CPPFLAGS) $< -o $*.i
|
|
|
|
@$(PREPROC) $*.i charmap.txt | $(CC1) $(CFLAGS) -o $*.s
|
|
|
|
@echo -e ".text\n\t.align\t2, 0\n" >> $*.s
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $*.s
|
2021-05-04 14:08:54 +00:00
|
|
|
endif
|
2024-10-15 03:47:07 +00:00
|
|
|
|
|
|
|
$(C_BUILDDIR)/%.d: $(C_SUBDIR)/%.c
|
|
|
|
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $<
|
|
|
|
|
2024-10-11 18:33:32 +00:00
|
|
|
ifneq ($(NODEP),1)
|
2024-10-15 03:47:07 +00:00
|
|
|
-include $(addprefix $(OBJ_DIR)/,$(C_SRCS:.c=.d))
|
2019-08-06 18:08:13 +00:00
|
|
|
endif
|
2019-09-09 01:07:54 +00:00
|
|
|
|
2024-10-15 03:47:07 +00:00
|
|
|
$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
$(ASM_BUILDDIR)/%.d: $(ASM_SUBDIR)/%.s
|
|
|
|
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $<
|
|
|
|
|
|
|
|
ifneq ($(NODEP),1)
|
|
|
|
-include $(addprefix $(OBJ_DIR)/,$(ASM_SRCS:.s=.d))
|
2019-08-06 18:08:13 +00:00
|
|
|
endif
|
|
|
|
|
2024-10-15 03:47:07 +00:00
|
|
|
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s
|
|
|
|
$(PREPROC) $< charmap.txt | $(CPP) $(INCLUDE_SCANINC_ARGS) - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@
|
|
|
|
|
|
|
|
$(C_BUILDDIR)/%.d: $(C_SUBDIR)/%.s
|
|
|
|
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $<
|
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
ifneq ($(NODEP),1)
|
2024-10-15 03:47:07 +00:00
|
|
|
-include $(addprefix $(OBJ_DIR)/,$(C_ASM_SRCS:.s=.d))
|
2017-10-11 02:28:32 +00:00
|
|
|
endif
|
|
|
|
|
2024-10-15 03:47:07 +00:00
|
|
|
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s
|
|
|
|
$(PREPROC) $< charmap.txt | $(CPP) $(INCLUDE_SCANINC_ARGS) - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@
|
|
|
|
|
|
|
|
$(DATA_ASM_BUILDDIR)/%.d: $(DATA_ASM_SUBDIR)/%.s
|
|
|
|
$(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $<
|
|
|
|
|
|
|
|
ifneq ($(NODEP),1)
|
|
|
|
-include $(addprefix $(OBJ_DIR)/,$(REGULAR_DATA_ASM_SRCS:.s=.d))
|
2020-11-12 16:04:38 +00:00
|
|
|
endif
|
2016-09-03 08:11:14 +00:00
|
|
|
|
2017-10-11 02:28:32 +00:00
|
|
|
$(OBJ_DIR)/sym_bss.ld: sym_bss.txt
|
|
|
|
$(RAMSCRGEN) .bss $< ENGLISH > $@
|
2016-11-01 18:35:16 +00:00
|
|
|
|
2017-10-11 02:28:32 +00:00
|
|
|
$(OBJ_DIR)/sym_common.ld: sym_common.txt $(C_OBJS) $(wildcard common_syms/*.txt)
|
|
|
|
$(RAMSCRGEN) COMMON $< ENGLISH -c $(C_BUILDDIR),common_syms > $@
|
2016-11-01 18:35:16 +00:00
|
|
|
|
2017-10-11 02:28:32 +00:00
|
|
|
$(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt
|
|
|
|
$(RAMSCRGEN) ewram_data $< ENGLISH > $@
|
2016-11-01 18:35:16 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Linker script
|
2019-06-27 00:12:40 +00:00
|
|
|
ifeq ($(MODERN),0)
|
2023-11-12 02:19:50 +00:00
|
|
|
LD_SCRIPT := ld_script.ld
|
2019-06-29 12:35:52 +00:00
|
|
|
LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
|
2019-06-27 00:12:40 +00:00
|
|
|
else
|
2023-11-12 02:19:50 +00:00
|
|
|
LD_SCRIPT := ld_script_modern.ld
|
2022-09-11 18:14:49 +00:00
|
|
|
LD_SCRIPT_DEPS :=
|
2019-06-27 00:12:40 +00:00
|
|
|
endif
|
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Final rules
|
|
|
|
|
|
|
|
libagbsyscall:
|
|
|
|
@$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN)
|
2016-11-01 18:35:16 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Elf from object files
|
2024-09-12 17:50:47 +00:00
|
|
|
$(ELF): $(LD_SCRIPT) $(LD_SCRIPT_DEPS) $(OBJS) libagbsyscall
|
|
|
|
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ $(OBJS_REL) $(LIB) | cat
|
2024-10-15 03:52:11 +00:00
|
|
|
@echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ <objs> <libs> | cat"
|
2019-06-29 15:41:26 +00:00
|
|
|
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
|
2016-11-01 18:35:16 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Builds the rom from the elf file
|
2017-10-11 02:28:32 +00:00
|
|
|
$(ROM): $(ELF)
|
2018-08-29 21:34:59 +00:00
|
|
|
$(OBJCOPY) -O binary $< $@
|
2019-07-20 16:00:45 +00:00
|
|
|
$(FIX) $@ -p --silent
|
2019-06-26 12:13:38 +00:00
|
|
|
|
2023-11-12 00:20:09 +00:00
|
|
|
# Symbol file (`make syms`)
|
2021-06-16 15:03:23 +00:00
|
|
|
$(SYM): $(ELF)
|
2021-06-18 16:53:15 +00:00
|
|
|
$(OBJDUMP) -t $< | sort -u | grep -E "^0[2389]" | $(PERL) -p -e 's/^(\w{8}) (\w).{6} \S+\t(\w{8}) (\S+)$$/\1 \2 \3 \4/g' > $@
|