Add support for dkp-less instructions.

Todo: actually test building with dkP.
This commit is contained in:
luckytyphlosion 2020-11-25 09:20:45 -05:00
parent 70b6e05a47
commit 1536295872
5 changed files with 99 additions and 91 deletions

View File

@ -1,28 +1,28 @@
TOOLCHAIN := $(DEVKITARM) TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0 COMPARE ?= 0
ifeq ($(CC),) # check if dkP's base_tools makefile exists
HOSTCC := gcc
else
HOSTCC := $(CC)
endif
ifeq ($(CXX),)
HOSTCXX := g++
else
HOSTCXX := $(CXX)
endif
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools include $(TOOLCHAIN)/base_tools
# otherwise, either use the bin files or the
# arm-none-eabi binaries on the system
else else
export PATH := $(TOOLCHAIN)/bin:$(PATH) ifneq ($(TOOLCHAIN),)
PREFIX := arm-none-eabi- export PATH := $(TOOLCHAIN)/bin:$(PATH)
OBJCOPY := $(PREFIX)objcopy endif
export CC := $(PREFIX)gcc PREFIX := arm-none-eabi-
export AS := $(PREFIX)as OBJCOPY := $(PREFIX)objcopy
# note: the makefile must be set up so MODERNCC is never called
# if MODERN=0
export MODERNCC := $(PREFIX)gcc
export AS := $(PREFIX)as
endif endif
ifneq ($(TOOLCHAIN),)
export CPP := $(PREFIX)cpp export CPP := $(PREFIX)cpp
else
export CPP := $(CC) -E
endif
export LD := $(PREFIX)ld export LD := $(PREFIX)ld
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
@ -37,6 +37,16 @@ MAKER_CODE := 01
REVISION := 0 REVISION := 0
MODERN ?= 0 MODERN ?= 0
ROM_NAME := pokeemerald.gba
ELF_NAME := $(ROM_NAME:.gba=.elf)
MAP_NAME := $(ROM_NAME:.gba=.map)
OBJ_DIR_NAME := build/emerald
MODERN_ROM_NAME := pokeemerald_modern.gba
MODERN_ELF_NAME := $(MODERN_ROM_NAME:.gba=.elf)
MODERN_MAP_NAME := $(MODERN_ROM_NAME:.gba=.map)
MODERN_OBJ_DIR_NAME := build/modern
SHELL := /bin/bash -o pipefail SHELL := /bin/bash -o pipefail
ELF = $(ROM:.gba=.elf) ELF = $(ROM:.gba=.elf)
@ -64,18 +74,18 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN)
ifeq ($(MODERN),0) ifeq ($(MODERN),0)
CC1 := tools/agbcc/bin/agbcc$(EXE) CC1 := tools/agbcc/bin/agbcc$(EXE)
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm
ROM := pokeemerald.gba ROM := $(ROM_NAME)
OBJ_DIR := build/emerald OBJ_DIR := $(OBJ_DIR_NAME)
LIBPATH := -L ../../tools/agbcc/lib LIBPATH := -L ../../tools/agbcc/lib
else else
CC1 = $(shell $(CC) --print-prog-name=cc1) -quiet CC1 = $(shell $(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 override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
ROM := pokeemerald_modern.gba ROM := $(MODERN_ROM_NAME)
OBJ_DIR := build/modern OBJ_DIR := $(MODERN_OBJ_DIR_NAME)
LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))"
endif endif
CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -nostdinc -undef
ifeq ($(MODERN),0) ifeq ($(MODERN),0)
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc CPPFLAGS += -I tools/agbcc/include -I tools/agbcc
endif endif
@ -111,7 +121,7 @@ MAKEFLAGS += --no-print-directory
# Secondary expansion is required for dependency variables in object rules. # Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION: .SECONDEXPANSION:
.PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern .PHONY: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern tidymodern tidynonmodern
infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
@ -162,7 +172,7 @@ all: rom
tools: $(TOOLDIRS) tools: $(TOOLDIRS)
$(TOOLDIRS): $(TOOLDIRS):
@$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX) @$(MAKE) -C $@
rom: $(ROM) rom: $(ROM)
ifeq ($(COMPARE),1) ifeq ($(COMPARE),1)
@ -177,7 +187,7 @@ clean: mostlyclean clean-tools
clean-tools: clean-tools:
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)
mostlyclean: tidy mostlyclean: tidynonmodern tidymodern
rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(SAMPLE_SUBDIR)/*.bin
rm -f $(CRY_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin
rm -f $(MID_SUBDIR)/*.s rm -f $(MID_SUBDIR)/*.s
@ -192,10 +202,15 @@ mostlyclean: tidy
tidy: tidy:
rm -f $(ROM) $(ELF) $(MAP) rm -f $(ROM) $(ELF) $(MAP)
rm -r $(OBJ_DIR) rm -r $(OBJ_DIR)
ifeq ($(MODERN),0)
@$(MAKE) tidy MODERN=1
endif
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) ifneq ($(MODERN),0)
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
endif endif
@ -296,11 +311,11 @@ endif
ifeq ($(NODEP),1) ifeq ($(NODEP),1)
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s $(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@ $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
else else
define DATA_ASM_DEP define DATA_ASM_DEP
$1: $2 $$(shell $(SCANINC) -I include -I "" $2) $1: $2 $$(shell $(SCANINC) -I include -I "" $2)
$$(PREPROC) $$< charmap.txt | $$(CPP) -I include | $$(AS) $$(ASFLAGS) -o $$@ $$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@
endef endef
$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src))))
endif endif

View File

@ -1,28 +1,26 @@
TOOLCHAIN := $(DEVKITARM) TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0 COMPARE ?= 0
ifeq ($(CC),) # check if dkP's base_tools makefile exists
HOSTCC := gcc
else
HOSTCC := $(CC)
endif
ifeq ($(CXX),)
HOSTCXX := g++
else
HOSTCXX := $(CXX)
endif
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools include $(TOOLCHAIN)/base_tools
# otherwise, either use the bin files or the
# arm-none-eabi binaries on the system
else else
export PATH := $(TOOLCHAIN)/bin:$(PATH) ifneq ($(TOOLCHAIN),)
PREFIX := arm-none-eabi- export PATH := $(TOOLCHAIN)/bin:$(PATH)
OBJCOPY := $(PREFIX)objcopy endif
export CC := $(PREFIX)gcc PREFIX := arm-none-eabi-
export AS := $(PREFIX)as OBJCOPY := $(PREFIX)objcopy
export MODERNCC := $(PREFIX)gcc
export AS := $(PREFIX)as
endif endif
ifneq ($(TOOLCHAIN),)
export CPP := $(PREFIX)cpp export CPP := $(PREFIX)cpp
else
export CPP := $(CC) -E
endif
export LD := $(PREFIX)ld export LD := $(PREFIX)ld
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)

View File

@ -1,28 +1,26 @@
TOOLCHAIN := $(DEVKITARM) TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0 COMPARE ?= 0
ifeq ($(CC),) # check if dkP's base_tools makefile exists
HOSTCC := gcc
else
HOSTCC := $(CC)
endif
ifeq ($(CXX),)
HOSTCXX := g++
else
HOSTCXX := $(CXX)
endif
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools include $(TOOLCHAIN)/base_tools
# otherwise, either use the bin files or the
# arm-none-eabi binaries on the system
else else
export PATH := $(TOOLCHAIN)/bin:$(PATH) ifneq ($(TOOLCHAIN),)
PREFIX := arm-none-eabi- export PATH := $(TOOLCHAIN)/bin:$(PATH)
OBJCOPY := $(PREFIX)objcopy endif
export CC := $(PREFIX)gcc PREFIX := arm-none-eabi-
export AS := $(PREFIX)as OBJCOPY := $(PREFIX)objcopy
export MODERNCC := $(PREFIX)gcc
export AS := $(PREFIX)as
endif endif
ifneq ($(TOOLCHAIN),)
export CPP := $(PREFIX)cpp export CPP := $(PREFIX)cpp
else
export CPP := $(CC) -E
endif
export LD := $(PREFIX)ld export LD := $(PREFIX)ld
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)

View File

@ -1,30 +1,27 @@
TOOLCHAIN := $(DEVKITARM) TOOLCHAIN := $(DEVKITARM)
COMPARE ?= 0 COMPARE ?= 0
ifeq ($(CC),) # check if dkP's base_tools makefile exists
HOSTCC := gcc
else
HOSTCC := $(CC)
endif
ifeq ($(CXX),)
HOSTCXX := g++
else
HOSTCXX := $(CXX)
endif
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools include $(TOOLCHAIN)/base_tools
# otherwise, either use the bin files or the
# arm-none-eabi binaries on the system
else else
export PATH := $(TOOLCHAIN)/bin:$(PATH) ifneq ($(TOOLCHAIN),)
PREFIX := arm-none-eabi- export PATH := $(TOOLCHAIN)/bin:$(PATH)
OBJCOPY := $(PREFIX)objcopy endif
export CC := $(PREFIX)gcc PREFIX := arm-none-eabi-
export AS := $(PREFIX)as OBJCOPY := $(PREFIX)objcopy
export MODERNCC := $(PREFIX)gcc
export AS := $(PREFIX)as
endif endif
export CPP := $(PREFIX)cpp
export LD := $(PREFIX)ld
ifneq ($(TOOLCHAIN),)
export CPP := $(PREFIX)cpp
else
export CPP := $(CC) -E
endif
export LD := $(PREFIX)ld
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
EXE := .exe EXE := .exe
else else

View File

@ -9,9 +9,9 @@ MAP_EVENTS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/events.inc,$(MAP_DIRS))
MAP_HEADERS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/header.inc,$(MAP_DIRS)) MAP_HEADERS := $(patsubst $(MAPS_DIR)/%/,$(MAPS_DIR)/%/header.inc,$(MAP_DIRS))
$(DATA_ASM_BUILDDIR)/maps.o: $(DATA_ASM_SUBDIR)/maps.s $(LAYOUTS_DIR)/layouts.inc $(LAYOUTS_DIR)/layouts_table.inc $(MAPS_DIR)/headers.inc $(MAPS_DIR)/groups.inc $(MAPS_DIR)/connections.inc $(MAP_CONNECTIONS) $(MAP_HEADERS) $(DATA_ASM_BUILDDIR)/maps.o: $(DATA_ASM_SUBDIR)/maps.s $(LAYOUTS_DIR)/layouts.inc $(LAYOUTS_DIR)/layouts_table.inc $(MAPS_DIR)/headers.inc $(MAPS_DIR)/groups.inc $(MAPS_DIR)/connections.inc $(MAP_CONNECTIONS) $(MAP_HEADERS)
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@ $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
$(DATA_ASM_BUILDDIR)/map_events.o: $(DATA_ASM_SUBDIR)/map_events.s $(MAPS_DIR)/events.inc $(MAP_EVENTS) $(DATA_ASM_BUILDDIR)/map_events.o: $(DATA_ASM_SUBDIR)/map_events.s $(MAPS_DIR)/events.inc $(MAP_EVENTS)
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@ $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
$(MAPS_DIR)/%/header.inc: $(MAPS_DIR)/%/map.json $(MAPS_DIR)/%/header.inc: $(MAPS_DIR)/%/map.json
$(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json $(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json