feat: start working on a PC port using Normmatt's code as a base.
This commit is contained in:
parent
47ddf11b8d
commit
95f351657c
351
Makefile
351
Makefile
@ -1,34 +1,13 @@
|
||||
TOOLCHAIN := $(DEVKITARM)
|
||||
COMPARE ?= 0
|
||||
|
||||
ifeq (compare,$(MAKECMDGOALS))
|
||||
COMPARE := 1
|
||||
endif
|
||||
|
||||
# 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
|
||||
# if dkP is not installed on this system
|
||||
|
||||
ifneq (,$(TOOLCHAIN))
|
||||
ifneq ($(wildcard $(TOOLCHAIN)/bin),)
|
||||
export PATH := $(TOOLCHAIN)/bin:$(PATH)
|
||||
endif
|
||||
endif
|
||||
|
||||
PREFIX := arm-none-eabi-
|
||||
PREFIX :=
|
||||
OBJCOPY := $(PREFIX)objcopy
|
||||
OBJDUMP := $(PREFIX)objdump
|
||||
CC := $(PREFIX)gcc
|
||||
AS := $(PREFIX)as
|
||||
|
||||
LD := $(PREFIX)ld
|
||||
SDL_DIR := /k/gba/pokeemerald-pc/SDL-1.2.15
|
||||
ASM_PSEUDO_OP_CONV := sed -e 's/\.4byte/\.int/g;s/\.2byte/\.short/g'
|
||||
|
||||
# note: the makefile must be set up so MODERNCC is never called
|
||||
# if MODERN=0
|
||||
MODERNCC := $(PREFIX)gcc
|
||||
PATH_MODERNCC := PATH=$(TOOLCHAIN)/bin:PATH $(MODERNCC)
|
||||
export CPP := $(PREFIX)cpp
|
||||
export LD := $(PREFIX)ld
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXE := .exe
|
||||
@ -36,91 +15,41 @@ else
|
||||
EXE :=
|
||||
endif
|
||||
|
||||
TITLE := POKEMON EMER
|
||||
GAME_CODE := BPEE
|
||||
MAKER_CODE := 01
|
||||
REVISION := 0
|
||||
MODERN ?= 0
|
||||
|
||||
ifeq (modern,$(MAKECMDGOALS))
|
||||
MODERN := 1
|
||||
endif
|
||||
|
||||
# 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
|
||||
ifneq ($(MODERN),1)
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
CPP := $(PREFIX)cpp
|
||||
else
|
||||
CPP := $(CC) -E
|
||||
endif
|
||||
else
|
||||
CPP := $(PREFIX)cpp
|
||||
endif
|
||||
|
||||
ROM_NAME := tumbledemerald.gba
|
||||
ELF_NAME := $(ROM_NAME:.gba=.elf)
|
||||
MAP_NAME := $(ROM_NAME:.gba=.map)
|
||||
OBJ_DIR_NAME := build/tumbled
|
||||
|
||||
MODERN_ROM_NAME := tumbledemerald_modern.gba
|
||||
MODERN_ELF_NAME := $(MODERN_ROM_NAME:.gba=.elf)
|
||||
MODERN_MAP_NAME := $(MODERN_ROM_NAME:.gba=.map)
|
||||
MODERN_OBJ_DIR_NAME := build/modern
|
||||
MODERN := 1
|
||||
|
||||
SHELL := /bin/bash -o pipefail
|
||||
|
||||
ELF = $(ROM:.gba=.elf)
|
||||
MAP = $(ROM:.gba=.map)
|
||||
SYM = $(ROM:.gba=.sym)
|
||||
|
||||
C_SUBDIR = src
|
||||
GFLIB_SUBDIR = gflib
|
||||
ASM_SUBDIR = asm
|
||||
DATA_SRC_SUBDIR = src/data
|
||||
DATA_ASM_SUBDIR = data
|
||||
SONG_SUBDIR = sound/songs
|
||||
MID_SUBDIR = sound/songs/midi
|
||||
SAMPLE_SUBDIR = sound/direct_sound_samples
|
||||
CRY_SUBDIR = sound/direct_sound_samples/cries
|
||||
|
||||
C_BUILDDIR = $(OBJ_DIR)/$(C_SUBDIR)
|
||||
GFLIB_BUILDDIR = $(OBJ_DIR)/$(GFLIB_SUBDIR)
|
||||
ASM_BUILDDIR = $(OBJ_DIR)/$(ASM_SUBDIR)
|
||||
DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR)
|
||||
SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR)
|
||||
MID_BUILDDIR = $(OBJ_DIR)/$(MID_SUBDIR)
|
||||
|
||||
ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN)
|
||||
ASFLAGS := --32 --defsym MODERN=$(MODERN) --defsym PORTABLE=1
|
||||
|
||||
ifeq ($(MODERN),0)
|
||||
CC1 := tools/agbcc/bin/agbcc$(EXE)
|
||||
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -g
|
||||
ROM := $(ROM_NAME)
|
||||
OBJ_DIR := $(OBJ_DIR_NAME)
|
||||
LIBPATH := -L ../../tools/agbcc/lib
|
||||
LIB := $(LIBPATH) -lgcc -lc -L../../libagbsyscall -lagbsyscall
|
||||
else
|
||||
CC1 = $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet
|
||||
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -g
|
||||
ROM := $(MODERN_ROM_NAME)
|
||||
OBJ_DIR := $(MODERN_OBJ_DIR_NAME)
|
||||
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
|
||||
endif
|
||||
GCC_VER := $(shell $(CC) -dumpversion)
|
||||
|
||||
CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN)
|
||||
ifneq ($(MODERN),1)
|
||||
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef
|
||||
endif
|
||||
CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) -quiet
|
||||
override CFLAGS += -Wno-trigraphs -Wimplicit -Wparentheses -Wunused -O0 -g -m32 -std=gnu99 -fno-leading-underscore -fno-dce -Wno-unused-function -DPORTABLE -DNONMATCHING
|
||||
ROM := pokeemerald_modern.gba
|
||||
OBJ_DIR := build/pc
|
||||
|
||||
CPPFLAGS := -iquote include -Wno-trigraphs -D NONMATCHING -D PORTABLE -I$(SDL_DIR)/include -L$(SDL_DIR)/lib
|
||||
|
||||
LDFLAGS = -Map ../../$(MAP)
|
||||
|
||||
LIB := $(LIBPATH) -lgcc -lc
|
||||
|
||||
SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c
|
||||
GFX := tools/gbagfx/gbagfx$(EXE)
|
||||
AIF := tools/aif2pcm/aif2pcm$(EXE)
|
||||
@ -132,14 +61,6 @@ FIX := tools/gbafix/gbafix$(EXE)
|
||||
MAPJSON := tools/mapjson/mapjson$(EXE)
|
||||
JSONPROC := tools/jsonproc/jsonproc$(EXE)
|
||||
|
||||
PERL := perl
|
||||
|
||||
TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*))
|
||||
TOOLBASE = $(TOOLDIRS:tools/%=%)
|
||||
TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE))
|
||||
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
||||
# Clear the default suffixes
|
||||
.SUFFIXES:
|
||||
# Don't delete intermediate files
|
||||
@ -150,50 +71,14 @@ MAKEFLAGS += --no-print-directory
|
||||
# Secondary expansion is required for dependency variables in object rules.
|
||||
.SECONDEXPANSION:
|
||||
|
||||
.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern tidymodern tidynonmodern
|
||||
.PHONY: rom clean compare tidy tools mostlyclean clean-tools
|
||||
|
||||
infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
|
||||
|
||||
# Build tools when building the rom
|
||||
# Disable dependency scanning for clean/tidy/tools
|
||||
# Use a separate minimal makefile for speed
|
||||
# Since we don't need to reload most of this makefile
|
||||
ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall syms,$(MAKECMDGOALS)))
|
||||
$(call infoshell, $(MAKE) -f make_tools.mk)
|
||||
else
|
||||
NODEP ?= 1
|
||||
endif
|
||||
|
||||
# check if we need to scan dependencies based on the rule
|
||||
ifeq (,$(MAKECMDGOALS))
|
||||
SCAN_DEPS ?= 1
|
||||
else
|
||||
# clean, tidy, tools, mostlyclean, clean-tools, $(TOOLDIRS), tidymodern, tidynonmodern don't even build the ROM
|
||||
# berry_fix and libagbsyscall do their own thing
|
||||
ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) tidymodern tidynonmodern berry_fix libagbsyscall,$(MAKECMDGOALS)))
|
||||
SCAN_DEPS ?= 0
|
||||
else
|
||||
SCAN_DEPS ?= 1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(SCAN_DEPS),1)
|
||||
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)))
|
||||
C_SRCS := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c)
|
||||
C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS))
|
||||
|
||||
GFLIB_SRCS := $(wildcard $(GFLIB_SUBDIR)/*.c)
|
||||
GFLIB_OBJS := $(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o,$(GFLIB_SRCS))
|
||||
|
||||
C_ASM_SRCS += $(wildcard $(C_SUBDIR)/*.s $(C_SUBDIR)/*/*.s $(C_SUBDIR)/*/*/*.s)
|
||||
C_ASM_OBJS := $(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o,$(C_ASM_SRCS))
|
||||
|
||||
ASM_SRCS := $(wildcard $(ASM_SUBDIR)/*.s)
|
||||
#ASM_SRCS := $(wildcard $(ASM_SUBDIR)/*.s)
|
||||
ASM_OBJS := $(patsubst $(ASM_SUBDIR)/%.s,$(ASM_BUILDDIR)/%.o,$(ASM_SRCS))
|
||||
|
||||
# get all the data/*.s files EXCEPT the ones with specific rules
|
||||
REGULAR_DATA_ASM_SRCS := $(filter-out $(DATA_ASM_SUBDIR)/maps.s $(DATA_ASM_SUBDIR)/map_events.s, $(wildcard $(DATA_ASM_SUBDIR)/*.s))
|
||||
|
||||
DATA_ASM_SRCS := $(wildcard $(DATA_ASM_SUBDIR)/*.s)
|
||||
DATA_ASM_OBJS := $(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o,$(DATA_ASM_SRCS))
|
||||
|
||||
@ -203,61 +88,51 @@ SONG_OBJS := $(patsubst $(SONG_SUBDIR)/%.s,$(SONG_BUILDDIR)/%.o,$(SONG_SRCS))
|
||||
MID_SRCS := $(wildcard $(MID_SUBDIR)/*.mid)
|
||||
MID_OBJS := $(patsubst $(MID_SUBDIR)/%.mid,$(MID_BUILDDIR)/%.o,$(MID_SRCS))
|
||||
|
||||
OBJS := $(C_OBJS) $(GFLIB_OBJS) $(C_ASM_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $(SONG_OBJS) $(MID_OBJS)
|
||||
OBJS := $(C_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS) $(SONG_OBJS) $(MID_OBJS)
|
||||
OBJS_REL := $(patsubst $(OBJ_DIR)/%,%,$(OBJS))
|
||||
|
||||
SUBDIRS := $(sort $(dir $(OBJS)))
|
||||
$(shell mkdir -p $(SUBDIRS))
|
||||
endif
|
||||
|
||||
AUTO_GEN_TARGETS :=
|
||||
|
||||
all: rom
|
||||
TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*))
|
||||
TOOLBASE = $(TOOLDIRS:tools/%=%)
|
||||
TOOLS = $(foreach tool,$(TOOLBASE),tools/%(tool)/$(tool)$(EXE))
|
||||
|
||||
tools: $(TOOLDIRS)
|
||||
$(shell mkdir -p $(SUBDIRS))
|
||||
|
||||
syms: $(SYM)
|
||||
all: tools rom
|
||||
|
||||
$(TOOLDIRS):
|
||||
@$(MAKE) -C $@
|
||||
tools: $(TOOLS)
|
||||
|
||||
$(TOOLS):
|
||||
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) -C $(tooldir);)
|
||||
|
||||
rom: $(ROM)
|
||||
ifeq ($(COMPARE),1)
|
||||
@$(SHA1) rom.sha1
|
||||
endif
|
||||
|
||||
# For contributors to make sure a change didn't affect the contents of the ROM.
|
||||
compare: all
|
||||
@$(SHA1) rom.sha1
|
||||
|
||||
clean: mostlyclean clean-tools
|
||||
|
||||
clean-tools:
|
||||
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)
|
||||
|
||||
mostlyclean: tidynonmodern tidymodern
|
||||
rm -f $(SAMPLE_SUBDIR)/*.bin
|
||||
rm -f $(CRY_SUBDIR)/*.bin
|
||||
mostlyclean: tidy
|
||||
rm -f sound/direct_sound_samples/*.bin
|
||||
rm -f $(MID_SUBDIR)/*.s
|
||||
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 {} +
|
||||
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
|
||||
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
|
||||
find $(DATA_ASM_SUBDIR)/maps \( -iname 'connections.inc' -o -iname 'events.inc' -o -iname 'header.inc' \) -exec rm {} +
|
||||
rm -f $(AUTO_GEN_TARGETS)
|
||||
@$(MAKE) clean -C berry_fix
|
||||
@$(MAKE) clean -C libagbsyscall
|
||||
|
||||
tidy: tidynonmodern tidymodern
|
||||
|
||||
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)
|
||||
|
||||
ifneq ($(MODERN),0)
|
||||
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
|
||||
tidy:
|
||||
rm -f $(ROM) $(ELF) $(MAP)
|
||||
rm -r $(OBJ_DIR)
|
||||
ifeq ($(MODERN),0)
|
||||
@$(MAKE) tidy MODERN=1
|
||||
endif
|
||||
|
||||
include graphics_file_rules.mk
|
||||
@ -278,129 +153,44 @@ include songs.mk
|
||||
%.gbapal: %.png ; $(GFX) $< $@
|
||||
%.lz: % ; $(GFX) $< $@
|
||||
%.rl: % ; $(GFX) $< $@
|
||||
$(CRY_SUBDIR)/%.bin: $(CRY_SUBDIR)/%.aif ; $(AIF) $< $@ --compress
|
||||
sound/direct_sound_samples/cry_%.bin: sound/direct_sound_samples/cry_%.aif ; $(AIF) $< $@ --compress
|
||||
sound/%.bin: sound/%.aif ; $(AIF) $< $@
|
||||
|
||||
|
||||
ifeq ($(MODERN),0)
|
||||
$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
|
||||
$(C_BUILDDIR)/libc.o: CFLAGS := -O2
|
||||
%src/platform/sdl2.o: CFLAGS += -fleading-underscore -O3
|
||||
|
||||
$(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
|
||||
|
||||
$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
|
||||
|
||||
$(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding
|
||||
$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm$(EXE)
|
||||
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -O2 -mthumb-interwork -quiet
|
||||
else
|
||||
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
|
||||
endif
|
||||
|
||||
ifeq ($(DDEBUG), 1)
|
||||
override ASFLAGS += --defsym DEBUG=1
|
||||
override CPPFLAGS += -D DEBUG=1
|
||||
endif
|
||||
|
||||
ifeq ($(DINFO),1)
|
||||
override CFLAGS += -g
|
||||
endif
|
||||
|
||||
# The dep rules have to be explicit or else missing files won't be reported.
|
||||
# As a side effect, they're evaluated immediately instead of when the rule is invoked.
|
||||
# It doesn't look like $(shell) can be deferred so there might not be a better way.
|
||||
|
||||
ifeq ($(SCAN_DEPS),1)
|
||||
ifeq ($(NODEP),1)
|
||||
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c
|
||||
ifeq (,$(KEEP_TEMPS))
|
||||
@echo "$(CC1) <flags> -o $@ $<"
|
||||
@$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ -
|
||||
$(C_BUILDDIR)/%.o: c_dep :=
|
||||
else
|
||||
$(C_BUILDDIR)/%.o: c_dep = $(shell $(SCANINC) -I include $(C_SUBDIR)/$*.c)
|
||||
endif
|
||||
|
||||
$(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep)
|
||||
@$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i
|
||||
@$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $(C_BUILDDIR)/$*.s
|
||||
$(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s
|
||||
endif
|
||||
else
|
||||
define C_DEP
|
||||
$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2)
|
||||
ifeq (,$$(KEEP_TEMPS))
|
||||
@echo "$$(CC1) <flags> -o $$@ $$<"
|
||||
@$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
|
||||
else
|
||||
@$$(CPP) $$(CPPFLAGS) $$< -o $$(C_BUILDDIR)/$3.i
|
||||
@$$(PREPROC) $$(C_BUILDDIR)/$3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(C_BUILDDIR)/$3.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $$(C_BUILDDIR)/$3.s
|
||||
$$(AS) $$(ASFLAGS) -o $$@ $$(C_BUILDDIR)/$3.s
|
||||
endif
|
||||
endef
|
||||
$(foreach src, $(C_SRCS), $(eval $(call C_DEP,$(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(src)),$(src),$(patsubst $(C_SUBDIR)/%.c,%,$(src)))))
|
||||
endif
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(GFLIB_BUILDDIR)/%.o: $(GFLIB_SUBDIR)/%.c $$(c_dep)
|
||||
ifeq (,$(KEEP_TEMPS))
|
||||
@echo "$(CC1) <flags> -o $@ $<"
|
||||
@$(CPP) $(CPPFLAGS) $< | $(PREPROC) $< charmap.txt -i | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ -
|
||||
$(ASM_BUILDDIR)/%.o: asm_dep :=
|
||||
else
|
||||
@$(CPP) $(CPPFLAGS) $< -o $(GFLIB_BUILDDIR)/$*.i
|
||||
@$(PREPROC) $(GFLIB_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(GFLIB_BUILDDIR)/$*.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $(GFLIB_BUILDDIR)/$*.s
|
||||
$(AS) $(ASFLAGS) -o $@ $(GFLIB_BUILDDIR)/$*.s
|
||||
endif
|
||||
else
|
||||
define GFLIB_DEP
|
||||
$1: $2 $$(shell $(SCANINC) -I include -I tools/agbcc/include -I gflib $2)
|
||||
ifeq (,$$(KEEP_TEMPS))
|
||||
@echo "$$(CC1) <flags> -o $$@ $$<"
|
||||
@$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
|
||||
else
|
||||
@$$(CPP) $$(CPPFLAGS) $$< -o $$(GFLIB_BUILDDIR)/$3.i
|
||||
@$$(PREPROC) $$(GFLIB_BUILDDIR)/$3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $$(GFLIB_BUILDDIR)/$3.s
|
||||
@echo -e ".text\n\t.align\t2, 0\n" >> $$(GFLIB_BUILDDIR)/$3.s
|
||||
$$(AS) $$(ASFLAGS) -o $$@ $$(GFLIB_BUILDDIR)/$3.s
|
||||
endif
|
||||
endef
|
||||
$(foreach src, $(GFLIB_SRCS), $(eval $(call GFLIB_DEP,$(patsubst $(GFLIB_SUBDIR)/%.c,$(GFLIB_BUILDDIR)/%.o, $(src)),$(src),$(patsubst $(GFLIB_SUBDIR)/%.c,%, $(src)))))
|
||||
$(ASM_BUILDDIR)/%.o: asm_dep = $(shell $(SCANINC) -I "" $(ASM_SUBDIR)/$*.s)
|
||||
endif
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
|
||||
else
|
||||
define SRC_ASM_DATA_DEP
|
||||
$1: $2 $$(shell $(SCANINC) -I include -I "" $2)
|
||||
$$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@
|
||||
endef
|
||||
$(foreach src, $(C_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src))))
|
||||
endif
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s
|
||||
$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s $$(asm_dep)
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
else
|
||||
define ASM_DEP
|
||||
$1: $2 $$(shell $(SCANINC) -I include -I "" $2)
|
||||
$$(AS) $$(ASFLAGS) -o $$@ $$<
|
||||
endef
|
||||
$(foreach src, $(ASM_SRCS), $(eval $(call ASM_DEP,$(patsubst $(ASM_SUBDIR)/%.s,$(ASM_BUILDDIR)/%.o, $(src)),$(src))))
|
||||
endif
|
||||
|
||||
ifeq ($(NODEP),1)
|
||||
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
|
||||
$(DATA_ASM_BUILDDIR)/%.o: data_dep :=
|
||||
else
|
||||
$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src))))
|
||||
endif
|
||||
$(DATA_ASM_BUILDDIR)/%.o: data_dep = $(shell $(SCANINC) -I include -I "" $(DATA_ASM_SUBDIR)/$*.s)
|
||||
endif
|
||||
|
||||
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s $$(data_dep)
|
||||
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(ASM_PSEUDO_OP_CONV) | $(AS) $(ASFLAGS) -o $@
|
||||
|
||||
$(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s
|
||||
$(AS) $(ASFLAGS) -I sound -o $@ $<
|
||||
$(ASM_PSEUDO_OP_CONV) $< | $(AS) $(ASFLAGS) -I sound -o $@
|
||||
|
||||
$(OBJ_DIR)/sym_bss.ld: sym_bss.txt
|
||||
$(RAMSCRGEN) .bss $< ENGLISH > $@
|
||||
@ -422,28 +212,17 @@ endif
|
||||
$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS)
|
||||
cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld
|
||||
|
||||
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) berry_fix libagbsyscall
|
||||
@echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ <objects> <lib>"
|
||||
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
|
||||
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS)
|
||||
cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
|
||||
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
|
||||
#$(ROM): $(ELF)
|
||||
#$(OBJCOPY) -O binary $< $@
|
||||
#$(FIX) $@ -p --silent
|
||||
|
||||
$(ROM): $(ELF)
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(FIX) $@ -p --silent
|
||||
pokeemerald.exe: $(OBJS)
|
||||
$(CC) $(CFLAGS) -Wl,--demangle $^ -L$(SDL_DIR)/lib -lmingw32 -lSDLmain -lSDL.dll -lwinmm -static-libgcc -o $@
|
||||
|
||||
modern: all
|
||||
$(ROM): pokeemerald.exe
|
||||
@:
|
||||
|
||||
berry_fix/berry_fix.gba: berry_fix
|
||||
|
||||
berry_fix:
|
||||
@$(MAKE) -C berry_fix COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN)
|
||||
|
||||
libagbsyscall:
|
||||
@$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN)
|
||||
|
||||
###################
|
||||
### Symbol file ###
|
||||
###################
|
||||
|
||||
$(SYM): $(ELF)
|
||||
$(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' > $@
|
||||
modern: ; @$(MAKE) MODERN=1
|
||||
|
Loading…
Reference in New Issue
Block a user