From 15362958722fe6d3070d1911a5a9edd7e7b41c58 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 25 Nov 2020 09:20:45 -0500 Subject: [PATCH 01/43] Add support for dkp-less instructions. Todo: actually test building with dkP. --- Makefile | 81 ++++++++++++++++++++++---------------- berry_fix/Makefile | 34 ++++++++-------- berry_fix/payload/Makefile | 34 ++++++++-------- libagbsyscall/Makefile | 37 ++++++++--------- map_data_rules.mk | 4 +- 5 files changed, 99 insertions(+), 91 deletions(-) diff --git a/Makefile b/Makefile index 07143e4ad4..d39b9fb2d4 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,28 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -endif - -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - +# check if dkP's base_tools makefile exists 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 -export PATH := $(TOOLCHAIN)/bin:$(PATH) -PREFIX := arm-none-eabi- -OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as + ifneq ($(TOOLCHAIN),) + export PATH := $(TOOLCHAIN)/bin:$(PATH) + endif + PREFIX := arm-none-eabi- + 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 + +ifneq ($(TOOLCHAIN),) export CPP := $(PREFIX)cpp +else +export CPP := $(CC) -E +endif export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) @@ -37,6 +37,16 @@ MAKER_CODE := 01 REVISION := 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 ELF = $(ROM:.gba=.elf) @@ -64,18 +74,18 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -ROM := pokeemerald.gba -OBJ_DIR := build/emerald +ROM := $(ROM_NAME) +OBJ_DIR := $(OBJ_DIR_NAME) LIBPATH := -L ../../tools/agbcc/lib 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 -ROM := pokeemerald_modern.gba -OBJ_DIR := build/modern -LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" +ROM := $(MODERN_ROM_NAME) +OBJ_DIR := $(MODERN_OBJ_DIR_NAME) +LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))" 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) CPPFLAGS += -I tools/agbcc/include -I tools/agbcc endif @@ -111,7 +121,7 @@ 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 +.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)))) @@ -162,7 +172,7 @@ all: rom tools: $(TOOLDIRS) $(TOOLDIRS): - @$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX) + @$(MAKE) -C $@ rom: $(ROM) ifeq ($(COMPARE),1) @@ -177,7 +187,7 @@ clean: mostlyclean clean-tools clean-tools: @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) -mostlyclean: tidy +mostlyclean: tidynonmodern tidymodern rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin rm -f $(MID_SUBDIR)/*.s @@ -192,10 +202,15 @@ mostlyclean: tidy tidy: rm -f $(ROM) $(ELF) $(MAP) 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) $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member endif @@ -296,11 +311,11 @@ endif ifeq ($(NODEP),1) $(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 define DATA_ASM_DEP $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 $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 0ead3804fd..dd52792ec2 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,28 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -endif - -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - +# check if dkP's base_tools makefile exists 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 -export PATH := $(TOOLCHAIN)/bin:$(PATH) -PREFIX := arm-none-eabi- -OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as + ifneq ($(TOOLCHAIN),) + export PATH := $(TOOLCHAIN)/bin:$(PATH) + endif + PREFIX := arm-none-eabi- + OBJCOPY := $(PREFIX)objcopy + export MODERNCC := $(PREFIX)gcc + export AS := $(PREFIX)as endif + +ifneq ($(TOOLCHAIN),) export CPP := $(PREFIX)cpp +else +export CPP := $(CC) -E +endif export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index a121fda93b..20d3d60c81 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,28 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -endif - -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - +# check if dkP's base_tools makefile exists 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 -export PATH := $(TOOLCHAIN)/bin:$(PATH) -PREFIX := arm-none-eabi- -OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as + ifneq ($(TOOLCHAIN),) + export PATH := $(TOOLCHAIN)/bin:$(PATH) + endif + PREFIX := arm-none-eabi- + OBJCOPY := $(PREFIX)objcopy + export MODERNCC := $(PREFIX)gcc + export AS := $(PREFIX)as endif + +ifneq ($(TOOLCHAIN),) export CPP := $(PREFIX)cpp +else +export CPP := $(CC) -E +endif export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 911cdb237c..6c0ba681ed 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -1,30 +1,27 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -endif - -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - +# check if dkP's base_tools makefile exists 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 -export PATH := $(TOOLCHAIN)/bin:$(PATH) -PREFIX := arm-none-eabi- -OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as + ifneq ($(TOOLCHAIN),) + export PATH := $(TOOLCHAIN)/bin:$(PATH) + endif + PREFIX := arm-none-eabi- + OBJCOPY := $(PREFIX)objcopy + export MODERNCC := $(PREFIX)gcc + export AS := $(PREFIX)as 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) EXE := .exe else diff --git a/map_data_rules.mk b/map_data_rules.mk index 0203b383d0..626cd47240 100755 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -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)) $(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) - $(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 $(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json From 51e8b8b8dbf51f57a7d925137a369864f7debdbb Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 25 Nov 2020 10:37:50 -0500 Subject: [PATCH 02/43] Don't use base_tools if dkP is installed, also just use $(CC) -E for CPP regardless. --- Makefile | 37 +++++++++++++++++-------------------- berry_fix/Makefile | 35 +++++++++++++++++------------------ berry_fix/payload/Makefile | 35 +++++++++++++++++------------------ libagbsyscall/Makefile | 36 ++++++++++++++++++------------------ 4 files changed, 69 insertions(+), 74 deletions(-) diff --git a/Makefile b/Makefile index d39b9fb2d4..72af64f5c2 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# check if dkP's base_tools makefile exists -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) - include $(TOOLCHAIN)/base_tools -# otherwise, either use the bin files or the -# arm-none-eabi binaries on the system -else - ifneq ($(TOOLCHAIN),) - export PATH := $(TOOLCHAIN)/bin:$(PATH) - endif - PREFIX := arm-none-eabi- - 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 +# 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 tihs system ifneq ($(TOOLCHAIN),) -export CPP := $(PREFIX)cpp -else -export CPP := $(CC) -E +export PATH := $(TOOLCHAIN)/bin:$(PATH) endif -export LD := $(PREFIX)ld + +PREFIX := arm-none-eabi- +OBJCOPY := $(PREFIX)objcopy +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/berry_fix/Makefile b/berry_fix/Makefile index dd52792ec2..f7ce405047 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,27 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# check if dkP's base_tools makefile exists -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) - include $(TOOLCHAIN)/base_tools -# otherwise, either use the bin files or the -# arm-none-eabi binaries on the system -else - ifneq ($(TOOLCHAIN),) - export PATH := $(TOOLCHAIN)/bin:$(PATH) - endif - PREFIX := arm-none-eabi- - OBJCOPY := $(PREFIX)objcopy - export MODERNCC := $(PREFIX)gcc - export AS := $(PREFIX)as -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 tihs system ifneq ($(TOOLCHAIN),) -export CPP := $(PREFIX)cpp -else -export CPP := $(CC) -E +export PATH := $(TOOLCHAIN)/bin:$(PATH) endif -export LD := $(PREFIX)ld + +PREFIX := arm-none-eabi- +OBJCOPY := $(PREFIX)objcopy +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index 20d3d60c81..7a6a923960 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,27 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# check if dkP's base_tools makefile exists -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) - include $(TOOLCHAIN)/base_tools -# otherwise, either use the bin files or the -# arm-none-eabi binaries on the system -else - ifneq ($(TOOLCHAIN),) - export PATH := $(TOOLCHAIN)/bin:$(PATH) - endif - PREFIX := arm-none-eabi- - OBJCOPY := $(PREFIX)objcopy - export MODERNCC := $(PREFIX)gcc - export AS := $(PREFIX)as -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 tihs system ifneq ($(TOOLCHAIN),) -export CPP := $(PREFIX)cpp -else -export CPP := $(CC) -E +export PATH := $(TOOLCHAIN)/bin:$(PATH) endif -export LD := $(PREFIX)ld + +PREFIX := arm-none-eabi- +OBJCOPY := $(PREFIX)objcopy +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 6c0ba681ed..ba349e9ebb 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -1,27 +1,27 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# check if dkP's base_tools makefile exists -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) - include $(TOOLCHAIN)/base_tools -# otherwise, either use the bin files or the -# arm-none-eabi binaries on the system -else - ifneq ($(TOOLCHAIN),) - export PATH := $(TOOLCHAIN)/bin:$(PATH) - endif - PREFIX := arm-none-eabi- - OBJCOPY := $(PREFIX)objcopy - export MODERNCC := $(PREFIX)gcc - export AS := $(PREFIX)as -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 tihs system ifneq ($(TOOLCHAIN),) -export CPP := $(PREFIX)cpp -else -export CPP := $(CC) -E +export PATH := $(TOOLCHAIN)/bin:$(PATH) endif -export LD := $(PREFIX)ld + +PREFIX := arm-none-eabi- +OBJCOPY := $(PREFIX)objcopy +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc + ifeq ($(OS),Windows_NT) EXE := .exe else From 90d8bb1d332036a26da549b456cf0f2a3ace6d54 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 25 Nov 2020 11:28:01 -0500 Subject: [PATCH 03/43] Partially work on the new Install.MD. Todo: - Legacy Windows instructions - macOS, Linux instructions - figure out what to do with the base_tools note for macOS - dkp installation instructions for platforms which do not install dkp. --- INSTALL.md | 171 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 129 insertions(+), 42 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 20d55e134c..8669738be0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,82 +1,170 @@ -# Prerequisites +# Instructions -| Linux | macOS | Windows 10 -| - | - | - -| none | [Xcode Command Line Tools Package][xcode] | [Windows Terminal][terminal] and [Windows Subsystem for Linux (WSL)][wsl] +These instructions explain how to set up the tools required to build **pokeemerald**, which assembles the source files into a ROM. -[xcode]: https://developer.apple.com/library/archive/technotes/tn2339/_index.html -[terminal]: https://docs.microsoft.com/windows/terminal/get-started -[wsl]: https://docs.microsoft.com/windows/wsl/install-win10 +If you run into trouble, ask for help on IRC or Discord (see [README.md](README.md)). -Independently from the specific OS, make sure that the `gcc`, `g++`, `make`, `git`, and `libpng-dev` packages or their equivalents are installed and accessible to the development tools that are used by the project (this means that, for example, on Windows, the packages have to be installed in the WSL environment). The package names and installation methods may vary with each OS. +## Windows 10 +WSL1 is the preferred terminal to build **pokeemerald**. The following instructions will explain how to install WSL1. These steps can be skipped if WSL1 is already installed. -Install the devkitARM toolchain of devkitPro as per [the instructions on their wiki](https://devkitpro.org/wiki/devkitPro_pacman). On Windows, follow the Linux instructions inside WSL as any steps about the Windows installer do not apply. +### Installing WSL1 +Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Shift+Insert is paste in the terminal). +``` +dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart +``` +Once the process finishes, restart your machine. -**Debian-based distro users:** This applies to Debian, Ubuntu, and similar distros, including in WSL. If necessary, install the `libarchive13`, `pkg-config`, and `gdebi-core` packages to be able to install devkitPro. +The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice. Advanced users can pick a preferred Linux distribution, but build instructions may differ. -**Windows 10 users:** WSL 2 is available in the 1903 release (build 18362) and later, therefore existing WSL 1 and [prerelease WSL](https://docs.microsoft.com/windows/wsl/install-legacy) users are recommended to update. Right-click the Start button or press `Win`+`X`, choose Run, and run `ms-settings:about` to determine the Windows version. Also check Windows Update to make sure your installation is up-to-date. +Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). -**Windows 7 and 8.1 users:** pret is no longer focusing on support in pokeemerald for [old versions of Windows](https://support.microsoft.com/help/13853) so consider upgrading to a current release of Windows 10 or try a third-party guide like [this one](https://www.pokecommunity.com/showthread.php?t=425246) instead. +### Setting up WSL1 +Open **Ubuntu** (e.g. using Search). WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in). Note that there will be no visible response when typing in the password, but the terminal will still read in input. +A few notes before proceeding +- In the terminal, Copy and Paste is either done via + - **right-click** (selection + right click to Copy, right click with no selection to Paste) + - **Ctrl+Shift+C/Ctrl+Shift+V** (enabled by right-clicking the title bar, going to Properties, then checking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste"). +- Some of the commands that you'll run will ask for your WSL password and/or confirmation to perform the stated action. This is to be expected, just enter your WSL password and/or the yes action when necessary. -# Installation +Update WSL/Ubuntu before continuing. Do this by running the following command: +```bash +sudo apt update && sudo apt upgrade +``` +Note that these commands will likely take a long time to finish. -To set up the repository: +Certain packages are required to build pokeemerald. Install these packages by running the following command: +```bash +sudo apt install build-essential binutils-arm-none-eabi git libpng-dev +``` +(If the above command does not work, try the above command but replacing `apt` with `apt-get`). - git clone https://github.com/pret/pokeemerald - git clone https://github.com/pret/agbcc +WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to install pokeemerald within Windows. You'll have to change the **current working directory** every time you open WSL. - cd ./agbcc - ./build.sh - ./install.sh ../pokeemerald +For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: +```bash +cd /mnt/c/Users//Desktop/decomps +``` +Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. + +(The Windows C:\ drive is called /mnt/c/ in WSL. Replace in the example path with your **Windows** username, and the drive letter with the letter of the drive of the folder where the package was saved to. Windows path names are case-insensitive so adhereing to capitalization isn't needed) - cd ../pokeemerald +If this works, then proceed to [Installation](#Installation). +Otherwise, continue reading below for [the older Windows instructions](#windows). + +## Windows +TODO: add general Windows instructions + +## macOS +TODO: add macOS instructions + +## Linux +TODO: add Linux instructions + +## Installation +To download the pokeemerald repository: +```bash +git clone https://github.com/pret/pokeemerald +``` +If agbcc isn't built, run the following commands to build and install it into pokeemerald: +``` +git clone https://github.com/pret/agbcc +cd agbcc +./build.sh +./install.sh ../pokeemerald +``` +Otherwise, run the following commands to install agbcc into pokeemerald: +``` +cd agbcc +./install.sh ../pokeemerald +``` +Then, change directory back to the base directory where pokeemerald and agbcc are stored: +``` +cd .. +``` +Now you're ready to [build **pokeemerald**](#build-pokeemerald) +## Build pokeemerald +First, change directory to the pokeemerald folder: +```bash +cd pokeemerald +``` To build **pokeemerald.gba** for the first time and confirm it matches the official ROM image: - - make compare - +```bash +make compare +``` If an OK is returned, then the installation went smoothly. -**Windows users:** Consider adding exceptions for the `pokeemerald` and `agbcc` folders in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. - - -# Start - To build **pokeemerald.gba** with your changes: +```bash +make +``` - make - -**macOS users:** If the base tools are not found in new Terminal sessions after the first successful build, run `echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile` once to prevent the issue from occurring again. Verify that the `devkitarm-rules` package is installed as well; if not, install it by running `sudo dkp-pacman -S devkitarm-rules`. +**Windows users:** Consider adding an exception for the `pokeemerald` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. +**macOS users (this is probably outdated):** If the base tools are not found in new Terminal sessions after the first successful build, run `echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile` once to prevent the issue from occurring again. Verify that the `devkitarm-rules` package is installed as well; if not, install it by running `sudo dkp-pacman -S devkitarm-rules`. # Building guidance - ## Parallel builds See [the GNU docs](https://www.gnu.org/software/make/manual/html_node/Parallel.html) and [this Stack Exchange thread](https://unix.stackexchange.com/questions/208568) for more information. -To speed up building, run: - - make -j$(nproc) +To speed up building, first get the value of `nproc`: +```bash +nproc +``` +Builds can then be sped up by running the following command: +```bash +make -j +``` +Replace `` with the number that the `nproc` command returned. `nproc` is not available on macOS. The alternative is `sysctl -n hw.ncpu` ([relevant Stack Overflow thread](https://stackoverflow.com/questions/1715580)). - ## Debug info To build **pokeemerald.elf** with enhanced debug info: - - make DINFO=1 - +```bash +make DINFO=1 +``` ## devkitARM's C compiler -This project supports the `arm-none-eabi-gcc` compiler included with devkitARM r52. To build this target, simply run: +This project supports the `arm-none-eabi-gcc` compiler included with devkitARM. If devkitARM has already been installed as part of the platform-specific instructions, simply run: +```bash +make modern +``` +Otherwise, follow the instructions below to install devkitARM. +### Installing devkitARM on WSL1 - make modern +`gdebi-core` must be installed beforehand in order to install devkitPro (which facilitates the installation of devkitARM). Install this with the following command: +```bash +sudo apt install gdebi-core +``` +(If the above command does not work, try the above command but replacing `apt` with `apt-get`). +Once `gdebi-core` is done installing, download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. + +Change directory to where the package was downloaded. For example, if the package file was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: +```bash +cd /mnt/c/Users//Downloads +``` +(Replace with your Windows username) + +Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. +```bash +sudo gdebi devkitpro-pacman.amd64.deb +sudo dkp-pacman -Sy +sudo dkp-pacman -S gba-dev +``` +Note: the last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + +Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL): +```bash +source /etc/profile.d/devkit-env.sh +``` +devkitARM is now installed. ## Other toolchains @@ -90,7 +178,6 @@ The following is an example: To compile the `modern` target with this toolchain, the subdirectories `lib`, `include`, and `arm-none-eabi` must also be present. - # Useful additional tools * [porymap](https://github.com/huderlem/porymap) for viewing and editing maps From 01637deee53232432630e1ff64ff4550c7ca7aec Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 25 Nov 2020 11:30:08 -0500 Subject: [PATCH 04/43] Fix bad clarification. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 8669738be0..66d49b412d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -47,7 +47,7 @@ cd /mnt/c/Users//Desktop/decomps ``` Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. -(The Windows C:\ drive is called /mnt/c/ in WSL. Replace in the example path with your **Windows** username, and the drive letter with the letter of the drive of the folder where the package was saved to. Windows path names are case-insensitive so adhereing to capitalization isn't needed) +(The Windows C:\ drive is called /mnt/c/ in WSL. Replace in the example path with your **Windows** username, and the drive letter with the letter of the drive where you want to save pokeemerald. Windows path names are case-insensitive so adhereing to capitalization isn't needed) If this works, then proceed to [Installation](#Installation). From 6bf6cf2eb8ca0ee7b66c62ca9ab39d59f2a83877 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 25 Nov 2020 11:32:22 -0500 Subject: [PATCH 05/43] Escape literal text. --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 66d49b412d..e0164c1f31 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -47,7 +47,7 @@ cd /mnt/c/Users//Desktop/decomps ``` Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. -(The Windows C:\ drive is called /mnt/c/ in WSL. Replace in the example path with your **Windows** username, and the drive letter with the letter of the drive where you want to save pokeemerald. Windows path names are case-insensitive so adhereing to capitalization isn't needed) +(The Windows C:\ drive is called /mnt/c/ in WSL. Replace *\* in the example path with your **Windows** username, and the drive letter with the letter of the drive where you want to save pokeemerald. Windows path names are case-insensitive so adhereing to capitalization isn't needed) If this works, then proceed to [Installation](#Installation). @@ -150,7 +150,7 @@ Change directory to where the package was downloaded. For example, if the packag ```bash cd /mnt/c/Users//Downloads ``` -(Replace with your Windows username) +(Replace *\* with your Windows username) Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. ```bash From 59a6d18679365cb3a2e2d7fa7571fa2495652939 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 25 Nov 2020 11:46:12 -0500 Subject: [PATCH 06/43] Minor INSTALL.md cleanup, also don't print the wall of linked objects during make (helps spot warnings more easily) --- INSTALL.md | 4 ++-- Makefile | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index e0164c1f31..779572c69f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -8,7 +8,7 @@ If you run into trouble, ask for help on IRC or Discord (see [README.md](README. WSL1 is the preferred terminal to build **pokeemerald**. The following instructions will explain how to install WSL1. These steps can be skipped if WSL1 is already installed. ### Installing WSL1 -Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Shift+Insert is paste in the terminal). +Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Right Click or Shift+Insert is paste in the Powershell). ``` dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart ``` @@ -21,7 +21,7 @@ Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubunt ### Setting up WSL1 Open **Ubuntu** (e.g. using Search). WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in). Note that there will be no visible response when typing in the password, but the terminal will still read in input. -A few notes before proceeding +A few notes before proceeding: - In the terminal, Copy and Paste is either done via - **right-click** (selection + right click to Copy, right click with no selection to Paste) - **Ctrl+Shift+C/Ctrl+Shift+V** (enabled by right-clicking the title bar, going to Properties, then checking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste"). diff --git a/Makefile b/Makefile index 72af64f5c2..aa588445f2 100644 --- a/Makefile +++ b/Makefile @@ -341,7 +341,8 @@ $(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 - cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + @echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ " + @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) From 976b967732454b3171ac5b5d61b865f1cc3a5777 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Thu, 26 Nov 2020 20:21:16 -0500 Subject: [PATCH 07/43] Add msys2 and Cygwin instructions, also add .exe extension to built tools. Todo: actually extensively test out msys2 and Cygwin, and double check the readme. --- INSTALL.md | 131 ++++++++++++++++++++++++++++++++++++--- Makefile | 6 +- tools/aif2pcm/Makefile | 10 ++- tools/bin2c/Makefile | 10 ++- tools/gbafix/Makefile | 10 ++- tools/gbagfx/Makefile | 12 +++- tools/jsonproc/Makefile | 10 ++- tools/mapjson/Makefile | 10 ++- tools/mid2agb/Makefile | 10 ++- tools/preproc/Makefile | 10 ++- tools/ramscrgen/Makefile | 10 ++- tools/rsfont/Makefile | 10 ++- tools/scaninc/Makefile | 10 ++- 13 files changed, 213 insertions(+), 36 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 779572c69f..f50ea1db76 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -4,8 +4,22 @@ These instructions explain how to set up the tools required to build **pokeemera If you run into trouble, ask for help on IRC or Discord (see [README.md](README.md)). -## Windows 10 -WSL1 is the preferred terminal to build **pokeemerald**. The following instructions will explain how to install WSL1. These steps can be skipped if WSL1 is already installed. +## Windows +Windows has instructions for building with three possible terminals, if users encounter unexpected errors in following instructions for one of the terminals. These instructions are: +- [Windows 10 (WSL1)](#windows-10-wsl1) +- [Windows (msys2)](#windows-(msys2)) +- [Windows (Cygwin)](#windows-(cygwin)) + +The instructions have been ordered by the performance of their respective terminal. Out of the provided terminals, **WSL1** builds pokeemerald the fastest, and is thus **highly recommended**, but is only available on Windows 10. **msys2** is the second fastest, and **Cygwin** is the slowest. For advanced users, **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools such as [porymap](https://github.com/huderlem/porymap) cannot interact with said files due to problems [outside the control of maintainers](https://bugreports.qt.io/browse/QTBUG-86277). + +All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct the drive letter when reading the instructions. + +**A note of caution**: As Windows 7 is officially unsupported by Microsoft and Windows 8 has very little usage, some maintainers are unwilling to maintain the Windows 7/8 instructions. Thus, these instructions may break in the future with fixes taking longer than fixes to the Windows 10 instructions. + +## Windows 10 (WSL1) +WSL1 is the preferred terminal to build **pokeemerald**. The following instructions will explain how to install WSL1 (referred interchangeably as WSL). + +If WSL is **not installed**, then go to [Installing WSL1](#Installing-WSL1). Otherwise, if WSL is installed, but it hasn't previously been set up for another decompilation project, then go to [Setting up WSL1](#Setting-up-WSL1). Otherwise, open WSL and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-(WSL1)). ### Installing WSL1 Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Right Click or Shift+Insert is paste in the Powershell). @@ -14,7 +28,7 @@ dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux ``` Once the process finishes, restart your machine. -The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice. Advanced users can pick a preferred Linux distribution, but build instructions may differ. +The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice. Advanced users can pick a preferred Linux distribution, but setup instructions may differ. Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). @@ -39,6 +53,7 @@ sudo apt install build-essential binutils-arm-none-eabi git libpng-dev ``` (If the above command does not work, try the above command but replacing `apt` with `apt-get`). +### Choosing where to store pokeemerald (WSL1) WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to install pokeemerald within Windows. You'll have to change the **current working directory** every time you open WSL. For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: @@ -47,14 +62,103 @@ cd /mnt/c/Users//Desktop/decomps ``` Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. -(The Windows C:\ drive is called /mnt/c/ in WSL. Replace *\* in the example path with your **Windows** username, and the drive letter with the letter of the drive where you want to save pokeemerald. Windows path names are case-insensitive so adhereing to capitalization isn't needed) +(The Windows C:\ drive is called /mnt/c/ in WSL. Replace *\* in the example path with your **Windows** username. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. Windows path names are case-insensitive so adhereing to capitalization isn't needed) If this works, then proceed to [Installation](#Installation). -Otherwise, continue reading below for [the older Windows instructions](#windows). +Otherwise, continue reading below for [Windows instructions using msys2](#windows-(msys2)). -## Windows -TODO: add general Windows instructions +## Windows (msys2) + +If devkitPro is not installed, or is installed but without the GBA Development component, then go to [Installing devkitPro](#installing-devkitpro). If devkitPro is installed, but msys2 hasn't previously been set up for another decompilation project, then go to [Setting up msys2](#setting-up-msys2). Otherwise, open msys2 and go to [Choosing where to store pokeemerald (msys2)](#choosing-where-to-store-pokeemerald-(msys2)). + +### Installing devkitPro +Download the devkitPro installer [here](https://github.com/devkitPro/installer/releases). + +Run the devkitPro installer. In the "Choose Components" screen, uncheck everything except GBA Development unless if you plan to use devkitPro for other purposes. Keep the install location as C:\devkitPro and leave the Start Menu option unchanged. + +### Setting up msys2 +Open msys2 at C:\devkitPro\msys2\msys2_shell.bat. + +Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert. + +Certain packages are required to build pokeemerald. Install these by running the following command: +```bash +pacman -S make gcc zlib-devel git +``` +(This command will ask for confirmation, just enter the yes action when prompted). + +Download [libpng](https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.xz/download). + +Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at **C:\Users\\__**, where *\* is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: +```bash +cd Downloads +``` +(While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator. Windows path names are case-insensitive so adhereing to capitalization isn’t needed. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`. If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there) + +Run the following command to uncompress and install libpng. +```bash +tar xf libpng-1.6.37 +cd libpng-1.6.37 +./configure --prefix=/usr +make check +make install +``` +Then finally, run the following command to change back to the user profile folder. +```bash +cd +``` + +### Choosing where to store pokeemerald (msys2) +At this point, you can choose a folder to store pokeemerald into. If so, you'll have to change the **current working directory** every time you open msys2. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). + +For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: +```bash +cd Desktop/decomps +``` +Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. + +If this works, then proceed to [Installation](#Installation). + +Otherwise, continue reading below for [Windows instructions using Cygwin](#windows-(cygwin)). + +## Windows (Cygwin) +If devkitPro is not installed, or is installed but without the GBA Development component, then follow the instructions used to [install devkitPro](#installing-devkitpro) for the msys2 setup before continuing. + +If Cygwin is not installed, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin). Otherwise, go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-(cygwin)) + +### Installing Cygwin +Download [Cygwin](https://cygwin.com/install.html): setup-x86_64.exe for 64-bit Windows, setup-x86.exe for 32-bit. + +Run the Cygwin setup and leave the default settings. At "Select Packages", set the view to "Full" and choose to install the following: +- `make` +- `git` +- `gcc-core` +- `gcc-g++` +- `libpng-devel` + +To quickly find these, use the search bar and type the name of each package. Ensure that the selected package name is the **exact** same as the one you're trying to download, e.g. `cmake` is **NOT** the same as `make`. + +Double click on the text that says "**Skip**" next to each package to select the most recent version to install. If the text says anything other than "**Skip**", (e.g. Keep or a version number), then the package is or will be installed and you don't need to do anything. + +Once all required packages have been selected, finish the installation. + +### Choosing where to store pokeemerald (Cygwin) +Open **Cygwin**. + +Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert. + +Cygwin has its own file system that's within Windows, at **C:\cygwin64\home\\_\_**. If you don't want to store pokeemerald there, you'll have to change the **current working directory** every time you open Cygwin. + +For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: +```bash +cd c:/Users//Desktop/decomps +``` +Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. + +(Replace *\* in the example path with your **Windows** username. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. Windows path names are case-insensitive so adhereing to capitalization isn't needed) + +If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). ## macOS TODO: add macOS instructions @@ -63,17 +167,24 @@ TODO: add macOS instructions TODO: add Linux instructions ## Installation -To download the pokeemerald repository: +If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: ```bash git clone https://github.com/pret/pokeemerald ``` -If agbcc isn't built, run the following commands to build and install it into pokeemerald: +If agbcc has not been built before, run the following commands to build and install it into pokeemerald: ``` git clone https://github.com/pret/agbcc cd agbcc ./build.sh ./install.sh ../pokeemerald ``` +If agbcc has been built before, but was **last built on a different terminal** than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokeemerald: +``` +cd agbcc +git clean -fX +./build.sh +./install.sh ../pokeemerald +``` Otherwise, run the following commands to install agbcc into pokeemerald: ``` cd agbcc @@ -93,7 +204,7 @@ To build **pokeemerald.gba** for the first time and confirm it matches the offic ```bash make compare ``` -If an OK is returned, then the installation went smoothly. +If an OK is returned, then the installation went smoothly. **Note:** if you switched from Cygwin to msys2, you must run `make clean-tools` once before any subsequent `make` commands. To build **pokeemerald.gba** with your changes: ```bash diff --git a/Makefile b/Makefile index aa588445f2..bffa4b5609 100644 --- a/Makefile +++ b/Makefile @@ -235,7 +235,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@ ifeq ($(MODERN),0) -$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc +$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) $(C_BUILDDIR)/libc.o: CFLAGS := -O2 $(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork @@ -244,10 +244,10 @@ $(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 +$(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 +$(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 diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile index 77df291527..dd48a87597 100644 --- a/tools/aif2pcm/Makefile +++ b/tools/aif2pcm/Makefile @@ -6,12 +6,18 @@ LIBS = -lm SRCS = main.c extended.c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: aif2pcm +all: aif2pcm$(EXE) @: -aif2pcm: $(SRCS) +aif2pcm$(EXE): $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile index 52806e39c6..4dbfab94fe 100644 --- a/tools/bin2c/Makefile +++ b/tools/bin2c/Makefile @@ -6,10 +6,16 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 SRCS = bin2c.c -all: bin2c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: bin2c$(EXE) @: -bin2c: $(SRCS) +bin2c$(EXE): $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile index 91a60a9e4c..efb016c97e 100644 --- a/tools/gbafix/Makefile +++ b/tools/gbafix/Makefile @@ -3,10 +3,16 @@ CC ?= gcc SRCS = gbafix.c -all: gbafix +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: gbafix$(EXE) @: -gbafix: $(SRCS) +gbafix$(EXE): $(SRCS) $(CC) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile index f0638414da..b4244aa8d6 100644 --- a/tools/gbagfx/Makefile +++ b/tools/gbagfx/Makefile @@ -6,15 +6,21 @@ LIBS = -lpng -lz SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: gbagfx +all: gbagfx$(EXE) @: -gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS) -gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile index 47198b171e..eec73eb7bf 100755 --- a/tools/jsonproc/Makefile +++ b/tools/jsonproc/Makefile @@ -8,12 +8,18 @@ SRCS := jsonproc.cpp HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: jsonproc +all: jsonproc$(EXE) @: -jsonproc: $(SRCS) $(HEADERS) +jsonproc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile index c1f703f9fe..100e809c6c 100644 --- a/tools/mapjson/Makefile +++ b/tools/mapjson/Makefile @@ -6,12 +6,18 @@ SRCS := json11.cpp mapjson.cpp HEADERS := mapjson.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: mapjson +all: mapjson$(EXE) @: -mapjson: $(SRCS) $(HEADERS) +mapjson$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mid2agb/Makefile b/tools/mid2agb/Makefile index 451d4b39fb..553b7859ed 100644 --- a/tools/mid2agb/Makefile +++ b/tools/mid2agb/Makefile @@ -6,12 +6,18 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp HEADERS := agb.h error.h main.h midi.h tables.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: mid2agb +all: mid2agb$(EXE) @: -mid2agb: $(SRCS) $(HEADERS) +mid2agb$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile index 8c48afea2a..1507c973f2 100644 --- a/tools/preproc/Makefile +++ b/tools/preproc/Makefile @@ -8,12 +8,18 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ utf8.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: preproc +all: preproc$(EXE) @: -preproc: $(SRCS) $(HEADERS) +preproc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile index 4e901a29c1..a9375c87ab 100644 --- a/tools/ramscrgen/Makefile +++ b/tools/ramscrgen/Makefile @@ -8,10 +8,16 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h .PHONY: all clean -all: ramscrgen +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: ramscrgen$(EXE) @: -ramscrgen: $(SRCS) $(HEADERS) +ramscrgen$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile index 930a92b36e..0bc88a42b7 100644 --- a/tools/rsfont/Makefile +++ b/tools/rsfont/Makefile @@ -8,10 +8,16 @@ SRCS = main.c convert_png.c util.c font.c .PHONY: all clean -all: rsfont +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: rsfont$(EXE) @: -rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h +rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile index 52e663d8da..96d92f7062 100644 --- a/tools/scaninc/Makefile +++ b/tools/scaninc/Makefile @@ -8,10 +8,16 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h .PHONY: all clean -all: scaninc +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: scaninc$(EXE) @: -scaninc: $(SRCS) $(HEADERS) +scaninc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: From 3d0f0384237185d4fdab5efedd82d2ae25c1918d Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Sat, 28 Nov 2020 11:30:11 -0500 Subject: [PATCH 08/43] Add install instructions for repositories which don't have dkp-less support. --- INSTALL.md | 2 ++ docs/legacy_WSL1_INSTALL.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 docs/legacy_WSL1_INSTALL.md diff --git a/INSTALL.md b/INSTALL.md index f50ea1db76..4ac4690c0f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -47,6 +47,8 @@ sudo apt update && sudo apt upgrade ``` Note that these commands will likely take a long time to finish. +*Note: If the repository you plan to build was created before 2020/XX/YY (e.g. modifications of pokeemerald that haven't updated) then follow the [legacy WSL1 instructions](docs/legacy_WSL1_INSTALL.md). These repositories can be identified by the [older revision](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md) of the INSTALL.md* + Certain packages are required to build pokeemerald. Install these packages by running the following command: ```bash sudo apt install build-essential binutils-arm-none-eabi git libpng-dev diff --git a/docs/legacy_WSL1_INSTALL.md b/docs/legacy_WSL1_INSTALL.md new file mode 100644 index 0000000000..f9ed7b0e21 --- /dev/null +++ b/docs/legacy_WSL1_INSTALL.md @@ -0,0 +1,32 @@ +### Setting up WSL1 (Legacy Portion) +Certain packages are required to build pokeemerald. Install these packages by running the following command: +```bash +sudo apt install build-essential git libpng-dev gdebi-core +``` +(If the above command does not work, try the above command but replacing `apt` with `apt-get`). + +Download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. + +WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. To install the devkitPro package, you'll need to change to the **current working directory** where the package file was saved. + +For example, if the package file was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: + +```bash +cd /mnt/c/Users//Downloads +``` + +(The Windows C:\ drive is called /mnt/c/ in WSL. Replace in the example path with your **Windows** username. Windows path names are case-insensitive so adhereing to capitalization isn't needed) + +Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. +```bash +sudo gdebi devkitpro-pacman.amd64.deb +sudo dkp-pacman -Sy +sudo dkp-pacman -S gba-dev +``` +Note: the last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + +Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL): +```bash +source /etc/profile.d/devkit-env.sh +``` +Proceed to [Choosing where to store pokeemerald (WSL1) of the current INSTALL.md](/INSTALL.md#choosing-where-to-store-pokeemerald-(WSL1)). From b9eb605fbf07b0f27917e83b302074abd2f681d0 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Sat, 28 Nov 2020 11:34:03 -0500 Subject: [PATCH 09/43] Fix broken header links. --- INSTALL.md | 14 +++++++------- docs/legacy_WSL1_INSTALL.md | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 4ac4690c0f..14469ff104 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -7,8 +7,8 @@ If you run into trouble, ask for help on IRC or Discord (see [README.md](README. ## Windows Windows has instructions for building with three possible terminals, if users encounter unexpected errors in following instructions for one of the terminals. These instructions are: - [Windows 10 (WSL1)](#windows-10-wsl1) -- [Windows (msys2)](#windows-(msys2)) -- [Windows (Cygwin)](#windows-(cygwin)) +- [Windows (msys2)](#windows-msys2) +- [Windows (Cygwin)](#windows-cygwin) The instructions have been ordered by the performance of their respective terminal. Out of the provided terminals, **WSL1** builds pokeemerald the fastest, and is thus **highly recommended**, but is only available on Windows 10. **msys2** is the second fastest, and **Cygwin** is the slowest. For advanced users, **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools such as [porymap](https://github.com/huderlem/porymap) cannot interact with said files due to problems [outside the control of maintainers](https://bugreports.qt.io/browse/QTBUG-86277). @@ -19,7 +19,7 @@ All of the Windows instructions assume that the default drive is C:\\. If this d ## Windows 10 (WSL1) WSL1 is the preferred terminal to build **pokeemerald**. The following instructions will explain how to install WSL1 (referred interchangeably as WSL). -If WSL is **not installed**, then go to [Installing WSL1](#Installing-WSL1). Otherwise, if WSL is installed, but it hasn't previously been set up for another decompilation project, then go to [Setting up WSL1](#Setting-up-WSL1). Otherwise, open WSL and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-(WSL1)). +If WSL is **not installed**, then go to [Installing WSL1](#Installing-WSL1). Otherwise, if WSL is installed, but it hasn't previously been set up for another decompilation project, then go to [Setting up WSL1](#Setting-up-WSL1). Otherwise, open WSL and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-WSL1). ### Installing WSL1 Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Right Click or Shift+Insert is paste in the Powershell). @@ -68,11 +68,11 @@ Note that the directory **must exist** in Windows. If you want to store pokeemer If this works, then proceed to [Installation](#Installation). -Otherwise, continue reading below for [Windows instructions using msys2](#windows-(msys2)). +Otherwise, continue reading below for [Windows instructions using msys2](#windows-msys2). ## Windows (msys2) -If devkitPro is not installed, or is installed but without the GBA Development component, then go to [Installing devkitPro](#installing-devkitpro). If devkitPro is installed, but msys2 hasn't previously been set up for another decompilation project, then go to [Setting up msys2](#setting-up-msys2). Otherwise, open msys2 and go to [Choosing where to store pokeemerald (msys2)](#choosing-where-to-store-pokeemerald-(msys2)). +If devkitPro is not installed, or is installed but without the GBA Development component, then go to [Installing devkitPro](#installing-devkitpro). If devkitPro is installed, but msys2 hasn't previously been set up for another decompilation project, then go to [Setting up msys2](#setting-up-msys2). Otherwise, open msys2 and go to [Choosing where to store pokeemerald (msys2)](#choosing-where-to-store-pokeemerald-msys2). ### Installing devkitPro Download the devkitPro installer [here](https://github.com/devkitPro/installer/releases). @@ -122,12 +122,12 @@ Note that the directory **must exist** in Windows. If you want to store pokeemer If this works, then proceed to [Installation](#Installation). -Otherwise, continue reading below for [Windows instructions using Cygwin](#windows-(cygwin)). +Otherwise, continue reading below for [Windows instructions using Cygwin](#windows-cygwin). ## Windows (Cygwin) If devkitPro is not installed, or is installed but without the GBA Development component, then follow the instructions used to [install devkitPro](#installing-devkitpro) for the msys2 setup before continuing. -If Cygwin is not installed, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin). Otherwise, go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-(cygwin)) +If Cygwin is not installed, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin). Otherwise, go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-cygwin) ### Installing Cygwin Download [Cygwin](https://cygwin.com/install.html): setup-x86_64.exe for 64-bit Windows, setup-x86.exe for 32-bit. diff --git a/docs/legacy_WSL1_INSTALL.md b/docs/legacy_WSL1_INSTALL.md index f9ed7b0e21..5e2a7e1679 100644 --- a/docs/legacy_WSL1_INSTALL.md +++ b/docs/legacy_WSL1_INSTALL.md @@ -29,4 +29,4 @@ Run the following command to set devkitPro related environment variables (altern ```bash source /etc/profile.d/devkit-env.sh ``` -Proceed to [Choosing where to store pokeemerald (WSL1) of the current INSTALL.md](/INSTALL.md#choosing-where-to-store-pokeemerald-(WSL1)). +Proceed to [Choosing where to store pokeemerald (WSL1) of the current INSTALL.md](/INSTALL.md#choosing-where-to-store-pokeemerald-WSL1). From 47d4ff24483abbd416598055f8a5867ff7723378 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Sat, 28 Nov 2020 11:38:02 -0500 Subject: [PATCH 10/43] Add case for downloads folder with space for the legacy WSL1 instructions, also fix WSL1 path in dedicated folder example with spaces. --- INSTALL.md | 2 +- docs/legacy_WSL1_INSTALL.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 14469ff104..f096ad6bc5 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -64,7 +64,7 @@ cd /mnt/c/Users//Desktop/decomps ``` Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. -(The Windows C:\ drive is called /mnt/c/ in WSL. Replace *\* in the example path with your **Windows** username. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. Windows path names are case-insensitive so adhereing to capitalization isn't needed) +(The Windows C:\ drive is called /mnt/c/ in WSL. Replace *\* in the example path with your **Windows** username. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Desktop/decomp folder"`. Windows path names are case-insensitive so adhereing to capitalization isn't needed) If this works, then proceed to [Installation](#Installation). diff --git a/docs/legacy_WSL1_INSTALL.md b/docs/legacy_WSL1_INSTALL.md index 5e2a7e1679..731b8f4338 100644 --- a/docs/legacy_WSL1_INSTALL.md +++ b/docs/legacy_WSL1_INSTALL.md @@ -15,7 +15,7 @@ For example, if the package file was saved to **C:\Users\\_\_\Downloads** cd /mnt/c/Users//Downloads ``` -(The Windows C:\ drive is called /mnt/c/ in WSL. Replace in the example path with your **Windows** username. Windows path names are case-insensitive so adhereing to capitalization isn't needed) +(The Windows C:\ drive is called /mnt/c/ in WSL. Replace in the example path with your **Windows** username. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Downloads folder"`. Windows path names are case-insensitive so adhereing to capitalization isn't needed) Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. ```bash From 24d94185b9857d68f96665ff4205e8086789838b Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Sat, 28 Nov 2020 11:42:45 -0500 Subject: [PATCH 11/43] Fix typo (thanks Spherical Ice). --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index f096ad6bc5..05c914ea2a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -12,7 +12,7 @@ Windows has instructions for building with three possible terminals, if users en The instructions have been ordered by the performance of their respective terminal. Out of the provided terminals, **WSL1** builds pokeemerald the fastest, and is thus **highly recommended**, but is only available on Windows 10. **msys2** is the second fastest, and **Cygwin** is the slowest. For advanced users, **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools such as [porymap](https://github.com/huderlem/porymap) cannot interact with said files due to problems [outside the control of maintainers](https://bugreports.qt.io/browse/QTBUG-86277). -All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct the drive letter when reading the instructions. +All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions. **A note of caution**: As Windows 7 is officially unsupported by Microsoft and Windows 8 has very little usage, some maintainers are unwilling to maintain the Windows 7/8 instructions. Thus, these instructions may break in the future with fixes taking longer than fixes to the Windows 10 instructions. From 680187d7d9ca1e5b4088c9a9180df34b62b1bfd0 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 14 Dec 2020 02:16:25 -0500 Subject: [PATCH 12/43] Add more detailed notes on Windows terminal comparisons, fix Cygwin instructions (didn't export devkitpro), add macOS and Linux instructions. macOS and Linux instructions untested. --- INSTALL.md | 94 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 9 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 05c914ea2a..c4e0a6e4c9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -10,7 +10,7 @@ Windows has instructions for building with three possible terminals, if users en - [Windows (msys2)](#windows-msys2) - [Windows (Cygwin)](#windows-cygwin) -The instructions have been ordered by the performance of their respective terminal. Out of the provided terminals, **WSL1** builds pokeemerald the fastest, and is thus **highly recommended**, but is only available on Windows 10. **msys2** is the second fastest, and **Cygwin** is the slowest. For advanced users, **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools such as [porymap](https://github.com/huderlem/porymap) cannot interact with said files due to problems [outside the control of maintainers](https://bugreports.qt.io/browse/QTBUG-86277). +The instructions have been ordered by the performance of their respective terminal. Out of the provided terminals, **WSL1** builds pokeemerald the fastest, and is thus **highly recommended**, but is only available on Windows 10. **msys2** is the second fastest, and **Cygwin** is the slowest. Unscientific benchmarks suggest msys2 is 2x slower than WSL1, and Cygwin is **5-6x** slower than WSL1. For advanced users, **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools such as [porymap](https://github.com/huderlem/porymap) cannot interact with said files due to problems [outside the control of maintainers](https://bugreports.qt.io/browse/QTBUG-86277). All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions. @@ -125,14 +125,14 @@ If this works, then proceed to [Installation](#Installation). Otherwise, continue reading below for [Windows instructions using Cygwin](#windows-cygwin). ## Windows (Cygwin) -If devkitPro is not installed, or is installed but without the GBA Development component, then follow the instructions used to [install devkitPro](#installing-devkitpro) for the msys2 setup before continuing. +If devkitPro is not installed, or is installed but without the GBA Development component, then follow the instructions used to [install devkitPro](#installing-devkitpro) for the msys2 setup before continuing. Remember to not continue following the msys2 instructions by mistake! -If Cygwin is not installed, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin). Otherwise, go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-cygwin) +If Cygwin is not installed, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin). If Cygwin is installed, but is not configured to work with devkitPro, then go to [Configuring devkitPro for Cygwin](#configuring-devkitpro-for-cygwin). Otherwise, open Cygwin and go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-cygwin) ### Installing Cygwin Download [Cygwin](https://cygwin.com/install.html): setup-x86_64.exe for 64-bit Windows, setup-x86.exe for 32-bit. -Run the Cygwin setup and leave the default settings. At "Select Packages", set the view to "Full" and choose to install the following: +Run the Cygwin setup and leave the default settings. At "Choose a Download Site", select any mirror within the Available Download Sites. At "Select Packages", set the view to "Full" (top left) and choose to install the following: - `make` - `git` - `gcc-core` @@ -144,12 +144,22 @@ To quickly find these, use the search bar and type the name of each package. Ens Double click on the text that says "**Skip**" next to each package to select the most recent version to install. If the text says anything other than "**Skip**", (e.g. Keep or a version number), then the package is or will be installed and you don't need to do anything. Once all required packages have been selected, finish the installation. - -### Choosing where to store pokeemerald (Cygwin) +### Configuring devkitPro for Cygwin Open **Cygwin**. Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert. +Run the following commands to configure devkitPro to work with Cygwin. +```bash +export DEVKITPRO=/cygdrive/c/devkitpro +echo export DEVKITPRO=$DEVKITPRO >> ~/.bashrc +export DEVKITARM=$DEVKITPRO/devkitARM +echo export DEVKITARM=$DEVKITARM >> ~/.bashrc +``` +(Replace the drive letter c with the actual drive letter if it is not c). + +### Choosing where to store pokeemerald (Cygwin) + Cygwin has its own file system that's within Windows, at **C:\cygwin64\home\\_\_**. If you don't want to store pokeemerald there, you'll have to change the **current working directory** every time you open Cygwin. For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: @@ -163,10 +173,76 @@ Note that the directory **must exist** in Windows. If you want to store pokeemer If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). ## macOS -TODO: add macOS instructions +The [Xcode Command Line Tools Package](https://developer.apple.com/library/archive/technotes/tn2339/_index.html) is required. Open your Terminal and run the following command: +```bash +xcode-select --install +``` + +If devkitPro is not installed, then go to [Installing devkitPro (macOS)](#installing-devkitpro-macos). Otherwise, open the Terminal and go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos) + +### Installing devkitPro (macOS) +Download the `devkitpro-pacman-installer.pkg` package from [here](https://github.com/devkitPro/pacman/releases). + +Run the `open` command to install the devkitPro package. The command arguments depend on where the package was saved to. For example, if the package was saved to `~/Downloads` (the Downloads location for most users), enter this command: +```bash +open ~/Downloads/devkitpro-pacman-installer.pkg +``` +(If the path has spaces, then the path must be wrapped with quotations, e.g. "~/Downloads/My Downloads/devkitpro-pacman-installer.pkg"). + +Now devkitPro must be configured with the tools required for GBA development. Run the following commands: +```bash +sudo dkp-pacman -Sy +sudo dkp-pacman -S gba-dev +sudo dkp-pacman -S devkitarm-rules +``` +At this point, press Enter to confirm the installation. After the tools are installed, devkitPro must now be made accessible from anywhere by the system. To do so, run the following commands: + +``` +export DEVKITPRO=$HOME/devkitpro +echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc +export DEVKITARM=$DEVKITPRO/devkitARM +echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc + +echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile +``` + +### Choosing where to store pokeemerald (macOS) +At this point, you can choose a folder to store pokeemerald into. If so, you'll have to change the **current working directory** every time you open the Terminal. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). + +For example, if you want to store pokeemerald (and agbcc) in **~/Desktop/decomps**, enter this command: +```bash +cd Desktop/decomps +``` +Note that the directory **must exist** in the folder system. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the `cd` command. + +If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). ## Linux -TODO: add Linux instructions +Open Terminal and enter the following commands, depending on which distro you're using. + +### Debian or Ubuntu +Run the following command to install the necessary packages: +```bash +sudo apt install build-essential binutils-arm-none-eabi git libpng-dev +``` +Then proceed to [Choosing where to store pokeemerald (Linux)](#choosing-where-to-store-pokeemerald-linux). + +### Other distributions +_(Instructions for other distributions would be greatly appreciated!)_ + +If your distro is not listed here, try to find the required software in its repositories: +- `gcc` +- `g++` +- `make` +- `git` +- `libpng-dev` + +Then, install the devkitARM toolchain of [devkitPro](https://devkitpro.org/wiki/Getting_Started) as per the instructions on their wiki. + +### Choosing where to store pokeemerald (Linux) +At this point, you can choose a folder to store pokeemerald (and agbcc) into. If so, you'll have to change the current working directory every time you open the Terminal. + +If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). ## Installation If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: @@ -295,4 +371,4 @@ To compile the `modern` target with this toolchain, the subdirectories `lib`, `i * [porymap](https://github.com/huderlem/porymap) for viewing and editing maps * [poryscript](https://github.com/huderlem/poryscript) for scripting ([VS Code extension](https://marketplace.visualstudio.com/items?itemName=karathan.poryscript)) -* [Tilemap Studio](https://github.com/Rangi42/tilemap-studio) for viewing and editing tilemaps +* [Tilemap Studio](https://github.com/Rangi42/tilemap-studio) for viewing and editing tilemaps \ No newline at end of file From 30bd712fd401a9aace68e9f2571cf11ae7eb9731 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 14 Dec 2020 02:20:07 -0500 Subject: [PATCH 13/43] Temporarily change repo links to mine for people testing builds. --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index c4e0a6e4c9..b263cc52f2 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -247,11 +247,11 @@ If this works, then proceed to [Installation](#Installation). Otherwise, ask for ## Installation If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: ```bash -git clone https://github.com/pret/pokeemerald +git clone https://github.com/luckytyphlosion/pokeemerald ``` If agbcc has not been built before, run the following commands to build and install it into pokeemerald: ``` -git clone https://github.com/pret/agbcc +git clone https://github.com/luckytyphlosion/agbcc cd agbcc ./build.sh ./install.sh ../pokeemerald From 4ecbb91ccb609a83d82665d476d22228a1f88762 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:46:10 -0500 Subject: [PATCH 14/43] Simplify macOS instructions, clarify Linux instructions, general cleanup of macOS and Linux instructions, also some other minor clarifications. --- INSTALL.md | 64 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index b263cc52f2..ecbce35a26 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -19,7 +19,7 @@ All of the Windows instructions assume that the default drive is C:\\. If this d ## Windows 10 (WSL1) WSL1 is the preferred terminal to build **pokeemerald**. The following instructions will explain how to install WSL1 (referred interchangeably as WSL). -If WSL is **not installed**, then go to [Installing WSL1](#Installing-WSL1). Otherwise, if WSL is installed, but it hasn't previously been set up for another decompilation project, then go to [Setting up WSL1](#Setting-up-WSL1). Otherwise, open WSL and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-WSL1). +If WSL (Debian or Ubuntu) is **not installed**, then go to [Installing WSL1](#Installing-WSL1). Otherwise, if WSL is installed, but it hasn't previously been set up for another decompilation project, then go to [Setting up WSL1](#Setting-up-WSL1). Otherwise, open WSL and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-WSL1). ### Installing WSL1 Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Right Click or Shift+Insert is paste in the Powershell). @@ -28,7 +28,7 @@ dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux ``` Once the process finishes, restart your machine. -The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice. Advanced users can pick a preferred Linux distribution, but setup instructions may differ. +The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice (Note for advanced users: Debian also works here). Advanced users can pick a preferred Linux distribution, but setup instructions may differ. Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). @@ -173,7 +173,7 @@ Note that the directory **must exist** in Windows. If you want to store pokeemer If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). ## macOS -The [Xcode Command Line Tools Package](https://developer.apple.com/library/archive/technotes/tn2339/_index.html) is required. Open your Terminal and run the following command: +If the Xcode Command Line Tools are not installed, download the tools [here](https://developer.apple.com/library/archive/technotes/tn2339/_index.html), open your Terminal, and run the following command: ```bash xcode-select --install ``` @@ -183,13 +183,9 @@ If devkitPro is not installed, then go to [Installing devkitPro (macOS)](#instal ### Installing devkitPro (macOS) Download the `devkitpro-pacman-installer.pkg` package from [here](https://github.com/devkitPro/pacman/releases). -Run the `open` command to install the devkitPro package. The command arguments depend on where the package was saved to. For example, if the package was saved to `~/Downloads` (the Downloads location for most users), enter this command: -```bash -open ~/Downloads/devkitpro-pacman-installer.pkg -``` -(If the path has spaces, then the path must be wrapped with quotations, e.g. "~/Downloads/My Downloads/devkitpro-pacman-installer.pkg"). +Open the package to install devkitPro pacman. -Now devkitPro must be configured with the tools required for GBA development. Run the following commands: +devkitPro must be configured with the tools required for GBA development. Run the following commands: ```bash sudo dkp-pacman -Sy sudo dkp-pacman -S gba-dev @@ -207,7 +203,7 @@ echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile ``` ### Choosing where to store pokeemerald (macOS) -At this point, you can choose a folder to store pokeemerald into. If so, you'll have to change the **current working directory** every time you open the Terminal. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). +At this point, you can choose a folder to store pokeemerald into. If so, you'll have to change the **current working directory** every time you open the Terminal. If you're okay with storing pokeemerald in the user folder, then proceed to [Installation](#installation). For example, if you want to store pokeemerald (and agbcc) in **~/Desktop/decomps**, enter this command: ```bash @@ -215,12 +211,14 @@ cd Desktop/decomps ``` Note that the directory **must exist** in the folder system. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the `cd` command. +(If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"`) + If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). ## Linux Open Terminal and enter the following commands, depending on which distro you're using. -### Debian or Ubuntu +### Debian/Ubuntu-based distributions Run the following command to install the necessary packages: ```bash sudo apt install build-essential binutils-arm-none-eabi git libpng-dev @@ -228,16 +226,23 @@ sudo apt install build-essential binutils-arm-none-eabi git libpng-dev Then proceed to [Choosing where to store pokeemerald (Linux)](#choosing-where-to-store-pokeemerald-linux). ### Other distributions -_(Instructions for other distributions would be greatly appreciated!)_ +_(Specific instructions for other distributions would be greatly appreciated!)_ -If your distro is not listed here, try to find the required software in its repositories: +Try to find the required software in its repositories: - `gcc` - `g++` - `make` - `git` - `libpng-dev` -Then, install the devkitARM toolchain of [devkitPro](https://devkitpro.org/wiki/Getting_Started) as per the instructions on their wiki. +Then, follow the instructions [here](https://devkitpro.org/wiki/devkitPro_pacman) to install devkitPro's pacman installer. As a reminder, the goal is to configure an existing pacman installation to recognize devkitPro's repositories. + +Once devkitPro pacman is configured, run the following commands: +```bash +sudo pacman -Sy +sudo pacman -S gba-dev +``` +Note: the last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. ### Choosing where to store pokeemerald (Linux) At this point, you can choose a folder to store pokeemerald (and agbcc) into. If so, you'll have to change the current working directory every time you open the Terminal. @@ -256,7 +261,7 @@ cd agbcc ./build.sh ./install.sh ../pokeemerald ``` -If agbcc has been built before, but was **last built on a different terminal** than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokeemerald: +If agbcc has been built before (e.g. if the git clone above fails), but was **last built on a different terminal** than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokeemerald: ``` cd agbcc git clean -fX @@ -278,11 +283,11 @@ First, change directory to the pokeemerald folder: ```bash cd pokeemerald ``` -To build **pokeemerald.gba** for the first time and confirm it matches the official ROM image: +To build **pokeemerald.gba** for the first time and confirm it matches the official ROM image (Note: to speed up builds, see [Parallel builds](#parallel-builds)): ```bash make compare ``` -If an OK is returned, then the installation went smoothly. **Note:** if you switched from Cygwin to msys2, you must run `make clean-tools` once before any subsequent `make` commands. +If an OK is returned, then the installation went smoothly. **Note:** if you switched terminals on Windows since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands. To build **pokeemerald.gba** with your changes: ```bash @@ -291,8 +296,6 @@ make **Windows users:** Consider adding an exception for the `pokeemerald` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. -**macOS users (this is probably outdated):** If the base tools are not found in new Terminal sessions after the first successful build, run `echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile` once to prevent the issue from occurring again. Verify that the `devkitarm-rules` package is installed as well; if not, install it by running `sudo dkp-pacman -S devkitarm-rules`. - # Building guidance ## Parallel builds @@ -320,7 +323,7 @@ make DINFO=1 ## devkitARM's C compiler -This project supports the `arm-none-eabi-gcc` compiler included with devkitARM. If devkitARM has already been installed as part of the platform-specific instructions, simply run: +This project supports the `arm-none-eabi-gcc` compiler included with devkitARM. If devkitARM (a.k.a. gba-dev) has already been installed as part of the platform-specific instructions, simply run: ```bash make modern ``` @@ -355,6 +358,27 @@ source /etc/profile.d/devkit-env.sh ``` devkitARM is now installed. +### Installing devkitARM on Debian/Ubuntu-based distributions +If `gdebi-core` is not installed, run the following command: +```bash +sudo apt install gdebi-core +``` +Download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. + +Change directory to where the package was downloaded. Then, run the following commands to install devkitARM: +```bash +sudo gdebi devkitpro-pacman.amd64.deb +sudo dkp-pacman -Sy +sudo dkp-pacman -S gba-dev +``` +Note: the last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + +Run the following command to set devkitPro related environment variables (alternatively, close and re-open the Terminal): +```bash +source /etc/profile.d/devkit-env.sh +``` +devkitARM is now installed. + ## Other toolchains To build using a toolchain other than devkitARM, override the `TOOLCHAIN` environment variable with the path to your toolchain, which must contain the subdirectory `bin`. From aad94c34334ee44f1298175df38f14dc27ae5fb8 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 13:15:54 -0500 Subject: [PATCH 15/43] Fix asmdiff.sh to work without DKP, also improve the makefile command for recognizing a toolchain. The new command requires the toolchain binary path to exist in the file system before building using a toolchain (to handle the case where gba-dev is uninstalled but $(DEVKITARM) still exists)) --- Makefile | 2 +- asmdiff.sh | 7 ++++++- berry_fix/Makefile | 2 +- berry_fix/payload/Makefile | 2 +- libagbsyscall/Makefile | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index bffa4b5609..de146726bf 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ COMPARE ?= 0 # files, or use arm-none-eabi binaries on the system # if dkP is not installed on tihs system -ifneq ($(TOOLCHAIN),) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) endif diff --git a/asmdiff.sh b/asmdiff.sh index 9e8749acff..534281fdf5 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -1,6 +1,11 @@ #!/bin/bash -OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" +if [[ -d "$DEVKITARM/bin/" ]]; then + OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump" +else + OBJDUMP_BIN="arm-none-eabi-objdump" +fi +OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb" OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" $OBJDUMP $OPTIONS baserom.gba > baserom.dump $OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump diff --git a/berry_fix/Makefile b/berry_fix/Makefile index f7ce405047..6aab4ed624 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -8,7 +8,7 @@ COMPARE ?= 0 # files, or use arm-none-eabi binaries on the system # if dkP is not installed on tihs system -ifneq ($(TOOLCHAIN),) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) endif diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index 7a6a923960..ad8787c347 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -8,7 +8,7 @@ COMPARE ?= 0 # files, or use arm-none-eabi binaries on the system # if dkP is not installed on tihs system -ifneq ($(TOOLCHAIN),) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) endif diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index ba349e9ebb..e1f502b2f8 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -8,7 +8,7 @@ COMPARE ?= 0 # files, or use arm-none-eabi binaries on the system # if dkP is not installed on tihs system -ifneq ($(TOOLCHAIN),) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) endif From cc5db41f30708c1cc2d33a46879c96a9404764a3 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 13:29:02 -0500 Subject: [PATCH 16/43] Revert multiple source change commits for rebase. --- Makefile | 89 ++++++++++++++++---------------------- asmdiff.sh | 7 +-- berry_fix/Makefile | 35 ++++++++------- berry_fix/payload/Makefile | 35 ++++++++------- libagbsyscall/Makefile | 35 ++++++++------- map_data_rules.mk | 4 +- tools/aif2pcm/Makefile | 10 +---- tools/bin2c/Makefile | 10 +---- tools/gbafix/Makefile | 10 +---- tools/gbagfx/Makefile | 12 ++--- tools/jsonproc/Makefile | 10 +---- tools/mapjson/Makefile | 10 +---- tools/mid2agb/Makefile | 10 +---- tools/preproc/Makefile | 10 +---- tools/ramscrgen/Makefile | 10 +---- tools/rsfont/Makefile | 10 +---- tools/scaninc/Makefile | 10 +---- 17 files changed, 121 insertions(+), 196 deletions(-) diff --git a/Makefile b/Makefile index de146726bf..07143e4ad4 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system - -ifneq ($(wildcard $(TOOLCHAIN)/bin),) -export PATH := $(TOOLCHAIN)/bin:$(PATH) +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) endif +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else +export PATH := $(TOOLCHAIN)/bin:$(PATH) PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe @@ -34,16 +37,6 @@ MAKER_CODE := 01 REVISION := 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 ELF = $(ROM:.gba=.elf) @@ -71,18 +64,18 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -ROM := $(ROM_NAME) -OBJ_DIR := $(OBJ_DIR_NAME) +ROM := pokeemerald.gba +OBJ_DIR := build/emerald LIBPATH := -L ../../tools/agbcc/lib else -CC1 = $(shell $(MODERNCC) --print-prog-name=cc1) -quiet +CC1 = $(shell $(CC) --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 -ROM := $(MODERN_ROM_NAME) -OBJ_DIR := $(MODERN_OBJ_DIR_NAME) -LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))" +ROM := pokeemerald_modern.gba +OBJ_DIR := build/modern +LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" endif -CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -nostdinc -undef +CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) ifeq ($(MODERN),0) CPPFLAGS += -I tools/agbcc/include -I tools/agbcc endif @@ -118,7 +111,7 @@ 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: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) @@ -169,7 +162,7 @@ all: rom tools: $(TOOLDIRS) $(TOOLDIRS): - @$(MAKE) -C $@ + @$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX) rom: $(ROM) ifeq ($(COMPARE),1) @@ -184,7 +177,7 @@ clean: mostlyclean clean-tools clean-tools: @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) -mostlyclean: tidynonmodern tidymodern +mostlyclean: tidy rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin rm -f $(MID_SUBDIR)/*.s @@ -199,15 +192,10 @@ mostlyclean: tidynonmodern tidymodern tidy: rm -f $(ROM) $(ELF) $(MAP) 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) $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member endif @@ -235,7 +223,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@ ifeq ($(MODERN),0) -$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) +$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc $(C_BUILDDIR)/libc.o: CFLAGS := -O2 $(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork @@ -244,10 +232,10 @@ $(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)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc $(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding -$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm$(EXE) +$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm $(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 @@ -308,11 +296,11 @@ endif ifeq ($(NODEP),1) $(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 define DATA_ASM_DEP $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 $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif @@ -341,8 +329,7 @@ $(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 ../../$@ " - @cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + 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) diff --git a/asmdiff.sh b/asmdiff.sh index 534281fdf5..9e8749acff 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -1,11 +1,6 @@ #!/bin/bash -if [[ -d "$DEVKITARM/bin/" ]]; then - OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump" -else - OBJDUMP_BIN="arm-none-eabi-objdump" -fi -OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb" +OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" $OBJDUMP $OPTIONS baserom.gba > baserom.dump $OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 6aab4ed624..0ead3804fd 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,26 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system - -ifneq ($(wildcard $(TOOLCHAIN)/bin),) -export PATH := $(TOOLCHAIN)/bin:$(PATH) +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) endif +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else +export PATH := $(TOOLCHAIN)/bin:$(PATH) PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index ad8787c347..a121fda93b 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,26 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system - -ifneq ($(wildcard $(TOOLCHAIN)/bin),) -export PATH := $(TOOLCHAIN)/bin:$(PATH) +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) endif +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else +export PATH := $(TOOLCHAIN)/bin:$(PATH) PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index e1f502b2f8..911cdb237c 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -1,26 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system - -ifneq ($(wildcard $(TOOLCHAIN)/bin),) -export PATH := $(TOOLCHAIN)/bin:$(PATH) +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) endif +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else +export PATH := $(TOOLCHAIN)/bin:$(PATH) PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/map_data_rules.mk b/map_data_rules.mk index 626cd47240..0203b383d0 100755 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -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)) $(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) - $(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 $(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile index dd48a87597..77df291527 100644 --- a/tools/aif2pcm/Makefile +++ b/tools/aif2pcm/Makefile @@ -6,18 +6,12 @@ LIBS = -lm SRCS = main.c extended.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: aif2pcm$(EXE) +all: aif2pcm @: -aif2pcm$(EXE): $(SRCS) +aif2pcm: $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile index 4dbfab94fe..52806e39c6 100644 --- a/tools/bin2c/Makefile +++ b/tools/bin2c/Makefile @@ -6,16 +6,10 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 SRCS = bin2c.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: bin2c$(EXE) +all: bin2c @: -bin2c$(EXE): $(SRCS) +bin2c: $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile index efb016c97e..91a60a9e4c 100644 --- a/tools/gbafix/Makefile +++ b/tools/gbafix/Makefile @@ -3,16 +3,10 @@ CC ?= gcc SRCS = gbafix.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: gbafix$(EXE) +all: gbafix @: -gbafix$(EXE): $(SRCS) +gbafix: $(SRCS) $(CC) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile index b4244aa8d6..f0638414da 100644 --- a/tools/gbagfx/Makefile +++ b/tools/gbagfx/Makefile @@ -6,21 +6,15 @@ LIBS = -lpng -lz SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: gbagfx$(EXE) +all: gbagfx @: -gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS) -gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile index eec73eb7bf..47198b171e 100755 --- a/tools/jsonproc/Makefile +++ b/tools/jsonproc/Makefile @@ -8,18 +8,12 @@ SRCS := jsonproc.cpp HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: jsonproc$(EXE) +all: jsonproc @: -jsonproc$(EXE): $(SRCS) $(HEADERS) +jsonproc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile index 100e809c6c..c1f703f9fe 100644 --- a/tools/mapjson/Makefile +++ b/tools/mapjson/Makefile @@ -6,18 +6,12 @@ SRCS := json11.cpp mapjson.cpp HEADERS := mapjson.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: mapjson$(EXE) +all: mapjson @: -mapjson$(EXE): $(SRCS) $(HEADERS) +mapjson: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mid2agb/Makefile b/tools/mid2agb/Makefile index 553b7859ed..451d4b39fb 100644 --- a/tools/mid2agb/Makefile +++ b/tools/mid2agb/Makefile @@ -6,18 +6,12 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp HEADERS := agb.h error.h main.h midi.h tables.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: mid2agb$(EXE) +all: mid2agb @: -mid2agb$(EXE): $(SRCS) $(HEADERS) +mid2agb: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile index 1507c973f2..8c48afea2a 100644 --- a/tools/preproc/Makefile +++ b/tools/preproc/Makefile @@ -8,18 +8,12 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ utf8.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: preproc$(EXE) +all: preproc @: -preproc$(EXE): $(SRCS) $(HEADERS) +preproc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile index a9375c87ab..4e901a29c1 100644 --- a/tools/ramscrgen/Makefile +++ b/tools/ramscrgen/Makefile @@ -8,16 +8,10 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: ramscrgen$(EXE) +all: ramscrgen @: -ramscrgen$(EXE): $(SRCS) $(HEADERS) +ramscrgen: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile index 0bc88a42b7..930a92b36e 100644 --- a/tools/rsfont/Makefile +++ b/tools/rsfont/Makefile @@ -8,16 +8,10 @@ SRCS = main.c convert_png.c util.c font.c .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: rsfont$(EXE) +all: rsfont @: -rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h +rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile index 96d92f7062..52e663d8da 100644 --- a/tools/scaninc/Makefile +++ b/tools/scaninc/Makefile @@ -8,16 +8,10 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: scaninc$(EXE) +all: scaninc @: -scaninc$(EXE): $(SRCS) $(HEADERS) +scaninc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: From 936ba7f1bf492a805596716660cd751e35fc74cd Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 15:10:01 -0500 Subject: [PATCH 17/43] Apply all source related changes for the new INSTALL.md in one commit. For people who want to have dkPless builds in their repo. --- Makefile | 89 ++++++++++++++++++++++---------------- asmdiff.sh | 10 ++++- berry_fix/Makefile | 35 +++++++-------- berry_fix/payload/Makefile | 35 +++++++-------- libagbsyscall/Makefile | 35 +++++++-------- map_data_rules.mk | 4 +- tools/aif2pcm/Makefile | 10 ++++- tools/bin2c/Makefile | 10 ++++- tools/gbafix/Makefile | 10 ++++- tools/gbagfx/Makefile | 12 +++-- tools/jsonproc/Makefile | 10 ++++- tools/mapjson/Makefile | 10 ++++- tools/mid2agb/Makefile | 10 ++++- tools/preproc/Makefile | 10 ++++- tools/ramscrgen/Makefile | 10 ++++- tools/rsfont/Makefile | 10 ++++- tools/scaninc/Makefile | 10 ++++- 17 files changed, 199 insertions(+), 121 deletions(-) diff --git a/Makefile b/Makefile index 78a2c2a4fc..2e5a341dde 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe @@ -37,6 +34,16 @@ MAKER_CODE := 01 REVISION := 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 ELF = $(ROM:.gba=.elf) @@ -64,18 +71,18 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -g -ROM := pokeemerald.gba -OBJ_DIR := build/emerald +ROM := $(ROM_NAME) +OBJ_DIR := $(OBJ_DIR_NAME) LIBPATH := -L ../../tools/agbcc/lib 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 -g -ROM := pokeemerald_modern.gba -OBJ_DIR := build/modern -LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" +ROM := $(MODERN_ROM_NAME) +OBJ_DIR := $(MODERN_OBJ_DIR_NAME) +LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))" 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) CPPFLAGS += -I tools/agbcc/include -I tools/agbcc endif @@ -111,7 +118,7 @@ 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 +.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)))) @@ -162,7 +169,7 @@ all: rom tools: $(TOOLDIRS) $(TOOLDIRS): - @$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX) + @$(MAKE) -C $@ rom: $(ROM) ifeq ($(COMPARE),1) @@ -177,7 +184,7 @@ clean: mostlyclean clean-tools clean-tools: @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) -mostlyclean: tidy +mostlyclean: tidynonmodern tidymodern rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin rm -f $(MID_SUBDIR)/*.s @@ -192,10 +199,15 @@ mostlyclean: tidy tidy: rm -f $(ROM) $(ELF) $(MAP) 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) $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member endif @@ -223,7 +235,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@ ifeq ($(MODERN),0) -$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc +$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) $(C_BUILDDIR)/libc.o: CFLAGS := -O2 $(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork @@ -232,10 +244,10 @@ $(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 +$(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 +$(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 @@ -296,11 +308,11 @@ endif ifeq ($(NODEP),1) $(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 define DATA_ASM_DEP $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 $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif @@ -329,7 +341,8 @@ $(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 - cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + @echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ " + @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) diff --git a/asmdiff.sh b/asmdiff.sh index 6ea588131d..f5a7010747 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -1,11 +1,19 @@ #!/bin/bash -OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" +if [[ -d "$DEVKITARM/bin/" ]]; then + OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump" +else + OBJDUMP_BIN="arm-none-eabi-objdump" +fi + +OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb" + if [ $(($1)) -ge $((0x8000000)) ]; then OPTIONS="--adjust-vma=0x8000000 --start-address=$(($1)) --stop-address=$(($1 + $2))" else OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" fi + $OBJDUMP $OPTIONS baserom.gba > baserom.dump $OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump diff -u baserom.dump pokeemerald.dump diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 0ead3804fd..6aab4ed624 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,29 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index a121fda93b..ad8787c347 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,29 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 911cdb237c..e1f502b2f8 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -1,29 +1,26 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/map_data_rules.mk b/map_data_rules.mk index 0203b383d0..626cd47240 100755 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -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)) $(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) - $(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 $(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile index 77df291527..dd48a87597 100644 --- a/tools/aif2pcm/Makefile +++ b/tools/aif2pcm/Makefile @@ -6,12 +6,18 @@ LIBS = -lm SRCS = main.c extended.c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: aif2pcm +all: aif2pcm$(EXE) @: -aif2pcm: $(SRCS) +aif2pcm$(EXE): $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile index 52806e39c6..4dbfab94fe 100644 --- a/tools/bin2c/Makefile +++ b/tools/bin2c/Makefile @@ -6,10 +6,16 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 SRCS = bin2c.c -all: bin2c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: bin2c$(EXE) @: -bin2c: $(SRCS) +bin2c$(EXE): $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile index 91a60a9e4c..efb016c97e 100644 --- a/tools/gbafix/Makefile +++ b/tools/gbafix/Makefile @@ -3,10 +3,16 @@ CC ?= gcc SRCS = gbafix.c -all: gbafix +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: gbafix$(EXE) @: -gbafix: $(SRCS) +gbafix$(EXE): $(SRCS) $(CC) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile index f0638414da..b4244aa8d6 100644 --- a/tools/gbagfx/Makefile +++ b/tools/gbagfx/Makefile @@ -6,15 +6,21 @@ LIBS = -lpng -lz SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: gbagfx +all: gbagfx$(EXE) @: -gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS) -gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile index 47198b171e..eec73eb7bf 100755 --- a/tools/jsonproc/Makefile +++ b/tools/jsonproc/Makefile @@ -8,12 +8,18 @@ SRCS := jsonproc.cpp HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: jsonproc +all: jsonproc$(EXE) @: -jsonproc: $(SRCS) $(HEADERS) +jsonproc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile index c1f703f9fe..100e809c6c 100644 --- a/tools/mapjson/Makefile +++ b/tools/mapjson/Makefile @@ -6,12 +6,18 @@ SRCS := json11.cpp mapjson.cpp HEADERS := mapjson.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: mapjson +all: mapjson$(EXE) @: -mapjson: $(SRCS) $(HEADERS) +mapjson$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mid2agb/Makefile b/tools/mid2agb/Makefile index 451d4b39fb..553b7859ed 100644 --- a/tools/mid2agb/Makefile +++ b/tools/mid2agb/Makefile @@ -6,12 +6,18 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp HEADERS := agb.h error.h main.h midi.h tables.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: mid2agb +all: mid2agb$(EXE) @: -mid2agb: $(SRCS) $(HEADERS) +mid2agb$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile index 8c48afea2a..1507c973f2 100644 --- a/tools/preproc/Makefile +++ b/tools/preproc/Makefile @@ -8,12 +8,18 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ utf8.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: preproc +all: preproc$(EXE) @: -preproc: $(SRCS) $(HEADERS) +preproc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile index 4e901a29c1..a9375c87ab 100644 --- a/tools/ramscrgen/Makefile +++ b/tools/ramscrgen/Makefile @@ -8,10 +8,16 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h .PHONY: all clean -all: ramscrgen +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: ramscrgen$(EXE) @: -ramscrgen: $(SRCS) $(HEADERS) +ramscrgen$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile index 930a92b36e..0bc88a42b7 100644 --- a/tools/rsfont/Makefile +++ b/tools/rsfont/Makefile @@ -8,10 +8,16 @@ SRCS = main.c convert_png.c util.c font.c .PHONY: all clean -all: rsfont +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: rsfont$(EXE) @: -rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h +rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile index 52e663d8da..96d92f7062 100644 --- a/tools/scaninc/Makefile +++ b/tools/scaninc/Makefile @@ -8,10 +8,16 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h .PHONY: all clean -all: scaninc +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: scaninc$(EXE) @: -scaninc: $(SRCS) $(HEADERS) +scaninc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: From 8ad973090199d4350683f64069ed1cb676e23679 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 15:37:08 -0500 Subject: [PATCH 18/43] Make a note about the Microsoft Account dialog. --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ecbce35a26..82d0f228d2 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -30,7 +30,7 @@ Once the process finishes, restart your machine. The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice (Note for advanced users: Debian also works here). Advanced users can pick a preferred Linux distribution, but setup instructions may differ. -Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). +Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). If a dialog pops up asking for you to sign into a Microsoft Account, then just close the dialog. ### Setting up WSL1 Open **Ubuntu** (e.g. using Search). WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in). Note that there will be no visible response when typing in the password, but the terminal will still read in input. @@ -395,4 +395,4 @@ To compile the `modern` target with this toolchain, the subdirectories `lib`, `i * [porymap](https://github.com/huderlem/porymap) for viewing and editing maps * [poryscript](https://github.com/huderlem/poryscript) for scripting ([VS Code extension](https://marketplace.visualstudio.com/items?itemName=karathan.poryscript)) -* [Tilemap Studio](https://github.com/Rangi42/tilemap-studio) for viewing and editing tilemaps \ No newline at end of file +* [Tilemap Studio](https://github.com/Rangi42/tilemap-studio) for viewing and editing tilemaps From 3b1cbc58617fe45efbbbdd967ab1e0fae85d76a4 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 18:56:03 -0500 Subject: [PATCH 19/43] Add a note on core.filemode error. --- INSTALL.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 82d0f228d2..ee18ce2162 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -250,10 +250,22 @@ At this point, you can choose a folder to store pokeemerald (and agbcc) into. If If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). ## Installation + +**Windows users:** Consider adding an exception for the `pokeemerald`/`decomps` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. + If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: ```bash git clone https://github.com/luckytyphlosion/pokeemerald ``` +Note for WSL1: If you get an error stating `fatal: could not set 'core.filemode' to 'false'`, then run the following commands: +```bash +cd +sudo umount /mnt/c +sudo mount -t drvfs C: /mnt/c -o metadata +cd +``` +Where *\* is the path of the folder [where you chose to store pokeemerald](#Choosing-where-to-store-pokeemerald-WSL1). + If agbcc has not been built before, run the following commands to build and install it into pokeemerald: ``` git clone https://github.com/luckytyphlosion/agbcc @@ -294,8 +306,6 @@ To build **pokeemerald.gba** with your changes: make ``` -**Windows users:** Consider adding an exception for the `pokeemerald` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. - # Building guidance ## Parallel builds From 2783eed8257bcee46e33552a15e71b33a3d60058 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 19:54:12 -0500 Subject: [PATCH 20/43] Check for $(TOOLCHAIN) before checking for $(TOOLCHAIN)/bin if TOOLCHAIN is blank, wildcard can still detect the `/bin` directory. --- Makefile | 2 ++ berry_fix/Makefile | 2 ++ berry_fix/payload/Makefile | 2 ++ libagbsyscall/Makefile | 2 ++ 4 files changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 2e5a341dde..8a5a2b65f1 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,11 @@ COMPARE ?= 0 # files, or use arm-none-eabi binaries on the system # if dkP is not installed on tihs system +ifneq (,$(TOOLCHAIN)) ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) endif +endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 6aab4ed624..8b8d07d427 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -8,9 +8,11 @@ COMPARE ?= 0 # files, or use arm-none-eabi binaries on the system # if dkP is not installed on tihs system +ifneq (,$(TOOLCHAIN)) ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) endif +endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index ad8787c347..bae657c927 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -8,9 +8,11 @@ COMPARE ?= 0 # files, or use arm-none-eabi binaries on the system # if dkP is not installed on tihs system +ifneq (,$(TOOLCHAIN)) ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) endif +endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index e1f502b2f8..76368da86b 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -8,9 +8,11 @@ COMPARE ?= 0 # files, or use arm-none-eabi binaries on the system # if dkP is not installed on tihs system +ifneq (,$(TOOLCHAIN)) ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) endif +endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy From d597c5c883ad62b1fc62e9c688c2f8a17a1a853e Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 20:17:27 -0500 Subject: [PATCH 21/43] Fix modern builds. We actually need standard includes for modern. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8a5a2b65f1..a341ab5d4d 100644 --- a/Makefile +++ b/Makefile @@ -84,9 +84,9 @@ OBJ_DIR := $(MODERN_OBJ_DIR_NAME) LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))" endif -CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -nostdinc -undef -ifeq ($(MODERN),0) -CPPFLAGS += -I tools/agbcc/include -I tools/agbcc +CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) +ifneq ($(MODERN),1) +CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef endif LDFLAGS = -Map ../../$(MAP) From 11df2113d9c7ab9e09073a93db2bd467b664f678 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 20:29:58 -0500 Subject: [PATCH 22/43] Use arm-none-eabi-cpp for modern. --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index a341ab5d4d..891cab4800 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,13 @@ endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy AS := $(PREFIX)as + +ifneq ($(MODERN),1) CPP := $(CC) -E +else +CPP := $(PREFIX)cpp +endif + LD := $(PREFIX)ld # note: the makefile must be set up so MODERNCC is never called From 345aab63cf2550646a6a56c2c8fe8473d5bf996a Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 20:31:10 -0500 Subject: [PATCH 23/43] [Round 2] Revert multiple source change commits for re-commit. --- Makefile | 97 +++++++++++++++----------------------- asmdiff.sh | 10 +--- berry_fix/Makefile | 37 ++++++++------- berry_fix/payload/Makefile | 37 ++++++++------- libagbsyscall/Makefile | 37 ++++++++------- map_data_rules.mk | 4 +- tools/aif2pcm/Makefile | 10 +--- tools/bin2c/Makefile | 10 +--- tools/gbafix/Makefile | 10 +--- tools/gbagfx/Makefile | 12 ++--- tools/jsonproc/Makefile | 10 +--- tools/mapjson/Makefile | 10 +--- tools/mid2agb/Makefile | 10 +--- tools/preproc/Makefile | 10 +--- tools/ramscrgen/Makefile | 10 +--- tools/rsfont/Makefile | 10 +--- tools/scaninc/Makefile | 10 +--- 17 files changed, 121 insertions(+), 213 deletions(-) diff --git a/Makefile b/Makefile index 891cab4800..78a2c2a4fc 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) +endif -ifneq (,$(TOOLCHAIN)) -ifneq ($(wildcard $(TOOLCHAIN)/bin),) +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else export PATH := $(TOOLCHAIN)/bin:$(PATH) -endif -endif - PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as - -ifneq ($(MODERN),1) -CPP := $(CC) -E -else -CPP := $(PREFIX)cpp +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as endif - -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe @@ -42,16 +37,6 @@ MAKER_CODE := 01 REVISION := 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 ELF = $(ROM:.gba=.elf) @@ -79,20 +64,20 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) 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) +ROM := pokeemerald.gba +OBJ_DIR := build/emerald LIBPATH := -L ../../tools/agbcc/lib else -CC1 = $(shell $(MODERNCC) --print-prog-name=cc1) -quiet +CC1 = $(shell $(CC) --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 $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))" +ROM := pokeemerald_modern.gba +OBJ_DIR := build/modern +LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" endif CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -ifneq ($(MODERN),1) -CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef +ifeq ($(MODERN),0) +CPPFLAGS += -I tools/agbcc/include -I tools/agbcc endif LDFLAGS = -Map ../../$(MAP) @@ -126,7 +111,7 @@ 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: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) @@ -177,7 +162,7 @@ all: rom tools: $(TOOLDIRS) $(TOOLDIRS): - @$(MAKE) -C $@ + @$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX) rom: $(ROM) ifeq ($(COMPARE),1) @@ -192,7 +177,7 @@ clean: mostlyclean clean-tools clean-tools: @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) -mostlyclean: tidynonmodern tidymodern +mostlyclean: tidy rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin rm -f $(MID_SUBDIR)/*.s @@ -207,15 +192,10 @@ mostlyclean: tidynonmodern tidymodern tidy: rm -f $(ROM) $(ELF) $(MAP) 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) $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member endif @@ -243,7 +223,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@ ifeq ($(MODERN),0) -$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) +$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc $(C_BUILDDIR)/libc.o: CFLAGS := -O2 $(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork @@ -252,10 +232,10 @@ $(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)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc $(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding -$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm$(EXE) +$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm $(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 @@ -316,11 +296,11 @@ endif ifeq ($(NODEP),1) $(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 define DATA_ASM_DEP $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 $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif @@ -349,8 +329,7 @@ $(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 ../../$@ " - @cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + 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) diff --git a/asmdiff.sh b/asmdiff.sh index f5a7010747..6ea588131d 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -1,19 +1,11 @@ #!/bin/bash -if [[ -d "$DEVKITARM/bin/" ]]; then - OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump" -else - OBJDUMP_BIN="arm-none-eabi-objdump" -fi - -OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb" - +OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" if [ $(($1)) -ge $((0x8000000)) ]; then OPTIONS="--adjust-vma=0x8000000 --start-address=$(($1)) --stop-address=$(($1 + $2))" else OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" fi - $OBJDUMP $OPTIONS baserom.gba > baserom.dump $OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump diff -u baserom.dump pokeemerald.dump diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 8b8d07d427..0ead3804fd 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,28 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) +endif -ifneq (,$(TOOLCHAIN)) -ifneq ($(wildcard $(TOOLCHAIN)/bin),) +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else export PATH := $(TOOLCHAIN)/bin:$(PATH) -endif -endif - PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index bae657c927..a121fda93b 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,28 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) +endif -ifneq (,$(TOOLCHAIN)) -ifneq ($(wildcard $(TOOLCHAIN)/bin),) +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else export PATH := $(TOOLCHAIN)/bin:$(PATH) -endif -endif - PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 76368da86b..911cdb237c 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -1,28 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) +endif -ifneq (,$(TOOLCHAIN)) -ifneq ($(wildcard $(TOOLCHAIN)/bin),) +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else export PATH := $(TOOLCHAIN)/bin:$(PATH) -endif -endif - PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/map_data_rules.mk b/map_data_rules.mk index 626cd47240..0203b383d0 100755 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -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)) $(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) - $(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 $(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile index dd48a87597..77df291527 100644 --- a/tools/aif2pcm/Makefile +++ b/tools/aif2pcm/Makefile @@ -6,18 +6,12 @@ LIBS = -lm SRCS = main.c extended.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: aif2pcm$(EXE) +all: aif2pcm @: -aif2pcm$(EXE): $(SRCS) +aif2pcm: $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile index 4dbfab94fe..52806e39c6 100644 --- a/tools/bin2c/Makefile +++ b/tools/bin2c/Makefile @@ -6,16 +6,10 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 SRCS = bin2c.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: bin2c$(EXE) +all: bin2c @: -bin2c$(EXE): $(SRCS) +bin2c: $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile index efb016c97e..91a60a9e4c 100644 --- a/tools/gbafix/Makefile +++ b/tools/gbafix/Makefile @@ -3,16 +3,10 @@ CC ?= gcc SRCS = gbafix.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: gbafix$(EXE) +all: gbafix @: -gbafix$(EXE): $(SRCS) +gbafix: $(SRCS) $(CC) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile index b4244aa8d6..f0638414da 100644 --- a/tools/gbagfx/Makefile +++ b/tools/gbagfx/Makefile @@ -6,21 +6,15 @@ LIBS = -lpng -lz SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: gbagfx$(EXE) +all: gbagfx @: -gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS) -gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile index eec73eb7bf..47198b171e 100755 --- a/tools/jsonproc/Makefile +++ b/tools/jsonproc/Makefile @@ -8,18 +8,12 @@ SRCS := jsonproc.cpp HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: jsonproc$(EXE) +all: jsonproc @: -jsonproc$(EXE): $(SRCS) $(HEADERS) +jsonproc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile index 100e809c6c..c1f703f9fe 100644 --- a/tools/mapjson/Makefile +++ b/tools/mapjson/Makefile @@ -6,18 +6,12 @@ SRCS := json11.cpp mapjson.cpp HEADERS := mapjson.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: mapjson$(EXE) +all: mapjson @: -mapjson$(EXE): $(SRCS) $(HEADERS) +mapjson: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mid2agb/Makefile b/tools/mid2agb/Makefile index 553b7859ed..451d4b39fb 100644 --- a/tools/mid2agb/Makefile +++ b/tools/mid2agb/Makefile @@ -6,18 +6,12 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp HEADERS := agb.h error.h main.h midi.h tables.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: mid2agb$(EXE) +all: mid2agb @: -mid2agb$(EXE): $(SRCS) $(HEADERS) +mid2agb: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile index 1507c973f2..8c48afea2a 100644 --- a/tools/preproc/Makefile +++ b/tools/preproc/Makefile @@ -8,18 +8,12 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ utf8.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: preproc$(EXE) +all: preproc @: -preproc$(EXE): $(SRCS) $(HEADERS) +preproc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile index a9375c87ab..4e901a29c1 100644 --- a/tools/ramscrgen/Makefile +++ b/tools/ramscrgen/Makefile @@ -8,16 +8,10 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: ramscrgen$(EXE) +all: ramscrgen @: -ramscrgen$(EXE): $(SRCS) $(HEADERS) +ramscrgen: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile index 0bc88a42b7..930a92b36e 100644 --- a/tools/rsfont/Makefile +++ b/tools/rsfont/Makefile @@ -8,16 +8,10 @@ SRCS = main.c convert_png.c util.c font.c .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: rsfont$(EXE) +all: rsfont @: -rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h +rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile index 96d92f7062..52e663d8da 100644 --- a/tools/scaninc/Makefile +++ b/tools/scaninc/Makefile @@ -8,16 +8,10 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: scaninc$(EXE) +all: scaninc @: -scaninc$(EXE): $(SRCS) $(HEADERS) +scaninc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: From 166183d5ed73059922b9679b832b591dd6fa073b Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 20:31:56 -0500 Subject: [PATCH 24/43] [Round 2] Apply all source related changes for the new INSTALL.md in one commit. --- Makefile | 97 +++++++++++++++++++++++--------------- asmdiff.sh | 10 +++- berry_fix/Makefile | 37 +++++++-------- berry_fix/payload/Makefile | 37 +++++++-------- libagbsyscall/Makefile | 37 +++++++-------- map_data_rules.mk | 4 +- tools/aif2pcm/Makefile | 10 +++- tools/bin2c/Makefile | 10 +++- tools/gbafix/Makefile | 10 +++- tools/gbagfx/Makefile | 12 +++-- tools/jsonproc/Makefile | 10 +++- tools/mapjson/Makefile | 10 +++- tools/mid2agb/Makefile | 10 +++- tools/preproc/Makefile | 10 +++- tools/ramscrgen/Makefile | 10 +++- tools/rsfont/Makefile | 10 +++- tools/scaninc/Makefile | 10 +++- 17 files changed, 213 insertions(+), 121 deletions(-) diff --git a/Makefile b/Makefile index 78a2c2a4fc..891cab4800 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,34 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq (,$(TOOLCHAIN)) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as +AS := $(PREFIX)as + +ifneq ($(MODERN),1) +CPP := $(CC) -E +else +CPP := $(PREFIX)cpp endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld + +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe @@ -37,6 +42,16 @@ MAKER_CODE := 01 REVISION := 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 ELF = $(ROM:.gba=.elf) @@ -64,20 +79,20 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -g -ROM := pokeemerald.gba -OBJ_DIR := build/emerald +ROM := $(ROM_NAME) +OBJ_DIR := $(OBJ_DIR_NAME) LIBPATH := -L ../../tools/agbcc/lib 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 -g -ROM := pokeemerald_modern.gba -OBJ_DIR := build/modern -LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" +ROM := $(MODERN_ROM_NAME) +OBJ_DIR := $(MODERN_OBJ_DIR_NAME) +LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))" endif CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -ifeq ($(MODERN),0) -CPPFLAGS += -I tools/agbcc/include -I tools/agbcc +ifneq ($(MODERN),1) +CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef endif LDFLAGS = -Map ../../$(MAP) @@ -111,7 +126,7 @@ 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 +.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)))) @@ -162,7 +177,7 @@ all: rom tools: $(TOOLDIRS) $(TOOLDIRS): - @$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX) + @$(MAKE) -C $@ rom: $(ROM) ifeq ($(COMPARE),1) @@ -177,7 +192,7 @@ clean: mostlyclean clean-tools clean-tools: @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) -mostlyclean: tidy +mostlyclean: tidynonmodern tidymodern rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin rm -f $(MID_SUBDIR)/*.s @@ -192,10 +207,15 @@ mostlyclean: tidy tidy: rm -f $(ROM) $(ELF) $(MAP) 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) $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member endif @@ -223,7 +243,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@ ifeq ($(MODERN),0) -$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc +$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) $(C_BUILDDIR)/libc.o: CFLAGS := -O2 $(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork @@ -232,10 +252,10 @@ $(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 +$(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 +$(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 @@ -296,11 +316,11 @@ endif ifeq ($(NODEP),1) $(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 define DATA_ASM_DEP $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 $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif @@ -329,7 +349,8 @@ $(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 - cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + @echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ " + @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) diff --git a/asmdiff.sh b/asmdiff.sh index 6ea588131d..f5a7010747 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -1,11 +1,19 @@ #!/bin/bash -OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" +if [[ -d "$DEVKITARM/bin/" ]]; then + OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump" +else + OBJDUMP_BIN="arm-none-eabi-objdump" +fi + +OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb" + if [ $(($1)) -ge $((0x8000000)) ]; then OPTIONS="--adjust-vma=0x8000000 --start-address=$(($1)) --stop-address=$(($1 + $2))" else OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" fi + $OBJDUMP $OPTIONS baserom.gba > baserom.dump $OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump diff -u baserom.dump pokeemerald.dump diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 0ead3804fd..8b8d07d427 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,29 +1,28 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq (,$(TOOLCHAIN)) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index a121fda93b..bae657c927 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,29 +1,28 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq (,$(TOOLCHAIN)) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 911cdb237c..76368da86b 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -1,29 +1,28 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq (,$(TOOLCHAIN)) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/map_data_rules.mk b/map_data_rules.mk index 0203b383d0..626cd47240 100755 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -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)) $(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) - $(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 $(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile index 77df291527..dd48a87597 100644 --- a/tools/aif2pcm/Makefile +++ b/tools/aif2pcm/Makefile @@ -6,12 +6,18 @@ LIBS = -lm SRCS = main.c extended.c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: aif2pcm +all: aif2pcm$(EXE) @: -aif2pcm: $(SRCS) +aif2pcm$(EXE): $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile index 52806e39c6..4dbfab94fe 100644 --- a/tools/bin2c/Makefile +++ b/tools/bin2c/Makefile @@ -6,10 +6,16 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 SRCS = bin2c.c -all: bin2c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: bin2c$(EXE) @: -bin2c: $(SRCS) +bin2c$(EXE): $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile index 91a60a9e4c..efb016c97e 100644 --- a/tools/gbafix/Makefile +++ b/tools/gbafix/Makefile @@ -3,10 +3,16 @@ CC ?= gcc SRCS = gbafix.c -all: gbafix +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: gbafix$(EXE) @: -gbafix: $(SRCS) +gbafix$(EXE): $(SRCS) $(CC) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile index f0638414da..b4244aa8d6 100644 --- a/tools/gbagfx/Makefile +++ b/tools/gbagfx/Makefile @@ -6,15 +6,21 @@ LIBS = -lpng -lz SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: gbagfx +all: gbagfx$(EXE) @: -gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS) -gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile index 47198b171e..eec73eb7bf 100755 --- a/tools/jsonproc/Makefile +++ b/tools/jsonproc/Makefile @@ -8,12 +8,18 @@ SRCS := jsonproc.cpp HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: jsonproc +all: jsonproc$(EXE) @: -jsonproc: $(SRCS) $(HEADERS) +jsonproc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile index c1f703f9fe..100e809c6c 100644 --- a/tools/mapjson/Makefile +++ b/tools/mapjson/Makefile @@ -6,12 +6,18 @@ SRCS := json11.cpp mapjson.cpp HEADERS := mapjson.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: mapjson +all: mapjson$(EXE) @: -mapjson: $(SRCS) $(HEADERS) +mapjson$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mid2agb/Makefile b/tools/mid2agb/Makefile index 451d4b39fb..553b7859ed 100644 --- a/tools/mid2agb/Makefile +++ b/tools/mid2agb/Makefile @@ -6,12 +6,18 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp HEADERS := agb.h error.h main.h midi.h tables.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: mid2agb +all: mid2agb$(EXE) @: -mid2agb: $(SRCS) $(HEADERS) +mid2agb$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile index 8c48afea2a..1507c973f2 100644 --- a/tools/preproc/Makefile +++ b/tools/preproc/Makefile @@ -8,12 +8,18 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ utf8.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: preproc +all: preproc$(EXE) @: -preproc: $(SRCS) $(HEADERS) +preproc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile index 4e901a29c1..a9375c87ab 100644 --- a/tools/ramscrgen/Makefile +++ b/tools/ramscrgen/Makefile @@ -8,10 +8,16 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h .PHONY: all clean -all: ramscrgen +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: ramscrgen$(EXE) @: -ramscrgen: $(SRCS) $(HEADERS) +ramscrgen$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile index 930a92b36e..0bc88a42b7 100644 --- a/tools/rsfont/Makefile +++ b/tools/rsfont/Makefile @@ -8,10 +8,16 @@ SRCS = main.c convert_png.c util.c font.c .PHONY: all clean -all: rsfont +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: rsfont$(EXE) @: -rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h +rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile index 52e663d8da..96d92f7062 100644 --- a/tools/scaninc/Makefile +++ b/tools/scaninc/Makefile @@ -8,10 +8,16 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h .PHONY: all clean -all: scaninc +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: scaninc$(EXE) @: -scaninc: $(SRCS) $(HEADERS) +scaninc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: From 32e566def07698121d5b2f56edb6867329326276 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 21:16:55 -0500 Subject: [PATCH 25/43] Don't define CPP until MODERN is defined. --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 891cab4800..306b8fb6e8 100644 --- a/Makefile +++ b/Makefile @@ -18,12 +18,6 @@ PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy AS := $(PREFIX)as -ifneq ($(MODERN),1) -CPP := $(CC) -E -else -CPP := $(PREFIX)cpp -endif - LD := $(PREFIX)ld # note: the makefile must be set up so MODERNCC is never called @@ -42,6 +36,12 @@ MAKER_CODE := 01 REVISION := 0 MODERN ?= 0 +ifneq ($(MODERN),1) +CPP := $(CC) -E +else +CPP := $(PREFIX)cpp +endif + ROM_NAME := pokeemerald.gba ELF_NAME := $(ROM_NAME:.gba=.elf) MAP_NAME := $(ROM_NAME:.gba=.map) From 5a5acfb0ada48c89d1e398dea3fd3ef701213b60 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 21:24:08 -0500 Subject: [PATCH 26/43] [Round 3] Revert multiple source change commits for re-commit. --- Makefile | 99 +++++++++++++++----------------------- asmdiff.sh | 10 +--- berry_fix/Makefile | 37 +++++++------- berry_fix/payload/Makefile | 37 +++++++------- libagbsyscall/Makefile | 37 +++++++------- map_data_rules.mk | 4 +- tools/aif2pcm/Makefile | 10 +--- tools/bin2c/Makefile | 10 +--- tools/gbafix/Makefile | 10 +--- tools/gbagfx/Makefile | 12 ++--- tools/jsonproc/Makefile | 10 +--- tools/mapjson/Makefile | 10 +--- tools/mid2agb/Makefile | 10 +--- tools/preproc/Makefile | 10 +--- tools/ramscrgen/Makefile | 10 +--- tools/rsfont/Makefile | 10 +--- tools/scaninc/Makefile | 10 +--- 17 files changed, 122 insertions(+), 214 deletions(-) diff --git a/Makefile b/Makefile index 306b8fb6e8..78a2c2a4fc 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) +endif -ifneq (,$(TOOLCHAIN)) -ifneq ($(wildcard $(TOOLCHAIN)/bin),) +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else export PATH := $(TOOLCHAIN)/bin:$(PATH) -endif -endif - PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as - -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe @@ -36,22 +37,6 @@ MAKER_CODE := 01 REVISION := 0 MODERN ?= 0 -ifneq ($(MODERN),1) -CPP := $(CC) -E -else -CPP := $(PREFIX)cpp -endif - -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 ELF = $(ROM:.gba=.elf) @@ -79,20 +64,20 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) 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) +ROM := pokeemerald.gba +OBJ_DIR := build/emerald LIBPATH := -L ../../tools/agbcc/lib else -CC1 = $(shell $(MODERNCC) --print-prog-name=cc1) -quiet +CC1 = $(shell $(CC) --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 $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))" +ROM := pokeemerald_modern.gba +OBJ_DIR := build/modern +LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" endif CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -ifneq ($(MODERN),1) -CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef +ifeq ($(MODERN),0) +CPPFLAGS += -I tools/agbcc/include -I tools/agbcc endif LDFLAGS = -Map ../../$(MAP) @@ -126,7 +111,7 @@ 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: all rom clean compare tidy tools mostlyclean clean-tools $(TOOLDIRS) berry_fix libagbsyscall modern infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) @@ -177,7 +162,7 @@ all: rom tools: $(TOOLDIRS) $(TOOLDIRS): - @$(MAKE) -C $@ + @$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX) rom: $(ROM) ifeq ($(COMPARE),1) @@ -192,7 +177,7 @@ clean: mostlyclean clean-tools clean-tools: @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) -mostlyclean: tidynonmodern tidymodern +mostlyclean: tidy rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin rm -f $(MID_SUBDIR)/*.s @@ -207,15 +192,10 @@ mostlyclean: tidynonmodern tidymodern tidy: rm -f $(ROM) $(ELF) $(MAP) 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) $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member endif @@ -243,7 +223,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@ ifeq ($(MODERN),0) -$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) +$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc $(C_BUILDDIR)/libc.o: CFLAGS := -O2 $(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork @@ -252,10 +232,10 @@ $(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)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc $(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding -$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm$(EXE) +$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm $(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 @@ -316,11 +296,11 @@ endif ifeq ($(NODEP),1) $(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 define DATA_ASM_DEP $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 $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif @@ -349,8 +329,7 @@ $(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 ../../$@ " - @cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + 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) diff --git a/asmdiff.sh b/asmdiff.sh index f5a7010747..6ea588131d 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -1,19 +1,11 @@ #!/bin/bash -if [[ -d "$DEVKITARM/bin/" ]]; then - OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump" -else - OBJDUMP_BIN="arm-none-eabi-objdump" -fi - -OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb" - +OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" if [ $(($1)) -ge $((0x8000000)) ]; then OPTIONS="--adjust-vma=0x8000000 --start-address=$(($1)) --stop-address=$(($1 + $2))" else OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" fi - $OBJDUMP $OPTIONS baserom.gba > baserom.dump $OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump diff -u baserom.dump pokeemerald.dump diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 8b8d07d427..0ead3804fd 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,28 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) +endif -ifneq (,$(TOOLCHAIN)) -ifneq ($(wildcard $(TOOLCHAIN)/bin),) +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else export PATH := $(TOOLCHAIN)/bin:$(PATH) -endif -endif - PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index bae657c927..a121fda93b 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,28 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) +endif -ifneq (,$(TOOLCHAIN)) -ifneq ($(wildcard $(TOOLCHAIN)/bin),) +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else export PATH := $(TOOLCHAIN)/bin:$(PATH) -endif -endif - PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 76368da86b..911cdb237c 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -1,28 +1,29 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -# 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 tihs system +ifeq ($(CC),) +HOSTCC := gcc +else +HOSTCC := $(CC) +endif -ifneq (,$(TOOLCHAIN)) -ifneq ($(wildcard $(TOOLCHAIN)/bin),) +ifeq ($(CXX),) +HOSTCXX := g++ +else +HOSTCXX := $(CXX) +endif + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +else export PATH := $(TOOLCHAIN)/bin:$(PATH) -endif -endif - PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -AS := $(PREFIX)as -CPP := $(CC) -E -LD := $(PREFIX)ld - -# note: the makefile must be set up so MODERNCC is never called -# if MODERN=0 -MODERNCC := $(PREFIX)gcc +export CC := $(PREFIX)gcc +export AS := $(PREFIX)as +endif +export CPP := $(PREFIX)cpp +export LD := $(PREFIX)ld ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/map_data_rules.mk b/map_data_rules.mk index 626cd47240..0203b383d0 100755 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -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)) $(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) - $(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 $(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile index dd48a87597..77df291527 100644 --- a/tools/aif2pcm/Makefile +++ b/tools/aif2pcm/Makefile @@ -6,18 +6,12 @@ LIBS = -lm SRCS = main.c extended.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: aif2pcm$(EXE) +all: aif2pcm @: -aif2pcm$(EXE): $(SRCS) +aif2pcm: $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile index 4dbfab94fe..52806e39c6 100644 --- a/tools/bin2c/Makefile +++ b/tools/bin2c/Makefile @@ -6,16 +6,10 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 SRCS = bin2c.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: bin2c$(EXE) +all: bin2c @: -bin2c$(EXE): $(SRCS) +bin2c: $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile index efb016c97e..91a60a9e4c 100644 --- a/tools/gbafix/Makefile +++ b/tools/gbafix/Makefile @@ -3,16 +3,10 @@ CC ?= gcc SRCS = gbafix.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: gbafix$(EXE) +all: gbafix @: -gbafix$(EXE): $(SRCS) +gbafix: $(SRCS) $(CC) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile index b4244aa8d6..f0638414da 100644 --- a/tools/gbagfx/Makefile +++ b/tools/gbagfx/Makefile @@ -6,21 +6,15 @@ LIBS = -lpng -lz SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: gbagfx$(EXE) +all: gbagfx @: -gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS) -gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile index eec73eb7bf..47198b171e 100755 --- a/tools/jsonproc/Makefile +++ b/tools/jsonproc/Makefile @@ -8,18 +8,12 @@ SRCS := jsonproc.cpp HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: jsonproc$(EXE) +all: jsonproc @: -jsonproc$(EXE): $(SRCS) $(HEADERS) +jsonproc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile index 100e809c6c..c1f703f9fe 100644 --- a/tools/mapjson/Makefile +++ b/tools/mapjson/Makefile @@ -6,18 +6,12 @@ SRCS := json11.cpp mapjson.cpp HEADERS := mapjson.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: mapjson$(EXE) +all: mapjson @: -mapjson$(EXE): $(SRCS) $(HEADERS) +mapjson: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mid2agb/Makefile b/tools/mid2agb/Makefile index 553b7859ed..451d4b39fb 100644 --- a/tools/mid2agb/Makefile +++ b/tools/mid2agb/Makefile @@ -6,18 +6,12 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp HEADERS := agb.h error.h main.h midi.h tables.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: mid2agb$(EXE) +all: mid2agb @: -mid2agb$(EXE): $(SRCS) $(HEADERS) +mid2agb: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile index 1507c973f2..8c48afea2a 100644 --- a/tools/preproc/Makefile +++ b/tools/preproc/Makefile @@ -8,18 +8,12 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ utf8.h -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - .PHONY: all clean -all: preproc$(EXE) +all: preproc @: -preproc$(EXE): $(SRCS) $(HEADERS) +preproc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile index a9375c87ab..4e901a29c1 100644 --- a/tools/ramscrgen/Makefile +++ b/tools/ramscrgen/Makefile @@ -8,16 +8,10 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: ramscrgen$(EXE) +all: ramscrgen @: -ramscrgen$(EXE): $(SRCS) $(HEADERS) +ramscrgen: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile index 0bc88a42b7..930a92b36e 100644 --- a/tools/rsfont/Makefile +++ b/tools/rsfont/Makefile @@ -8,16 +8,10 @@ SRCS = main.c convert_png.c util.c font.c .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: rsfont$(EXE) +all: rsfont @: -rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h +rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile index 96d92f7062..52e663d8da 100644 --- a/tools/scaninc/Makefile +++ b/tools/scaninc/Makefile @@ -8,16 +8,10 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h .PHONY: all clean -ifeq ($(OS),Windows_NT) -EXE := .exe -else -EXE := -endif - -all: scaninc$(EXE) +all: scaninc @: -scaninc$(EXE): $(SRCS) $(HEADERS) +scaninc: $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: From 3d686116d8acb9f3daa1db9669de6eca11a861d5 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 16 Dec 2020 21:24:44 -0500 Subject: [PATCH 27/43] [Round 3] Apply all source related changes for the new INSTALL.md in one commit. --- Makefile | 99 +++++++++++++++++++++++--------------- asmdiff.sh | 10 +++- berry_fix/Makefile | 37 +++++++------- berry_fix/payload/Makefile | 37 +++++++------- libagbsyscall/Makefile | 37 +++++++------- map_data_rules.mk | 4 +- tools/aif2pcm/Makefile | 10 +++- tools/bin2c/Makefile | 10 +++- tools/gbafix/Makefile | 10 +++- tools/gbagfx/Makefile | 12 +++-- tools/jsonproc/Makefile | 10 +++- tools/mapjson/Makefile | 10 +++- tools/mid2agb/Makefile | 10 +++- tools/preproc/Makefile | 10 +++- tools/ramscrgen/Makefile | 10 +++- tools/rsfont/Makefile | 10 +++- tools/scaninc/Makefile | 10 +++- 17 files changed, 214 insertions(+), 122 deletions(-) diff --git a/Makefile b/Makefile index 78a2c2a4fc..306b8fb6e8 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,28 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq (,$(TOOLCHAIN)) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as + +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe @@ -37,6 +36,22 @@ MAKER_CODE := 01 REVISION := 0 MODERN ?= 0 +ifneq ($(MODERN),1) +CPP := $(CC) -E +else +CPP := $(PREFIX)cpp +endif + +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 ELF = $(ROM:.gba=.elf) @@ -64,20 +79,20 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN) ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -g -ROM := pokeemerald.gba -OBJ_DIR := build/emerald +ROM := $(ROM_NAME) +OBJ_DIR := $(OBJ_DIR_NAME) LIBPATH := -L ../../tools/agbcc/lib 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 -g -ROM := pokeemerald_modern.gba -OBJ_DIR := build/modern -LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))" +ROM := $(MODERN_ROM_NAME) +OBJ_DIR := $(MODERN_OBJ_DIR_NAME) +LIBPATH := -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(MODERNCC) -mthumb -print-file-name=libc.a))" endif CPPFLAGS := -iquote include -iquote $(GFLIB_SUBDIR) -Wno-trigraphs -DMODERN=$(MODERN) -ifeq ($(MODERN),0) -CPPFLAGS += -I tools/agbcc/include -I tools/agbcc +ifneq ($(MODERN),1) +CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef endif LDFLAGS = -Map ../../$(MAP) @@ -111,7 +126,7 @@ 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 +.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)))) @@ -162,7 +177,7 @@ all: rom tools: $(TOOLDIRS) $(TOOLDIRS): - @$(MAKE) -C $@ CC=$(HOSTCC) CXX=$(HOSTCXX) + @$(MAKE) -C $@ rom: $(ROM) ifeq ($(COMPARE),1) @@ -177,7 +192,7 @@ clean: mostlyclean clean-tools clean-tools: @$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);) -mostlyclean: tidy +mostlyclean: tidynonmodern tidymodern rm -f $(SAMPLE_SUBDIR)/*.bin rm -f $(CRY_SUBDIR)/*.bin rm -f $(MID_SUBDIR)/*.s @@ -192,10 +207,15 @@ mostlyclean: tidy tidy: rm -f $(ROM) $(ELF) $(MAP) 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) $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member endif @@ -223,7 +243,7 @@ sound/%.bin: sound/%.aif ; $(AIF) $< $@ ifeq ($(MODERN),0) -$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc +$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) $(C_BUILDDIR)/libc.o: CFLAGS := -O2 $(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork @@ -232,10 +252,10 @@ $(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 +$(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 +$(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 @@ -296,11 +316,11 @@ endif ifeq ($(NODEP),1) $(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 define DATA_ASM_DEP $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 $(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif @@ -329,7 +349,8 @@ $(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 - cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB) + @echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ " + @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) diff --git a/asmdiff.sh b/asmdiff.sh index 6ea588131d..f5a7010747 100755 --- a/asmdiff.sh +++ b/asmdiff.sh @@ -1,11 +1,19 @@ #!/bin/bash -OBJDUMP="$DEVKITARM/bin/arm-none-eabi-objdump -D -bbinary -marmv4t -Mforce-thumb" +if [[ -d "$DEVKITARM/bin/" ]]; then + OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump" +else + OBJDUMP_BIN="arm-none-eabi-objdump" +fi + +OBJDUMP="$OBJDUMP_BIN -D -bbinary -marmv4t -Mforce-thumb" + if [ $(($1)) -ge $((0x8000000)) ]; then OPTIONS="--adjust-vma=0x8000000 --start-address=$(($1)) --stop-address=$(($1 + $2))" else OPTIONS="--start-address=$(($1)) --stop-address=$(($1 + $2))" fi + $OBJDUMP $OPTIONS baserom.gba > baserom.dump $OBJDUMP $OPTIONS pokeemerald.gba > pokeemerald.dump diff -u baserom.dump pokeemerald.dump diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 0ead3804fd..8b8d07d427 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,29 +1,28 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq (,$(TOOLCHAIN)) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index a121fda93b..bae657c927 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,29 +1,28 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq (,$(TOOLCHAIN)) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 911cdb237c..76368da86b 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -1,29 +1,28 @@ TOOLCHAIN := $(DEVKITARM) COMPARE ?= 0 -ifeq ($(CC),) -HOSTCC := gcc -else -HOSTCC := $(CC) -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 tihs system -ifeq ($(CXX),) -HOSTCXX := g++ -else -HOSTCXX := $(CXX) -endif - -ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) -include $(TOOLCHAIN)/base_tools -else +ifneq (,$(TOOLCHAIN)) +ifneq ($(wildcard $(TOOLCHAIN)/bin),) export PATH := $(TOOLCHAIN)/bin:$(PATH) +endif +endif + PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy -export CC := $(PREFIX)gcc -export AS := $(PREFIX)as -endif -export CPP := $(PREFIX)cpp -export LD := $(PREFIX)ld +AS := $(PREFIX)as +CPP := $(CC) -E +LD := $(PREFIX)ld + +# note: the makefile must be set up so MODERNCC is never called +# if MODERN=0 +MODERNCC := $(PREFIX)gcc ifeq ($(OS),Windows_NT) EXE := .exe diff --git a/map_data_rules.mk b/map_data_rules.mk index 0203b383d0..626cd47240 100755 --- a/map_data_rules.mk +++ b/map_data_rules.mk @@ -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)) $(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) - $(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 $(MAPJSON) map emerald $< $(LAYOUTS_DIR)/layouts.json diff --git a/tools/aif2pcm/Makefile b/tools/aif2pcm/Makefile index 77df291527..dd48a87597 100644 --- a/tools/aif2pcm/Makefile +++ b/tools/aif2pcm/Makefile @@ -6,12 +6,18 @@ LIBS = -lm SRCS = main.c extended.c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: aif2pcm +all: aif2pcm$(EXE) @: -aif2pcm: $(SRCS) +aif2pcm$(EXE): $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/bin2c/Makefile b/tools/bin2c/Makefile index 52806e39c6..4dbfab94fe 100644 --- a/tools/bin2c/Makefile +++ b/tools/bin2c/Makefile @@ -6,10 +6,16 @@ CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 SRCS = bin2c.c -all: bin2c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: bin2c$(EXE) @: -bin2c: $(SRCS) +bin2c$(EXE): $(SRCS) $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbafix/Makefile b/tools/gbafix/Makefile index 91a60a9e4c..efb016c97e 100644 --- a/tools/gbafix/Makefile +++ b/tools/gbafix/Makefile @@ -3,10 +3,16 @@ CC ?= gcc SRCS = gbafix.c -all: gbafix +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: gbafix$(EXE) @: -gbafix: $(SRCS) +gbafix$(EXE): $(SRCS) $(CC) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/gbagfx/Makefile b/tools/gbagfx/Makefile index f0638414da..b4244aa8d6 100644 --- a/tools/gbagfx/Makefile +++ b/tools/gbagfx/Makefile @@ -6,15 +6,21 @@ LIBS = -lpng -lz SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: gbagfx +all: gbagfx$(EXE) @: -gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx-debug$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS) -gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h +gbagfx$(EXE): $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/jsonproc/Makefile b/tools/jsonproc/Makefile index 47198b171e..eec73eb7bf 100755 --- a/tools/jsonproc/Makefile +++ b/tools/jsonproc/Makefile @@ -8,12 +8,18 @@ SRCS := jsonproc.cpp HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: jsonproc +all: jsonproc$(EXE) @: -jsonproc: $(SRCS) $(HEADERS) +jsonproc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mapjson/Makefile b/tools/mapjson/Makefile index c1f703f9fe..100e809c6c 100644 --- a/tools/mapjson/Makefile +++ b/tools/mapjson/Makefile @@ -6,12 +6,18 @@ SRCS := json11.cpp mapjson.cpp HEADERS := mapjson.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: mapjson +all: mapjson$(EXE) @: -mapjson: $(SRCS) $(HEADERS) +mapjson$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/mid2agb/Makefile b/tools/mid2agb/Makefile index 451d4b39fb..553b7859ed 100644 --- a/tools/mid2agb/Makefile +++ b/tools/mid2agb/Makefile @@ -6,12 +6,18 @@ SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp HEADERS := agb.h error.h main.h midi.h tables.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: mid2agb +all: mid2agb$(EXE) @: -mid2agb: $(SRCS) $(HEADERS) +mid2agb$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/preproc/Makefile b/tools/preproc/Makefile index 8c48afea2a..1507c973f2 100644 --- a/tools/preproc/Makefile +++ b/tools/preproc/Makefile @@ -8,12 +8,18 @@ SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ utf8.h +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + .PHONY: all clean -all: preproc +all: preproc$(EXE) @: -preproc: $(SRCS) $(HEADERS) +preproc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/ramscrgen/Makefile b/tools/ramscrgen/Makefile index 4e901a29c1..a9375c87ab 100644 --- a/tools/ramscrgen/Makefile +++ b/tools/ramscrgen/Makefile @@ -8,10 +8,16 @@ HEADERS := ramscrgen.h sym_file.h elf.h char_util.h .PHONY: all clean -all: ramscrgen +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: ramscrgen$(EXE) @: -ramscrgen: $(SRCS) $(HEADERS) +ramscrgen$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: diff --git a/tools/rsfont/Makefile b/tools/rsfont/Makefile index 930a92b36e..0bc88a42b7 100644 --- a/tools/rsfont/Makefile +++ b/tools/rsfont/Makefile @@ -8,10 +8,16 @@ SRCS = main.c convert_png.c util.c font.c .PHONY: all clean -all: rsfont +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: rsfont$(EXE) @: -rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h +rsfont$(EXE): $(SRCS) convert_png.h gfx.h global.h util.h font.h $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) clean: diff --git a/tools/scaninc/Makefile b/tools/scaninc/Makefile index 52e663d8da..96d92f7062 100644 --- a/tools/scaninc/Makefile +++ b/tools/scaninc/Makefile @@ -8,10 +8,16 @@ HEADERS := scaninc.h asm_file.h c_file.h source_file.h .PHONY: all clean -all: scaninc +ifeq ($(OS),Windows_NT) +EXE := .exe +else +EXE := +endif + +all: scaninc$(EXE) @: -scaninc: $(SRCS) $(HEADERS) +scaninc$(EXE): $(SRCS) $(HEADERS) $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) clean: From 946faf682f4ca5fdaebc5cfec34815c1a427ac2d Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Thu, 17 Dec 2020 09:03:14 -0500 Subject: [PATCH 28/43] Extra clarification about remounting the C: drive --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ee18ce2162..dd5d24defc 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -261,10 +261,10 @@ Note for WSL1: If you get an error stating `fatal: could not set 'core.filemode' ```bash cd sudo umount /mnt/c -sudo mount -t drvfs C: /mnt/c -o metadata +sudo mount -t drvfs C: /mnt/c -o metadata,noatime cd ``` -Where *\* is the path of the folder [where you chose to store pokeemerald](#Choosing-where-to-store-pokeemerald-WSL1). +Where *\* is the path of the folder [where you chose to store pokeemerald](#Choosing-where-to-store-pokeemerald-WSL1). Then run the `git clone` command again. If agbcc has not been built before, run the following commands to build and install it into pokeemerald: ``` From 9da0920969a31bee441ba941263836204ff85f52 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 23 Dec 2020 18:02:30 -0500 Subject: [PATCH 29/43] Improve INSTALL.mds as per recommendations. - Put "conditional" notes in quotes to better communicate which instructions are more required - Number instructions per OS as per Griffin's advice. --- INSTALL.md | 493 ++++++++++++++++++++---------------- docs/legacy_WSL1_INSTALL.md | 55 ++-- 2 files changed, 313 insertions(+), 235 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index dd5d24defc..b3c106e725 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -2,117 +2,145 @@ These instructions explain how to set up the tools required to build **pokeemerald**, which assembles the source files into a ROM. -If you run into trouble, ask for help on IRC or Discord (see [README.md](README.md)). +If you run into trouble, ask for help on Discord or IRC (see [README.md](README.md)). ## Windows Windows has instructions for building with three possible terminals, if users encounter unexpected errors in following instructions for one of the terminals. These instructions are: -- [Windows 10 (WSL1)](#windows-10-wsl1) -- [Windows (msys2)](#windows-msys2) -- [Windows (Cygwin)](#windows-cygwin) +- [Windows 10 (WSL1)](#windows-10-wsl1) (**Fastest, highly recommended**, Windows 10 only) +- [Windows (msys2)](#windows-msys2) (Second fastest) +- [Windows (Cygwin)](#windows-cygwin) (Slowest) -The instructions have been ordered by the performance of their respective terminal. Out of the provided terminals, **WSL1** builds pokeemerald the fastest, and is thus **highly recommended**, but is only available on Windows 10. **msys2** is the second fastest, and **Cygwin** is the slowest. Unscientific benchmarks suggest msys2 is 2x slower than WSL1, and Cygwin is **5-6x** slower than WSL1. For advanced users, **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools such as [porymap](https://github.com/huderlem/porymap) cannot interact with said files due to problems [outside the control of maintainers](https://bugreports.qt.io/browse/QTBUG-86277). +Unscientific benchmarks suggest **msys2 is 2x slower** than WSL1, and **Cygwin is 5-6x slower** than WSL1. + +> Note for advanced users: **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools may have trouble interacting with the WSL2 file system over the network drive. All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions. **A note of caution**: As Windows 7 is officially unsupported by Microsoft and Windows 8 has very little usage, some maintainers are unwilling to maintain the Windows 7/8 instructions. Thus, these instructions may break in the future with fixes taking longer than fixes to the Windows 10 instructions. ## Windows 10 (WSL1) -WSL1 is the preferred terminal to build **pokeemerald**. The following instructions will explain how to install WSL1 (referred interchangeably as WSL). - -If WSL (Debian or Ubuntu) is **not installed**, then go to [Installing WSL1](#Installing-WSL1). Otherwise, if WSL is installed, but it hasn't previously been set up for another decompilation project, then go to [Setting up WSL1](#Setting-up-WSL1). Otherwise, open WSL and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-WSL1). +WSL1 is the preferred terminal to build **pokeemerald**. The following instructions will explain how to install WSL1 (referred to interchangeably as WSL). +- If WSL (Debian or Ubuntu) is **not installed**, then go to [Installing WSL1](#Installing-WSL1). +- Otherwise, if WSL is installed, but it **hasn't previously been set up for another decompilation project**, then go to [Setting up WSL1](#Setting-up-WSL1). +- Otherwise, **open WSL** and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-WSL1). ### Installing WSL1 -Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Right Click or Shift+Insert is paste in the Powershell). -``` -dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart -``` -Once the process finishes, restart your machine. +1. Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Right Click or Shift+Insert is paste in the Powershell). -The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice (Note for advanced users: Debian also works here). Advanced users can pick a preferred Linux distribution, but setup instructions may differ. + ```powershell + dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart + ``` -Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). If a dialog pops up asking for you to sign into a Microsoft Account, then just close the dialog. +2. Once the process finishes, restart your machine. + +3. The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice. + + > Note for advanced users: Advanced users can pick a preferred Linux distribution, but setup instructions may differ. Debian should work with the given instructions, but has not been tested. + +4. Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. + + > Note 1: If a dialog pops up asking for you to sign into a Microsoft Account, then just close the dialog. + > Note 2: If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). ### Setting up WSL1 -Open **Ubuntu** (e.g. using Search). WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in). Note that there will be no visible response when typing in the password, but the terminal will still read in input. - -A few notes before proceeding: -- In the terminal, Copy and Paste is either done via +Some tips before proceeding: +- In WSL, Copy and Paste is either done via - **right-click** (selection + right click to Copy, right click with no selection to Paste) - **Ctrl+Shift+C/Ctrl+Shift+V** (enabled by right-clicking the title bar, going to Properties, then checking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste"). - Some of the commands that you'll run will ask for your WSL password and/or confirmation to perform the stated action. This is to be expected, just enter your WSL password and/or the yes action when necessary. -Update WSL/Ubuntu before continuing. Do this by running the following command: -```bash -sudo apt update && sudo apt upgrade -``` -Note that these commands will likely take a long time to finish. +1. Open **Ubuntu** (e.g. using Search). +2. WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in). -*Note: If the repository you plan to build was created before 2020/XX/YY (e.g. modifications of pokeemerald that haven't updated) then follow the [legacy WSL1 instructions](docs/legacy_WSL1_INSTALL.md). These repositories can be identified by the [older revision](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md) of the INSTALL.md* + > Note: When typing in the password, there will be no visible response, but the terminal will still read in input. -Certain packages are required to build pokeemerald. Install these packages by running the following command: -```bash -sudo apt install build-essential binutils-arm-none-eabi git libpng-dev -``` -(If the above command does not work, try the above command but replacing `apt` with `apt-get`). +3. Update WSL/Ubuntu before continuing. Do this by running the following command: + + ```bash + sudo apt update && sudo apt upgrade + ``` + > Note: These commands will likely take a long time to finish. + +> *Note: If the repository you plan to build was created before 2020/XX/YY (e.g. modifications of pokeemerald that haven't updated) then follow the [legacy WSL1 instructions](docs/legacy_WSL1_INSTALL.md). These repositories can be identified by the [older revision](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md) of the INSTALL.md* + +4. Certain packages are required to build pokeemerald. Install these packages by running the following command: + + ```bash + sudo apt install build-essential binutils-arm-none-eabi git libpng-dev + ``` + > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`. ### Choosing where to store pokeemerald (WSL1) WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to install pokeemerald within Windows. You'll have to change the **current working directory** every time you open WSL. -For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: +For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command, where *\* is your **Windows** username: ```bash cd /mnt/c/Users//Desktop/decomps ``` Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. - -(The Windows C:\ drive is called /mnt/c/ in WSL. Replace *\* in the example path with your **Windows** username. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Desktop/decomp folder"`. Windows path names are case-insensitive so adhereing to capitalization isn't needed) -If this works, then proceed to [Installation](#Installation). +> Note 1: The Windows C:\ drive is called /mnt/c/ in WSL. +> Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Desktop/decomp folder"`. +> Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed -Otherwise, continue reading below for [Windows instructions using msys2](#windows-msys2). +If this works, then proceed to [Installation](#installation). + +Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or continue reading below for [Windows instructions using msys2](#windows-msys2). ## Windows (msys2) -If devkitPro is not installed, or is installed but without the GBA Development component, then go to [Installing devkitPro](#installing-devkitpro). If devkitPro is installed, but msys2 hasn't previously been set up for another decompilation project, then go to [Setting up msys2](#setting-up-msys2). Otherwise, open msys2 and go to [Choosing where to store pokeemerald (msys2)](#choosing-where-to-store-pokeemerald-msys2). +- If devkitPro is **not installed**, or is installed but without the GBA Development component, then go to [Installing devkitPro](#installing-devkitpro). +- If devkitPro is installed, but msys2 **hasn't previously been set up for another decompilation project**, then go to [Setting up msys2](#setting-up-msys2). +- Otherwise, **open msys2** and go to [Choosing where to store pokeemerald (msys2)](#choosing-where-to-store-pokeemerald-msys2). ### Installing devkitPro -Download the devkitPro installer [here](https://github.com/devkitPro/installer/releases). - -Run the devkitPro installer. In the "Choose Components" screen, uncheck everything except GBA Development unless if you plan to use devkitPro for other purposes. Keep the install location as C:\devkitPro and leave the Start Menu option unchanged. +1. Download the devkitPro installer [here](https://github.com/devkitPro/installer/releases). +2. Run the devkitPro installer. In the "Choose Components" screen, uncheck everything except GBA Development unless if you plan to use devkitPro for other purposes. Keep the install location as C:\devkitPro and leave the Start Menu option unchanged. ### Setting up msys2 -Open msys2 at C:\devkitPro\msys2\msys2_shell.bat. Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert. -Certain packages are required to build pokeemerald. Install these by running the following command: -```bash -pacman -S make gcc zlib-devel git -``` -(This command will ask for confirmation, just enter the yes action when prompted). +1. Open msys2 at C:\devkitPro\msys2\msys2_shell.bat. -Download [libpng](https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.xz/download). +2. Certain packages are required to build pokeemerald. Install these by running the following command: -Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at **C:\Users\\__**, where *\* is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: -```bash -cd Downloads -``` -(While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator. Windows path names are case-insensitive so adhereing to capitalization isn’t needed. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`. If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there) + ```bash + pacman -S make gcc zlib-devel git + ``` + > Note: This command will ask for confirmation, just enter the yes action when prompted. -Run the following command to uncompress and install libpng. -```bash -tar xf libpng-1.6.37 -cd libpng-1.6.37 -./configure --prefix=/usr -make check -make install -``` -Then finally, run the following command to change back to the user profile folder. -```bash -cd -``` +3. Download [libpng](https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.xz/download). + +4. Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at **C:\Users\\_\_**, where *\* is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: + + ```bash + cd Downloads + ``` + + > Note 1: While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator. + > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`. + > Note 3: Windows path names are case-insensitive so adhering to capitalization isn’t needed. + > Note 4: If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there. + +5. Run the following commands to uncompress and install libpng. + + ```bash + tar xf libpng-1.6.37 + cd libpng-1.6.37 + ./configure --prefix=/usr + make check + make install + ``` + +6. Then finally, run the following command to change back to the user profile folder. + + ```bash + cd + ``` ### Choosing where to store pokeemerald (msys2) -At this point, you can choose a folder to store pokeemerald into. If so, you'll have to change the **current working directory** every time you open msys2. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). +At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll have to change the **current working directory** an extra time every time you open msys2. For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: ```bash @@ -120,90 +148,106 @@ cd Desktop/decomps ``` Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. -If this works, then proceed to [Installation](#Installation). +If this works, then proceed to [Installation](#installation). -Otherwise, continue reading below for [Windows instructions using Cygwin](#windows-cygwin). +Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or continue reading below for [Windows instructions using Cygwin](#windows-cygwin). ## Windows (Cygwin) -If devkitPro is not installed, or is installed but without the GBA Development component, then follow the instructions used to [install devkitPro](#installing-devkitpro) for the msys2 setup before continuing. Remember to not continue following the msys2 instructions by mistake! +1. If devkitPro is **not installed**, or is installed but without the GBA Development component, then follow the instructions used to [install devkitPro](#installing-devkitpro) for the msys2 setup before continuing. *Remember to not continue following the msys2 instructions by mistake!* -If Cygwin is not installed, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin). If Cygwin is installed, but is not configured to work with devkitPro, then go to [Configuring devkitPro for Cygwin](#configuring-devkitpro-for-cygwin). Otherwise, open Cygwin and go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-cygwin) +2. + - If Cygwin is **not installed**, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin). + - If Cygwin is installed, but **is not configured to work with devkitPro**, then go to [Configuring devkitPro for Cygwin](#configuring-devkitpro-for-cygwin). + - Otherwise, **open Cygwin** and go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-cygwin) ### Installing Cygwin -Download [Cygwin](https://cygwin.com/install.html): setup-x86_64.exe for 64-bit Windows, setup-x86.exe for 32-bit. +1. Download [Cygwin](https://cygwin.com/install.html): setup-x86_64.exe for 64-bit Windows, setup-x86.exe for 32-bit. -Run the Cygwin setup and leave the default settings. At "Choose a Download Site", select any mirror within the Available Download Sites. At "Select Packages", set the view to "Full" (top left) and choose to install the following: -- `make` -- `git` -- `gcc-core` -- `gcc-g++` -- `libpng-devel` +2. Run the Cygwin setup. Within the Cygwin setup, leave the default settings until the "Choose A Download Site" screen. -To quickly find these, use the search bar and type the name of each package. Ensure that the selected package name is the **exact** same as the one you're trying to download, e.g. `cmake` is **NOT** the same as `make`. +3. At "Choose a Download Site", select any mirror within the Available Download Sites. -Double click on the text that says "**Skip**" next to each package to select the most recent version to install. If the text says anything other than "**Skip**", (e.g. Keep or a version number), then the package is or will be installed and you don't need to do anything. +4. At "Select Packages", set the view to "Full" (top left) and search for the following packages: + - `make` + - `git` + - `gcc-core` + - `gcc-g++` + - `libpng-devel` + + To quickly find these, use the search bar and type the name of each package. Ensure that the selected package name is the **exact** same as the one you're trying to download, e.g. `cmake` is **NOT** the same as `make`. + +5. For each package, double click on the text that says "**Skip**" next to each package to select the most recent version to install. If the text says anything other than "**Skip**", (e.g. Keep or a version number), then the package is or will be installed and you don't need to do anything. + +6. Once all required packages have been selected, finish the installation. -Once all required packages have been selected, finish the installation. ### Configuring devkitPro for Cygwin -Open **Cygwin**. Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert. -Run the following commands to configure devkitPro to work with Cygwin. -```bash -export DEVKITPRO=/cygdrive/c/devkitpro -echo export DEVKITPRO=$DEVKITPRO >> ~/.bashrc -export DEVKITARM=$DEVKITPRO/devkitARM -echo export DEVKITARM=$DEVKITARM >> ~/.bashrc -``` -(Replace the drive letter c with the actual drive letter if it is not c). +1. Open **Cygwin**. + +2. Run the following commands to configure devkitPro to work with Cygwin. + + ```bash + export DEVKITPRO=/cygdrive/c/devkitpro + echo export DEVKITPRO=$DEVKITPRO >> ~/.bashrc + export DEVKITARM=$DEVKITPRO/devkitARM + echo export DEVKITARM=$DEVKITARM >> ~/.bashrc + ``` + + > Note: Replace the drive letter c with the actual drive letter if it is not c. ### Choosing where to store pokeemerald (Cygwin) Cygwin has its own file system that's within Windows, at **C:\cygwin64\home\\_\_**. If you don't want to store pokeemerald there, you'll have to change the **current working directory** every time you open Cygwin. -For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: +For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command, where *\* is your **Windows** username: ```bash cd c:/Users//Desktop/decomps ``` Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. -(Replace *\* in the example path with your **Windows** username. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. Windows path names are case-insensitive so adhereing to capitalization isn't needed) +> Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. +> Note 2: Windows path names are case-insensitive so adhering to capitalization isn't needed -If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). +If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)). ## macOS -If the Xcode Command Line Tools are not installed, download the tools [here](https://developer.apple.com/library/archive/technotes/tn2339/_index.html), open your Terminal, and run the following command: -```bash -xcode-select --install -``` +1. If the Xcode Command Line Tools are not installed, download the tools [here](https://developer.apple.com/library/archive/technotes/tn2339/_index.html), open your Terminal, and run the following command: -If devkitPro is not installed, then go to [Installing devkitPro (macOS)](#installing-devkitpro-macos). Otherwise, open the Terminal and go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos) + ```bash + xcode-select --install + ``` + +2. - If devkitPro is **not installed**, then go to [Installing devkitPro (macOS)](#installing-devkitpro-macos). + - Otherwise, **open the Terminal** and go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos) ### Installing devkitPro (macOS) -Download the `devkitpro-pacman-installer.pkg` package from [here](https://github.com/devkitPro/pacman/releases). +1. Download the `devkitpro-pacman-installer.pkg` package from [here](https://github.com/devkitPro/pacman/releases). +2. Open the package to install devkitPro pacman. +3. devkitPro must be configured with the tools required for GBA development. Run the following commands: -Open the package to install devkitPro pacman. + ```bash + sudo dkp-pacman -Sy + sudo dkp-pacman -S gba-dev + sudo dkp-pacman -S devkitarm-rules + ``` -devkitPro must be configured with the tools required for GBA development. Run the following commands: -```bash -sudo dkp-pacman -Sy -sudo dkp-pacman -S gba-dev -sudo dkp-pacman -S devkitarm-rules -``` -At this point, press Enter to confirm the installation. After the tools are installed, devkitPro must now be made accessible from anywhere by the system. To do so, run the following commands: + The command with gba-dev will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. -``` -export DEVKITPRO=$HOME/devkitpro -echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc -export DEVKITARM=$DEVKITPRO/devkitARM -echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc +4. After the tools are installed, devkitPro must now be made accessible from anywhere by the system. To do so, run the following commands: -echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile -``` + ```bash + export DEVKITPRO=$HOME/devkitpro + echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc + export DEVKITARM=$DEVKITPRO/devkitARM + echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc + + echo "if [ -f ~/.bashrc ]; then . ~/.bashrc; fi" >> ~/.bash_profile + ``` ### Choosing where to store pokeemerald (macOS) -At this point, you can choose a folder to store pokeemerald into. If so, you'll have to change the **current working directory** every time you open the Terminal. If you're okay with storing pokeemerald in the user folder, then proceed to [Installation](#installation). +At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user folder, then proceed to [Installation](#installation). Otherwise, you'll have to change the **current working directory** an extra time every time you open the Terminal. For example, if you want to store pokeemerald (and agbcc) in **~/Desktop/decomps**, enter this command: ```bash @@ -211,9 +255,9 @@ cd Desktop/decomps ``` Note that the directory **must exist** in the folder system. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the `cd` command. -(If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"`) +> Note: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"` -If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). +If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)). ## Linux Open Terminal and enter the following commands, depending on which distro you're using. @@ -228,70 +272,84 @@ Then proceed to [Choosing where to store pokeemerald (Linux)](#choosing-where-to ### Other distributions _(Specific instructions for other distributions would be greatly appreciated!)_ -Try to find the required software in its repositories: -- `gcc` -- `g++` -- `make` -- `git` -- `libpng-dev` +1. Try to find the required software in its repositories: + - `gcc` + - `g++` + - `make` + - `git` + - `libpng-dev` -Then, follow the instructions [here](https://devkitpro.org/wiki/devkitPro_pacman) to install devkitPro's pacman installer. As a reminder, the goal is to configure an existing pacman installation to recognize devkitPro's repositories. +2. Follow the instructions [here](https://devkitpro.org/wiki/devkitPro_pacman) to install devkitPro's pacman installer. As a reminder, the goal is to configure an existing pacman installation to recognize devkitPro's repositories. +3. Once devkitPro pacman is configured, run the following commands: -Once devkitPro pacman is configured, run the following commands: -```bash -sudo pacman -Sy -sudo pacman -S gba-dev -``` -Note: the last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. + ```bash + sudo pacman -Sy + sudo pacman -S gba-dev + ``` + + The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. ### Choosing where to store pokeemerald (Linux) -At this point, you can choose a folder to store pokeemerald (and agbcc) into. If so, you'll have to change the current working directory every time you open the Terminal. +At this point, you can choose a folder to store pokeemerald (and agbcc) into. If so, you'll have to account for the modified folder path when changing directory to the pokeemerald folder. -If this works, then proceed to [Installation](#Installation). Otherwise, ask for help on IRC or Discord (see [README.md](README.md)). +If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)). ## Installation -**Windows users:** Consider adding an exception for the `pokeemerald`/`decomps` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. +**Windows users:** Consider adding an exception for the `pokeemerald` and/or `decomps` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. -If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: -```bash -git clone https://github.com/luckytyphlosion/pokeemerald -``` -Note for WSL1: If you get an error stating `fatal: could not set 'core.filemode' to 'false'`, then run the following commands: -```bash -cd -sudo umount /mnt/c -sudo mount -t drvfs C: /mnt/c -o metadata,noatime -cd -``` -Where *\* is the path of the folder [where you chose to store pokeemerald](#Choosing-where-to-store-pokeemerald-WSL1). Then run the `git clone` command again. +1. If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: + + ```bash + git clone https://github.com/luckytyphlosion/pokeemerald + ``` + + > Note for WSL1: If you get an error stating `fatal: could not set 'core.filemode' to 'false'`, then run the following commands: + >```bash + >cd + >sudo umount /mnt/c + >sudo mount -t drvfs C: /mnt/c -o metadata,noatime + >cd + >``` + > Where *\* is the path of the folder [where you chose to store pokeemerald](#Choosing-where-to-store-pokeemerald-WSL1). Then run the `git clone` command again. + +2. Install agbcc into pokeemerald. The commands to run depend on certain conditions: +- If agbcc has **not been built before** in the folder where you chose to store pokeemerald, run the following commands to build and install it into pokeemerald: + + ```bash + git clone https://github.com/luckytyphlosion/agbcc + cd agbcc + ./build.sh + ./install.sh ../pokeemerald + ``` + +- If agbcc has been built before (e.g. if the git clone above fails), but was **last built on a different terminal** than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokeemerald: + + ```bash + cd agbcc + git clean -fX + ./build.sh + ./install.sh ../pokeemerald + ``` + +- Otherwise, run the following commands to install agbcc into pokeemerald: + + ```bash + cd agbcc + ./install.sh ../pokeemerald + ``` + + > Note: If building agbcc or pokeemerald results in an error, try deleting the agbcc folder and re-installing agbcc as if it has not been built before. + +3. Once agbcc is installed, change directory back to the base directory where pokeemerald and agbcc are stored: + + ```bash + cd .. + ``` -If agbcc has not been built before, run the following commands to build and install it into pokeemerald: -``` -git clone https://github.com/luckytyphlosion/agbcc -cd agbcc -./build.sh -./install.sh ../pokeemerald -``` -If agbcc has been built before (e.g. if the git clone above fails), but was **last built on a different terminal** than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokeemerald: -``` -cd agbcc -git clean -fX -./build.sh -./install.sh ../pokeemerald -``` -Otherwise, run the following commands to install agbcc into pokeemerald: -``` -cd agbcc -./install.sh ../pokeemerald -``` -Then, change directory back to the base directory where pokeemerald and agbcc are stored: -``` -cd .. -``` Now you're ready to [build **pokeemerald**](#build-pokeemerald) ## Build pokeemerald -First, change directory to the pokeemerald folder: +If you aren't in the pokeemerald directory already, then **change directory** to the pokeemerald folder: ```bash cd pokeemerald ``` @@ -299,7 +357,8 @@ To build **pokeemerald.gba** for the first time and confirm it matches the offic ```bash make compare ``` -If an OK is returned, then the installation went smoothly. **Note:** if you switched terminals on Windows since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands. +If an OK is returned, then the installation went smoothly. +> Note for Windows: if you switched terminals since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands. To build **pokeemerald.gba** with your changes: ```bash @@ -312,7 +371,7 @@ make See [the GNU docs](https://www.gnu.org/software/make/manual/html_node/Parallel.html) and [this Stack Exchange thread](https://unix.stackexchange.com/questions/208568) for more information. -To speed up building, first get the value of `nproc`: +To speed up building, first get the value of `nproc` by running the following command: ```bash nproc ``` @@ -340,65 +399,75 @@ make modern Otherwise, follow the instructions below to install devkitARM. ### Installing devkitARM on WSL1 -`gdebi-core` must be installed beforehand in order to install devkitPro (which facilitates the installation of devkitARM). Install this with the following command: -```bash -sudo apt install gdebi-core -``` -(If the above command does not work, try the above command but replacing `apt` with `apt-get`). +1. `gdebi-core` must be installed beforehand in order to install devkitPro (which facilitates the installation of devkitARM). Install this with the following command: -Once `gdebi-core` is done installing, download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. + ```bash + sudo apt install gdebi-core + ``` + > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`. -Change directory to where the package was downloaded. For example, if the package file was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: -```bash -cd /mnt/c/Users//Downloads -``` -(Replace *\* with your Windows username) +2. Once `gdebi-core` is done installing, download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. +3. Change directory to where the package was downloaded. For example, if the package file was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command, where *\ is your **Windows** username: -Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. -```bash -sudo gdebi devkitpro-pacman.amd64.deb -sudo dkp-pacman -Sy -sudo dkp-pacman -S gba-dev -``` -Note: the last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + ```bash + cd /mnt/c/Users//Downloads + ``` + +4. Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. + + ```bash + sudo gdebi devkitpro-pacman.amd64.deb + sudo dkp-pacman -Sy + sudo dkp-pacman -S gba-dev + ``` + The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. + + > Note: `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + +5. Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL): + + ```bash + source /etc/profile.d/devkit-env.sh + ``` -Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL): -```bash -source /etc/profile.d/devkit-env.sh -``` devkitARM is now installed. ### Installing devkitARM on Debian/Ubuntu-based distributions -If `gdebi-core` is not installed, run the following command: -```bash -sudo apt install gdebi-core -``` -Download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. +1. If `gdebi-core` is not installed, run the following command: -Change directory to where the package was downloaded. Then, run the following commands to install devkitARM: -```bash -sudo gdebi devkitpro-pacman.amd64.deb -sudo dkp-pacman -Sy -sudo dkp-pacman -S gba-dev -``` -Note: the last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + ```bash + sudo apt install gdebi-core + ``` +2. Download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. +3. Change directory to where the package was downloaded. Then, run the following commands to install devkitARM: + + ```bash + sudo gdebi devkitpro-pacman.amd64.deb + sudo dkp-pacman -Sy + sudo dkp-pacman -S gba-dev + ``` + The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. + + > Note: `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + +4. Run the following command to set devkitPro related environment variables (alternatively, close and re-open the Terminal): + + ```bash + source /etc/profile.d/devkit-env.sh + ``` -Run the following command to set devkitPro related environment variables (alternatively, close and re-open the Terminal): -```bash -source /etc/profile.d/devkit-env.sh -``` devkitARM is now installed. ## Other toolchains To build using a toolchain other than devkitARM, override the `TOOLCHAIN` environment variable with the path to your toolchain, which must contain the subdirectory `bin`. - - make TOOLCHAIN="/path/to/toolchain/here" - +```bash +make TOOLCHAIN="/path/to/toolchain/here" +``` The following is an example: - - make TOOLCHAIN="/usr/local/arm-none-eabi" - +```bash +make TOOLCHAIN="/usr/local/arm-none-eabi" +``` To compile the `modern` target with this toolchain, the subdirectories `lib`, `include`, and `arm-none-eabi` must also be present. # Useful additional tools diff --git a/docs/legacy_WSL1_INSTALL.md b/docs/legacy_WSL1_INSTALL.md index 731b8f4338..f848abf676 100644 --- a/docs/legacy_WSL1_INSTALL.md +++ b/docs/legacy_WSL1_INSTALL.md @@ -1,32 +1,41 @@ ### Setting up WSL1 (Legacy Portion) -Certain packages are required to build pokeemerald. Install these packages by running the following command: -```bash -sudo apt install build-essential git libpng-dev gdebi-core -``` -(If the above command does not work, try the above command but replacing `apt` with `apt-get`). -Download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. +1. Certain packages are required to build pokeemerald. Install these packages by running the following command: -WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. To install the devkitPro package, you'll need to change to the **current working directory** where the package file was saved. + ```bash + sudo apt install build-essential git libpng-dev gdebi-core + ``` + > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`. -For example, if the package file was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: +2. Once the packages have finished installing, download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. -```bash -cd /mnt/c/Users//Downloads -``` +3. WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. To install the devkitPro package, you'll need to change to the **current working directory** where the package file was saved. -(The Windows C:\ drive is called /mnt/c/ in WSL. Replace in the example path with your **Windows** username. If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Downloads folder"`. Windows path names are case-insensitive so adhereing to capitalization isn't needed) + For example, if the package file was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command, where *\* is your **Windows** username: -Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. -```bash -sudo gdebi devkitpro-pacman.amd64.deb -sudo dkp-pacman -Sy -sudo dkp-pacman -S gba-dev -``` -Note: the last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + ```bash + cd /mnt/c/Users//Downloads + ``` + + > Note 1: The Windows C:\ drive is called /mnt/c/ in WSL. + > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Downloads folder"`. + > Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed + +4. Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. + + ```bash + sudo gdebi devkitpro-pacman.amd64.deb + sudo dkp-pacman -Sy + sudo dkp-pacman -S gba-dev + ``` + + The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. + + > Note: `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. + +5. Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL): + ```bash + source /etc/profile.d/devkit-env.sh + ``` -Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL): -```bash -source /etc/profile.d/devkit-env.sh -``` Proceed to [Choosing where to store pokeemerald (WSL1) of the current INSTALL.md](/INSTALL.md#choosing-where-to-store-pokeemerald-WSL1). From 56cad5c240a2ebb8fab2eec87ec4105f0875fddd Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 23 Dec 2020 18:14:33 -0500 Subject: [PATCH 30/43] Re-add note about Qt since Porymap hasn't upgraded to 6.0. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index b3c106e725..76ad51a242 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -12,7 +12,7 @@ Windows has instructions for building with three possible terminals, if users en Unscientific benchmarks suggest **msys2 is 2x slower** than WSL1, and **Cygwin is 5-6x slower** than WSL1. -> Note for advanced users: **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools may have trouble interacting with the WSL2 file system over the network drive. +> Note for advanced users: **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools may have trouble interacting with the WSL2 file system over the network drive. For example, tools which use Qt versions before 6.0 such as [porymap](https://github.com/huderlem/porymap) may [have problems with parsing the `\\wsl$` network drive path](https://bugreports.qt.io/browse/QTBUG-86277). All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions. From feb6befd09889d2f4518bbd6b6acf45872b95287 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 23 Dec 2020 22:51:35 -0500 Subject: [PATCH 31/43] Improve storage instructions as per Griffin's recommendations. Todo actually properly proofread this. --- INSTALL.md | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 76ad51a242..82c22d94b8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -12,7 +12,7 @@ Windows has instructions for building with three possible terminals, if users en Unscientific benchmarks suggest **msys2 is 2x slower** than WSL1, and **Cygwin is 5-6x slower** than WSL1. -> Note for advanced users: **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools may have trouble interacting with the WSL2 file system over the network drive. For example, tools which use Qt versions before 6.0 such as [porymap](https://github.com/huderlem/porymap) may [have problems with parsing the `\\wsl$` network drive path](https://bugreports.qt.io/browse/QTBUG-86277). +> Note for advanced users: **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools may have trouble interacting with the WSL2 file system over the network drive. For example, tools which use Qt versions before 5.15.2 such as [porymap](https://github.com/huderlem/porymap) may [have problems with parsing the `\\wsl$` network drive path](https://bugreports.qt.io/browse/QTBUG-86277). All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions. @@ -71,9 +71,9 @@ Some tips before proceeding: > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`. ### Choosing where to store pokeemerald (WSL1) -WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to install pokeemerald within Windows. You'll have to change the **current working directory** every time you open WSL. +WSL has its own file system that's not natively accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to install pokeemerald within Windows. -For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command, where *\* is your **Windows** username: +For example, say you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**. If pokeemerald and/or agbcc hasn't been installed yet, then enter the following command, where *\* is your **Windows** username: ```bash cd /mnt/c/Users//Desktop/decomps ``` @@ -81,7 +81,11 @@ Note that the directory **must exist** in Windows. If you want to store pokeemer > Note 1: The Windows C:\ drive is called /mnt/c/ in WSL. > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Desktop/decomp folder"`. -> Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed +> Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed +> Note 4: If pokeemerald is already installed, then run the following command instead (for the provided example path): +> ```bash +> cd /mnt/c/Users//Desktop/decomps/pokeemerald +> ``` If this works, then proceed to [Installation](#installation). @@ -140,14 +144,21 @@ Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert. ``` ### Choosing where to store pokeemerald (msys2) -At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll have to change the **current working directory** an extra time every time you open msys2. +At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder. + +For example, say you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**. If pokeemerald and/or agbcc hasn't been installed yet, then enter the following command to **change directory** to the desired folder: -For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command: ```bash cd Desktop/decomps ``` + Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. +> Note: If pokeemerald is already installed, then run the following command instead (for the provided example path): +> ```bash +> cd Desktop/decomps/pokeemerald +> ``` + If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or continue reading below for [Windows instructions using Cygwin](#windows-cygwin). @@ -199,7 +210,7 @@ Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert. ### Choosing where to store pokeemerald (Cygwin) -Cygwin has its own file system that's within Windows, at **C:\cygwin64\home\\_\_**. If you don't want to store pokeemerald there, you'll have to change the **current working directory** every time you open Cygwin. +Cygwin has its own file system that's within Windows, at **C:\cygwin64\home\\_\_**. If you don't want to store pokeemerald there, you'll need to account for where pokeemerald is stored when **changing directory** to the pokeemerald folder. For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**, enter this command, where *\* is your **Windows** username: ```bash @@ -209,6 +220,10 @@ Note that the directory **must exist** in Windows. If you want to store pokeemer > Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. > Note 2: Windows path names are case-insensitive so adhering to capitalization isn't needed +> Note 3: If pokeemerald is already installed, then run the following command instead (for the provided example path): +> ```bash +> cd c:/Users//Desktop/decomps/pokeemerald +> ``` If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)). @@ -247,15 +262,19 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ``` ### Choosing where to store pokeemerald (macOS) -At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user folder, then proceed to [Installation](#installation). Otherwise, you'll have to change the **current working directory** an extra time every time you open the Terminal. +At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder. -For example, if you want to store pokeemerald (and agbcc) in **~/Desktop/decomps**, enter this command: +For example, say you want to store pokeemerald (and agbcc) in **~/Desktop/decomps**. If pokeemerald and/or agbcc hasn't been installed yet, then enter the following command to **change directory** to the desired folder: ```bash cd Desktop/decomps ``` Note that the directory **must exist** in the folder system. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the `cd` command. -> Note: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"` +> Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"` +> Note 2: If pokeemerald is already installed, then run the following command instead (for the provided example path: +> ```bash +> cd Desktop/decomps/pokeemerald +> ``` If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)). From a0344a4094e97a11415a26758357071c06c591cc Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 30 Dec 2020 18:49:04 -0500 Subject: [PATCH 32/43] Forgot to add some line breaks. --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 82c22d94b8..7dd860e845 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -219,7 +219,7 @@ cd c:/Users//Desktop/decomps Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. > Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. -> Note 2: Windows path names are case-insensitive so adhering to capitalization isn't needed +> Note 2: Windows path names are case-insensitive so adhering to capitalization isn't needed > Note 3: If pokeemerald is already installed, then run the following command instead (for the provided example path): > ```bash > cd c:/Users//Desktop/decomps/pokeemerald @@ -270,7 +270,7 @@ cd Desktop/decomps ``` Note that the directory **must exist** in the folder system. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the `cd` command. -> Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"` +> Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"` > Note 2: If pokeemerald is already installed, then run the following command instead (for the provided example path: > ```bash > cd Desktop/decomps/pokeemerald From e744d86bf15db8e8ca172b849ac3473ae34194c3 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 30 Dec 2020 20:56:04 -0500 Subject: [PATCH 33/43] Fix msys2 instructions, also add more formatting to installation instructions. --- INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 7dd860e845..566d373792 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -130,7 +130,7 @@ Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert. 5. Run the following commands to uncompress and install libpng. ```bash - tar xf libpng-1.6.37 + tar xf libpng-1.6.37.tar.xz cd libpng-1.6.37 ./configure --prefix=/usr make check @@ -342,7 +342,7 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ./install.sh ../pokeemerald ``` -- If agbcc has been built before (e.g. if the git clone above fails), but was **last built on a different terminal** than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokeemerald: +- **Otherwise**, if agbcc has been built before (e.g. if the git clone above fails), but was **last built on a different terminal** than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pokeemerald: ```bash cd agbcc @@ -351,7 +351,7 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ./install.sh ../pokeemerald ``` -- Otherwise, run the following commands to install agbcc into pokeemerald: +- **Otherwise**, run the following commands to install agbcc into pokeemerald: ```bash cd agbcc From 98f8c96c9e21791651d2274f07046496ab826ff2 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 4 Jan 2021 11:35:59 -0500 Subject: [PATCH 34/43] Fix $(AR) define, remove \u warns on macOS. --- Makefile | 21 ++++++++++++++++----- berry_fix/Makefile | 22 +++++++++++++++++++--- berry_fix/payload/Makefile | 20 ++++++++++++++++++-- libagbsyscall/Makefile | 21 +++++++++++++++++++-- 4 files changed, 72 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 306b8fb6e8..3bb5161e31 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ COMPARE ?= 0 # 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 tihs system +# if dkP is not installed on this system ifneq (,$(TOOLCHAIN)) ifneq ($(wildcard $(TOOLCHAIN)/bin),) @@ -36,10 +36,21 @@ MAKER_CODE := 01 REVISION := 0 MODERN ?= 0 +# 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) -CPP := $(CC) -E + ifeq ($(shell uname -s),Darwin) + CPP := $(PREFIX)cpp + else + CPP := $(CC) -E + endif else -CPP := $(PREFIX)cpp + CPP := $(PREFIX)cpp endif ROM_NAME := pokeemerald.gba @@ -362,7 +373,7 @@ modern: ; @$(MAKE) MODERN=1 berry_fix/berry_fix.gba: berry_fix berry_fix: - @$(MAKE) -C berry_fix COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN) + @$(MAKE) -C berry_fix COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN) libagbsyscall: - @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) + @$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN) diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 8b8d07d427..464e5f9e9c 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -6,7 +6,7 @@ COMPARE ?= 0 # 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 tihs system +# if dkP is not installed on this system ifneq (,$(TOOLCHAIN)) ifneq ($(wildcard $(TOOLCHAIN)/bin),) @@ -17,7 +17,6 @@ endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy AS := $(PREFIX)as -CPP := $(CC) -E LD := $(PREFIX)ld # note: the makefile must be set up so MODERNCC is never called @@ -30,6 +29,23 @@ else EXE := 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 + GAME_CODE := AGBJ MAKER_CODE := 01 REVISION := 0 @@ -165,7 +181,7 @@ $(DATA_ASM_BUILDDIR)/%.o: data_dep = $(shell $(SCANINC) $(DATA_ASM_SUBDIR)/$*.s) endif payload: - @$(MAKE) -C payload COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN) + @$(MAKE) -C payload COMPARE=$(COMPARE) TOOLCHAIN=$(TOOLCHAIN) MODERN=$(MODERN) payload/payload.gba: payload diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index bae657c927..2779c43ba8 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -6,7 +6,7 @@ COMPARE ?= 0 # 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 tihs system +# if dkP is not installed on this system ifneq (,$(TOOLCHAIN)) ifneq ($(wildcard $(TOOLCHAIN)/bin),) @@ -17,7 +17,6 @@ endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy AS := $(PREFIX)as -CPP := $(CC) -E LD := $(PREFIX)ld # note: the makefile must be set up so MODERNCC is never called @@ -30,6 +29,23 @@ else EXE := 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 + SHELL := /bin/bash -o pipefail CPPFLAGS := -I ../../tools/agbcc/include -I ../../tools/agbcc -iquote include -nostdinc -undef diff --git a/libagbsyscall/Makefile b/libagbsyscall/Makefile index 76368da86b..78f246af40 100644 --- a/libagbsyscall/Makefile +++ b/libagbsyscall/Makefile @@ -6,7 +6,7 @@ COMPARE ?= 0 # 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 tihs system +# if dkP is not installed on this system ifneq (,$(TOOLCHAIN)) ifneq ($(wildcard $(TOOLCHAIN)/bin),) @@ -17,8 +17,8 @@ endif PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy AS := $(PREFIX)as -CPP := $(CC) -E LD := $(PREFIX)ld +AR := $(PREFIX)ar # note: the makefile must be set up so MODERNCC is never called # if MODERN=0 @@ -30,6 +30,23 @@ else EXE := 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 + ASFLAGS := -mcpu=arm7tdmi ARFLAGS := rc From 11eb805856262585248db63668d781d635d266af Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Sun, 31 Jan 2021 16:22:54 -0500 Subject: [PATCH 35/43] Temporary fix for macOS install. Should probably figure out what's exactly setting $DEVKITPRO since it's set by something else upon opening the Terminal. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 566d373792..a59d4002ca 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -253,7 +253,7 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for 4. After the tools are installed, devkitPro must now be made accessible from anywhere by the system. To do so, run the following commands: ```bash - export DEVKITPRO=$HOME/devkitpro + export DEVKITPRO=/opt/devkitpro echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc export DEVKITARM=$DEVKITPRO/devkitARM echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc From 4c3c61fa357c36444daade4d16a741418fff95a2 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 8 Feb 2021 11:55:36 -0500 Subject: [PATCH 36/43] Add instructions for installing libpng on macOS --- INSTALL.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a59d4002ca..fdeffca766 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -234,13 +234,28 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for xcode-select --install ``` -2. - If devkitPro is **not installed**, then go to [Installing devkitPro (macOS)](#installing-devkitpro-macos). - - Otherwise, **open the Terminal** and go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos) +2. - If libpng is **not installed**, then go to [Installing libpng (macOS)](#installing-libpng-macos). + - If devkitPro is **not installed**, then go to [Installing devkitPro (macOS)](#installing-devkitpro-macos). + - Otherwise, **open the Terminal** and go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos) + +### Installing libpng (macOS) +> Note for advanced users: This guide installs libpng via Homebrew as it is the easiest method, however advanced users can install libpng through other means if they so desire. + +1. Open the Terminal. +2. If Homebrew is not installed, then install [Homebrew](https://brew.sh/) by following the instructions on the website. +3. Run the following command to install libpng. + + ```bash + brew install libpng + ``` + libpng is now installed. + + Continue to [Installing devkitPro (macOS)](#installing-devkitpro-macos) if **devkitARM is not installed**, otherwise, go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos). ### Installing devkitPro (macOS) 1. Download the `devkitpro-pacman-installer.pkg` package from [here](https://github.com/devkitPro/pacman/releases). 2. Open the package to install devkitPro pacman. -3. devkitPro must be configured with the tools required for GBA development. Run the following commands: +3. devkitPro must be configured with the tools required for GBA development. In the Terminal, run the following commands: ```bash sudo dkp-pacman -Sy From 0f13e061e1d652b2e1d9a1515f10d831f63cc5f5 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 8 Feb 2021 12:35:21 -0500 Subject: [PATCH 37/43] Fix up dkP related naming. --- INSTALL.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index fdeffca766..d91f824340 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -93,13 +93,13 @@ Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or conti ## Windows (msys2) -- If devkitPro is **not installed**, or is installed but without the GBA Development component, then go to [Installing devkitPro](#installing-devkitpro). -- If devkitPro is installed, but msys2 **hasn't previously been set up for another decompilation project**, then go to [Setting up msys2](#setting-up-msys2). +- If devkitARM is **not installed**, then go to [Installing devkitARM](#installing-devkitarm). +- If devkitARM is installed, but msys2 **hasn't previously been set up for another decompilation project**, then go to [Setting up msys2](#setting-up-msys2). - Otherwise, **open msys2** and go to [Choosing where to store pokeemerald (msys2)](#choosing-where-to-store-pokeemerald-msys2). -### Installing devkitPro +### Installing devkitARM 1. Download the devkitPro installer [here](https://github.com/devkitPro/installer/releases). -2. Run the devkitPro installer. In the "Choose Components" screen, uncheck everything except GBA Development unless if you plan to use devkitPro for other purposes. Keep the install location as C:\devkitPro and leave the Start Menu option unchanged. +2. Run the devkitPro installer. In the "Choose Components" screen, uncheck everything except GBA Development unless if you plan to install other devkitPro components for other purposes. Keep the install location as C:\devkitPro and leave the Start Menu option unchanged. ### Setting up msys2 @@ -164,11 +164,11 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or continue reading below for [Windows instructions using Cygwin](#windows-cygwin). ## Windows (Cygwin) -1. If devkitPro is **not installed**, or is installed but without the GBA Development component, then follow the instructions used to [install devkitPro](#installing-devkitpro) for the msys2 setup before continuing. *Remember to not continue following the msys2 instructions by mistake!* +1. If devkitARM is **not installed**, then follow the instructions used to [install devkitARM](#installing-devkitarm) for the msys2 setup before continuing. *Remember to not continue following the msys2 instructions by mistake!* 2. - If Cygwin is **not installed**, or does not have all of the required packages installed, then go to [Installing Cygwin](#installing-cygwin). - - If Cygwin is installed, but **is not configured to work with devkitPro**, then go to [Configuring devkitPro for Cygwin](#configuring-devkitpro-for-cygwin). + - If Cygwin is installed, but **is not configured to work with devkitARM**, then go to [Configuring devkitARM for Cygwin](#configuring-devkitarm-for-cygwin). - Otherwise, **open Cygwin** and go to [Choosing where to store pokeemerald (Cygwin)](#choosing-where-to-store-pokeemerald-cygwin) ### Installing Cygwin @@ -191,7 +191,7 @@ Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or conti 6. Once all required packages have been selected, finish the installation. -### Configuring devkitPro for Cygwin +### Configuring devkitARM for Cygwin Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert. @@ -235,7 +235,7 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ``` 2. - If libpng is **not installed**, then go to [Installing libpng (macOS)](#installing-libpng-macos). - - If devkitPro is **not installed**, then go to [Installing devkitPro (macOS)](#installing-devkitpro-macos). + - If devkitARM is **not installed**, then go to [Installing devkitARM (macOS)](#installing-devkitarm-macos). - Otherwise, **open the Terminal** and go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos) ### Installing libpng (macOS) @@ -250,12 +250,12 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ``` libpng is now installed. - Continue to [Installing devkitPro (macOS)](#installing-devkitpro-macos) if **devkitARM is not installed**, otherwise, go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos). + Continue to [Installing devkitARM (macOS)](#installing-devkitarm-macos) if **devkitARM is not installed**, otherwise, go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos). -### Installing devkitPro (macOS) +### Installing devkitARM (macOS) 1. Download the `devkitpro-pacman-installer.pkg` package from [here](https://github.com/devkitPro/pacman/releases). 2. Open the package to install devkitPro pacman. -3. devkitPro must be configured with the tools required for GBA development. In the Terminal, run the following commands: +3. In the Terminal, run the following commands to install devkitARM: ```bash sudo dkp-pacman -Sy @@ -265,7 +265,7 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for The command with gba-dev will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. -4. After the tools are installed, devkitPro must now be made accessible from anywhere by the system. To do so, run the following commands: +4. After the tools are installed, devkitARM must now be made accessible from anywhere by the system. To do so, run the following commands: ```bash export DEVKITPRO=/opt/devkitpro @@ -313,7 +313,7 @@ _(Specific instructions for other distributions would be greatly appreciated!)_ - `git` - `libpng-dev` -2. Follow the instructions [here](https://devkitpro.org/wiki/devkitPro_pacman) to install devkitPro's pacman installer. As a reminder, the goal is to configure an existing pacman installation to recognize devkitPro's repositories. +2. Follow the instructions [here](https://devkitpro.org/wiki/devkitPro_pacman) to install devkitPro pacman. As a reminder, the goal is to configure an existing pacman installation to recognize devkitPro's repositories. 3. Once devkitPro pacman is configured, run the following commands: ```bash @@ -433,21 +433,21 @@ make modern Otherwise, follow the instructions below to install devkitARM. ### Installing devkitARM on WSL1 -1. `gdebi-core` must be installed beforehand in order to install devkitPro (which facilitates the installation of devkitARM). Install this with the following command: +1. `gdebi-core` must be installed beforehand in order to install devkitPro pacman (which facilitates the installation of devkitARM). Install this with the following command: ```bash sudo apt install gdebi-core ``` > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`. -2. Once `gdebi-core` is done installing, download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. +2. Once `gdebi-core` is done installing, download the devkitPro pacman package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. 3. Change directory to where the package was downloaded. For example, if the package file was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command, where *\ is your **Windows** username: ```bash cd /mnt/c/Users//Downloads ``` -4. Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. +4. Once the directory has been changed to the folder containing the devkitPro pacman package, run the following commands to install devkitPro pacman. ```bash sudo gdebi devkitpro-pacman.amd64.deb @@ -472,7 +472,7 @@ devkitARM is now installed. ```bash sudo apt install gdebi-core ``` -2. Download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. +2. Download the devkitPro pacman package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. 3. Change directory to where the package was downloaded. Then, run the following commands to install devkitARM: ```bash From 6a865be4c2f640b482d91ede650b52b4b7d5778f Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 8 Feb 2021 12:38:49 -0500 Subject: [PATCH 38/43] Fix up incorrect term. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index d91f824340..1ba2e7b425 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -447,7 +447,7 @@ Otherwise, follow the instructions below to install devkitARM. cd /mnt/c/Users//Downloads ``` -4. Once the directory has been changed to the folder containing the devkitPro pacman package, run the following commands to install devkitPro pacman. +4. Once the directory has been changed to the folder containing the devkitPro pacman package, run the following commands to install devkitARM. ```bash sudo gdebi devkitpro-pacman.amd64.deb From 1760d6801074ff20568726beeaea4d539aa9f1bd Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Mon, 8 Feb 2021 12:39:43 -0500 Subject: [PATCH 39/43] Fix up dkP related naming here as well. --- docs/legacy_WSL1_INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/legacy_WSL1_INSTALL.md b/docs/legacy_WSL1_INSTALL.md index f848abf676..b9840d1c82 100644 --- a/docs/legacy_WSL1_INSTALL.md +++ b/docs/legacy_WSL1_INSTALL.md @@ -7,7 +7,7 @@ ``` > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`. -2. Once the packages have finished installing, download the devkitPro software package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. +2. Once the packages have finished installing, download the devkitPro pacman package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. 3. WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. To install the devkitPro package, you'll need to change to the **current working directory** where the package file was saved. @@ -21,7 +21,7 @@ > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Downloads folder"`. > Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed -4. Once the directory has been changed to the folder containing the devkitPro package, run the following commands to install devkitPro. +4. Once the directory has been changed to the folder containing the devkitPro pacman package, run the following commands to install devkitARM. ```bash sudo gdebi devkitpro-pacman.amd64.deb From 52ab1acea16e98accf70acf0fdac493a370550ee Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 10 Feb 2021 17:32:46 -0500 Subject: [PATCH 40/43] Easy changes per Griffin's comments --- INSTALL.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 1ba2e7b425..36d2b9d252 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -5,7 +5,7 @@ These instructions explain how to set up the tools required to build **pokeemera If you run into trouble, ask for help on Discord or IRC (see [README.md](README.md)). ## Windows -Windows has instructions for building with three possible terminals, if users encounter unexpected errors in following instructions for one of the terminals. These instructions are: +Windows has instructions for building with three possible terminals, providing 3 different options in case the user stumbled upon unexpected errors. - [Windows 10 (WSL1)](#windows-10-wsl1) (**Fastest, highly recommended**, Windows 10 only) - [Windows (msys2)](#windows-msys2) (Second fastest) - [Windows (Cygwin)](#windows-cygwin) (Slowest) @@ -35,7 +35,7 @@ WSL1 is the preferred terminal to build **pokeemerald**. The following instructi 3. The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice. - > Note for advanced users: Advanced users can pick a preferred Linux distribution, but setup instructions may differ. Debian should work with the given instructions, but has not been tested. + > Note for advanced users: You can pick a preferred Linux distribution, but setup instructions may differ. Debian should work with the given instructions, but has not been tested. 4. Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. @@ -61,7 +61,7 @@ Some tips before proceeding: ``` > Note: These commands will likely take a long time to finish. -> *Note: If the repository you plan to build was created before 2020/XX/YY (e.g. modifications of pokeemerald that haven't updated) then follow the [legacy WSL1 instructions](docs/legacy_WSL1_INSTALL.md). These repositories can be identified by the [older revision](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md) of the INSTALL.md* +> Note: If the repository you plan to build has an **[older revision of the INSTALL.md](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md)**, then follow the [legacy WSL1 instructions](docs/legacy_WSL1_INSTALL.md) from here. 4. Certain packages are required to build pokeemerald. Install these packages by running the following command: @@ -330,7 +330,7 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ## Installation -**Windows users:** Consider adding an exception for the `pokeemerald` and/or `decomps` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. +> Windows users: Consider adding an exception for the `pokeemerald` and/or `decomps` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. 1. If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: From 9ec5a5b468b1a11d53a7cf33823a3bfa213dfdbd Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Sat, 1 May 2021 21:03:40 -0400 Subject: [PATCH 41/43] Wrap notes in details blocks. --- INSTALL.md | 187 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 124 insertions(+), 63 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 36d2b9d252..e0a8c325e7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -2,17 +2,25 @@ These instructions explain how to set up the tools required to build **pokeemerald**, which assembles the source files into a ROM. +These instructions come with notes which can be expanded by clicking the "Note..." text. +In general, you should not need to open these unless if you get an error or if you need additional clarification. + If you run into trouble, ask for help on Discord or IRC (see [README.md](README.md)). ## Windows -Windows has instructions for building with three possible terminals, providing 3 different options in case the user stumbled upon unexpected errors. +Windows has instructions for building with three possible terminals, providing 3 different options in case the user stumbles upon unexpected errors. - [Windows 10 (WSL1)](#windows-10-wsl1) (**Fastest, highly recommended**, Windows 10 only) - [Windows (msys2)](#windows-msys2) (Second fastest) - [Windows (Cygwin)](#windows-cygwin) (Slowest) Unscientific benchmarks suggest **msys2 is 2x slower** than WSL1, and **Cygwin is 5-6x slower** than WSL1. +
+ Note for advanced users: WSL2... -> Note for advanced users: **WSL2** is an option and is even faster than **WSL1** if files are stored on the WSL2 file system, but some tools may have trouble interacting with the WSL2 file system over the network drive. For example, tools which use Qt versions before 5.15.2 such as [porymap](https://github.com/huderlem/porymap) may [have problems with parsing the `\\wsl$` network drive path](https://bugreports.qt.io/browse/QTBUG-86277). +> WSL2 is an option and is even faster than WSL1 if files are stored on the WSL2 file system, but some tools may have trouble interacting +> with the WSL2 file system over the network drive. For example, tools which use Qt versions before 5.15.2 such as porymap +> may have problems with parsing the \\wsl$ network drive path. +
All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions. @@ -34,13 +42,19 @@ WSL1 is the preferred terminal to build **pokeemerald**. The following instructi 2. Once the process finishes, restart your machine. 3. The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice. - - > Note for advanced users: You can pick a preferred Linux distribution, but setup instructions may differ. Debian should work with the given instructions, but has not been tested. +
+ Note for advanced users... + + > You can pick a preferred Linux distribution, but setup instructions may differ. Debian should work with the given instructions, but has not been tested. +
4. Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution. +
+ Notes... - > Note 1: If a dialog pops up asking for you to sign into a Microsoft Account, then just close the dialog. - > Note 2: If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). + > Note 1: If a dialog pops up asking for you to sign into a Microsoft Account, then just close the dialog. + > Note 2: If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number). +
### Setting up WSL1 Some tips before proceeding: @@ -51,15 +65,17 @@ Some tips before proceeding: 1. Open **Ubuntu** (e.g. using Search). 2. WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in). +
+ Note... - > Note: When typing in the password, there will be no visible response, but the terminal will still read in input. + > When typing in the password, there will be no visible response, but the terminal will still read in input. +
-3. Update WSL/Ubuntu before continuing. Do this by running the following command: +3. Update WSL/Ubuntu before continuing. Do this by running the following command. These commands will likely take a long time to finish: ```bash sudo apt update && sudo apt upgrade ``` - > Note: These commands will likely take a long time to finish. > Note: If the repository you plan to build has an **[older revision of the INSTALL.md](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md)**, then follow the [legacy WSL1 instructions](docs/legacy_WSL1_INSTALL.md) from here. @@ -68,25 +84,29 @@ Some tips before proceeding: ```bash sudo apt install build-essential binutils-arm-none-eabi git libpng-dev ``` - > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`. +
+ Note... + + > If the above command does not work, try the above command but replacing `apt` with `apt-get`. +
### Choosing where to store pokeemerald (WSL1) -WSL has its own file system that's not natively accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to install pokeemerald within Windows. +WSL has its own file system that's not natively accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to store pokeemerald within Windows. + +For example, say you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**. First, ensure that the folder already exists. Then, enter this command to **change directory** to said folder, where *\* is your **Windows** username: -For example, say you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**. If pokeemerald and/or agbcc hasn't been installed yet, then enter the following command, where *\* is your **Windows** username: ```bash cd /mnt/c/Users//Desktop/decomps ``` -Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. -> Note 1: The Windows C:\ drive is called /mnt/c/ in WSL. -> Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Desktop/decomp folder"`. -> Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed -> Note 4: If pokeemerald is already installed, then run the following command instead (for the provided example path): -> ```bash -> cd /mnt/c/Users//Desktop/decomps/pokeemerald -> ``` +
+ Notes... +> Note 1: The Windows C:\ drive is called /mnt/c/ in WSL. +> Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users//Desktop/decomp folder"`. +> Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed +
+ If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or continue reading below for [Windows instructions using msys2](#windows-msys2). @@ -112,20 +132,28 @@ Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert. ```bash pacman -S make gcc zlib-devel git ``` - > Note: This command will ask for confirmation, just enter the yes action when prompted. +
+ Note... + + > This command will ask for confirmation, just enter the yes action when prompted. +
3. Download [libpng](https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.xz/download). -4. Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at **C:\Users\\_\_**, where *\* is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: +4. Change directory to where libpng was downloaded. By default, msys2 will start in the current user's profile folder, located at **C:\Users\\⁠_\_**, where *\* is your Windows username. In most cases, libpng should be saved within a subfolder of the profile folder. For example, if libpng was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command: ```bash cd Downloads ``` - > Note 1: While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator. - > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`. - > Note 3: Windows path names are case-insensitive so adhering to capitalization isn’t needed. - > Note 4: If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there. +
+ Notes... + + > Note 1: While not shown, msys uses forward slashes `/` instead of backwards slashes `\` as the directory separator. + > Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Downloads/My Downloads"`. + > Note 3: Windows path names are case-insensitive so adhering to capitalization isn’t needed. + > Note 4: If libpng was saved elsewhere, you will need to specify the full path to where libpng was downloaded, e.g. `cd c:/devkitpro/msys2` if it was saved there. +
5. Run the following commands to uncompress and install libpng. @@ -146,19 +174,12 @@ Note that in msys2, Copy is Ctrl+Insert and Paste is Shift+Insert. ### Choosing where to store pokeemerald (msys2) At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user profile folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder. -For example, say you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps**. If pokeemerald and/or agbcc hasn't been installed yet, then enter the following command to **change directory** to the desired folder: +For example, if you want to store pokeemerald (and agbcc) in **C:\Users\\_\_\Desktop\decomps** (where *\* is your **Windows** username), enter this command: ```bash cd Desktop/decomps ``` -Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. - -> Note: If pokeemerald is already installed, then run the following command instead (for the provided example path): -> ```bash -> cd Desktop/decomps/pokeemerald -> ``` - If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)), or continue reading below for [Windows instructions using Cygwin](#windows-cygwin). @@ -206,7 +227,11 @@ Note that in Cygwin, Copy is Ctrl+Insert and Paste is Shift+Insert. echo export DEVKITARM=$DEVKITARM >> ~/.bashrc ``` - > Note: Replace the drive letter c with the actual drive letter if it is not c. +
+ Note... + + > Replace the drive letter c with the actual drive letter if it is not c. +
### Choosing where to store pokeemerald (Cygwin) @@ -218,17 +243,17 @@ cd c:/Users//Desktop/decomps ``` Note that the directory **must exist** in Windows. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Windows Explorer) before executing the `cd` command. -> Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. -> Note 2: Windows path names are case-insensitive so adhering to capitalization isn't needed -> Note 3: If pokeemerald is already installed, then run the following command instead (for the provided example path): -> ```bash -> cd c:/Users//Desktop/decomps/pokeemerald -> ``` +
+ Notes... +> Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "c:/users//Desktop/decomp folder"`. +> Note 2: Windows path names are case-insensitive so adhering to capitalization isn't needed +
+ If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)). ## macOS -1. If the Xcode Command Line Tools are not installed, download the tools [here](https://developer.apple.com/library/archive/technotes/tn2339/_index.html), open your Terminal, and run the following command: +1. If the Xcode Command Line Tools are not installed, download the tools [here](https://developer.apple.com/xcode/resources/), open your Terminal, and run the following command: ```bash xcode-select --install @@ -239,7 +264,11 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for - Otherwise, **open the Terminal** and go to [Choosing where to store pokeemerald (macOS)](#choosing-where-to-store-pokeemerald-macos) ### Installing libpng (macOS) -> Note for advanced users: This guide installs libpng via Homebrew as it is the easiest method, however advanced users can install libpng through other means if they so desire. +
+ Note for advanced users... + +> This guide installs libpng via Homebrew as it is the easiest method, however advanced users can install libpng through other means if they so desire. +
1. Open the Terminal. 2. If Homebrew is not installed, then install [Homebrew](https://brew.sh/) by following the instructions on the website. @@ -279,17 +308,17 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ### Choosing where to store pokeemerald (macOS) At this point, you can choose a folder to store pokeemerald into. If you're okay with storing pokeemerald in the user folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pokeemerald is stored when changing directory to the pokeemerald folder. -For example, say you want to store pokeemerald (and agbcc) in **~/Desktop/decomps**. If pokeemerald and/or agbcc hasn't been installed yet, then enter the following command to **change directory** to the desired folder: +For example, if you want to store pokeemerald (and agbcc) in **~/Desktop/decomps**, enter this command to **change directory** to the desired folder: ```bash cd Desktop/decomps ``` Note that the directory **must exist** in the folder system. If you want to store pokeemerald in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the `cd` command. -> Note 1: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"` -> Note 2: If pokeemerald is already installed, then run the following command instead (for the provided example path: -> ```bash -> cd Desktop/decomps/pokeemerald -> ``` +
+ Note... + +> Note: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"` +
If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)). @@ -302,6 +331,13 @@ Run the following command to install the necessary packages: sudo apt install build-essential binutils-arm-none-eabi git libpng-dev ``` Then proceed to [Choosing where to store pokeemerald (Linux)](#choosing-where-to-store-pokeemerald-linux). +
+ Note for legacy repos... + +> If the repository you plan to build has an **[older revision of the INSTALL.md](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md)**, +> then you will have to install devkitARM. Install all the above packages except binutils-arm-none-eabi, and follow the instructions to +> [install devkitARM on Debian/Ubuntu-based distributions](#installing-devkitarm-on-debianubuntu-based-distributions). +
### Other distributions _(Specific instructions for other distributions would be greatly appreciated!)_ @@ -330,7 +366,13 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ## Installation -> Windows users: Consider adding an exception for the `pokeemerald` and/or `decomps` folder in Windows Security using [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from scanning them which might improve performance while building. +
+ Note for Windows users... + +> Consider adding an exception for the `pokeemerald` and/or `decomps` folder in Windows Security using +> [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from +> scanning them which might improve performance while building. +
1. If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: @@ -338,16 +380,20 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for git clone https://github.com/luckytyphlosion/pokeemerald ``` - > Note for WSL1: If you get an error stating `fatal: could not set 'core.filemode' to 'false'`, then run the following commands: - >```bash - >cd - >sudo umount /mnt/c - >sudo mount -t drvfs C: /mnt/c -o metadata,noatime - >cd - >``` - > Where *\* is the path of the folder [where you chose to store pokeemerald](#Choosing-where-to-store-pokeemerald-WSL1). Then run the `git clone` command again. +
+ Note for WSL1... -2. Install agbcc into pokeemerald. The commands to run depend on certain conditions: + > If you get an error stating `fatal: could not set 'core.filemode' to 'false'`, then run the following commands: + > ```bash + > cd + > sudo umount /mnt/c + > sudo mount -t drvfs C: /mnt/c -o metadata,noatime + > cd + > ``` + > Where *\* is the path of the folder [where you chose to store pokeemerald](#Choosing-where-to-store-pokeemerald-WSL1). Then run the `git clone` command again. +
+ +2. Install agbcc into pokeemerald. The commands to run depend on certain conditions. **You should only follow one of the listed instructions**: - If agbcc has **not been built before** in the folder where you chose to store pokeemerald, run the following commands to build and install it into pokeemerald: ```bash @@ -366,14 +412,18 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for ./install.sh ../pokeemerald ``` -- **Otherwise**, run the following commands to install agbcc into pokeemerald: +- **Otherwise**, if agbcc has been built before on the same terminal, run the following commands to install agbcc into pokeemerald: ```bash cd agbcc ./install.sh ../pokeemerald ``` - > Note: If building agbcc or pokeemerald results in an error, try deleting the agbcc folder and re-installing agbcc as if it has not been built before. +
+ Note... + + > If building agbcc or pokeemerald results in an error, try deleting the agbcc folder and re-installing agbcc as if it has not been built before. +
3. Once agbcc is installed, change directory back to the base directory where pokeemerald and agbcc are stored: @@ -392,7 +442,10 @@ To build **pokeemerald.gba** for the first time and confirm it matches the offic make compare ``` If an OK is returned, then the installation went smoothly. -> Note for Windows: if you switched terminals since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands. +
+Note for Windows... +> If you switched terminals since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands. +
To build **pokeemerald.gba** with your changes: ```bash @@ -438,7 +491,11 @@ Otherwise, follow the instructions below to install devkitARM. ```bash sudo apt install gdebi-core ``` - > Note: If the above command does not work, try the above command but replacing `apt` with `apt-get`. +
+ Note... + + > If the above command does not work, try the above command but replacing `apt` with `apt-get`. +
2. Once `gdebi-core` is done installing, download the devkitPro pacman package [here](https://github.com/devkitPro/pacman/releases). The file to download is `devkitpro-pacman.amd64.deb`. 3. Change directory to where the package was downloaded. For example, if the package file was saved to **C:\Users\\_\_\Downloads** (the Downloads location for most users), enter this command, where *\ is your **Windows** username: @@ -456,7 +513,11 @@ Otherwise, follow the instructions below to install devkitARM. ``` The last command will ask for the selection of packages to install. Just press Enter to install all of them, followed by entering Y to proceed with the installation. +
+ Note... + > Note: `devkitpro-pacman.amd64.deb` is the expected filename of the devkitPro package downloaded (for the first command). If the downloaded package filename differs, then use that filename instead. +
5. Run the following command to set devkitPro related environment variables (alternatively, close and re-open WSL): From c50a21fba07db80ac44c6f09fd202ba4b2e2c7d3 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Wed, 5 May 2021 16:07:21 -0400 Subject: [PATCH 42/43] Tidy just cleans both normal and modern. --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3bb5161e31..20dca6f643 100644 --- a/Makefile +++ b/Makefile @@ -215,9 +215,7 @@ mostlyclean: tidynonmodern tidymodern @$(MAKE) clean -C berry_fix @$(MAKE) clean -C libagbsyscall -tidy: - rm -f $(ROM) $(ELF) $(MAP) - rm -r $(OBJ_DIR) +tidy: tidynonmodern tidymodern tidynonmodern: rm -f $(ROM_NAME) $(ELF_NAME) $(MAP_NAME) From 8b45c8e48ac1ddce3e986fb512937cf2e57f86ec Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Thu, 27 May 2021 16:20:13 -0400 Subject: [PATCH 43/43] Fix github links to pret's. --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index e0a8c325e7..1ad3b4b0c9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -377,7 +377,7 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for 1. If pokeemerald is not already downloaded (some users may prefer to download pokeemerald via a git client like GitHub Desktop), run: ```bash - git clone https://github.com/luckytyphlosion/pokeemerald + git clone https://github.com/pret/pokeemerald ```
@@ -397,7 +397,7 @@ If this works, then proceed to [Installation](#installation). Otherwise, ask for - If agbcc has **not been built before** in the folder where you chose to store pokeemerald, run the following commands to build and install it into pokeemerald: ```bash - git clone https://github.com/luckytyphlosion/agbcc + git clone https://github.com/pret/agbcc cd agbcc ./build.sh ./install.sh ../pokeemerald