This commit is contained in:
Becker A 2023-10-24 23:23:38 -06:00 committed by GitHub
commit 59bcf8e2be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 19 deletions

View File

@ -309,10 +309,20 @@ IQUE_LD_PATH := $(TOOLS_DIR)/ique_ld
# detect prefix for MIPS toolchain
ifneq ($(call find-command,mips-linux-gnu-ld),)
CROSS := mips-linux-gnu-
else ifneq ($(call find-command,mips-unknown-linux-gnu-ld),)
CROSS := mips-unknown-linux-gnu-
else ifneq ($(call find-command,mips64-linux-gnu-ld),)
CROSS := mips64-linux-gnu-
else ifneq ($(call find-command,mips64-unknown-linux-gnu-ld),)
CROSS := mips64-unknown-linux-gnu-
else ifneq ($(call find-command,mips-elf-ld),)
CROSS := mips-elf-
else ifneq ($(call find-command,mips-none-elf-ld),)
CROSS := mips-none-elf-
else ifneq ($(call find-command,mips64-elf-ld),)
CROSS := mips64-elf-
else ifneq ($(call find-command,mips64-none-elf-ld),)
CROSS := mips64-none-elf-
else
$(error Unable to detect a suitable MIPS toolchain installed)
endif

View File

@ -44,23 +44,27 @@ There are 3 steps to set up a working build.
#### Step 1: Install dependencies
The build system has the following package requirements:
* binutils-mips
* pkgconf
* python3 >= 3.6
* binutils-mips
* pkgconf
* python3 >= 3.6
Dependency installation instructions for common Linux distros are provided below:
##### Debian / Ubuntu
To install build dependencies:
```
```bash
sudo apt install -y binutils-mips-linux-gnu build-essential git pkgconf python3
```
##### Arch Linux
To install build dependencies:
```
```bash
sudo pacman -S base-devel python
```
Install the following AUR packages:
* [mips64-elf-binutils](https://aur.archlinux.org/packages/mips64-elf-binutils) (AUR)
@ -81,11 +85,12 @@ You may also use [Docker](#docker-installation) to handle installing an image wi
For each version (jp/us/eu/sh/cn) for which you want to build a ROM, put an existing ROM at
`./baserom.<VERSION>.z64` for asset extraction.
##### Step 3: Build the ROM
#### Step 3: Build the ROM
Run `make` to build the ROM (defaults to `VERSION=us`).
Other examples:
```
```bash
make VERSION=jp -j4 # build (J) version instead with 4 jobs
make VERSION=eu COMPARE=0 # build (EU) version but do not compare ROM hashes
```
@ -106,14 +111,15 @@ With macOS, you may either use Homebrew or [Docker](#docker-installation).
#### Homebrew
#### Step 1: Install dependencies
##### Step 1: Install dependencies
Install [Homebrew](https://brew.sh) and the following dependencies:
```
```bash
brew update
brew install coreutils make pkg-config tehzz/n64-dev/mips64-elf-binutils
```
#### Step 2: Copy baserom(s) for asset extraction
##### Step 2: Copy baserom(s) for asset extraction
For each version (jp/us/eu/sh/cn) for which you want to build a ROM, put an existing ROM at
`./baserom.<VERSION>.z64` for asset extraction.
@ -122,36 +128,42 @@ For each version (jp/us/eu/sh/cn) for which you want to build a ROM, put an exis
Use Homebrew's GNU make because the version included with macOS is too old.
```
```bash
gmake VERSION=jp -j4 # build (J) version instead with 4 jobs
```
### Docker Installation
#### Docker Installation
#### Create Docker image
##### Create Docker image
After installing and starting Docker, create the docker image. This only needs to be done once.
```
```bash
docker build -t sm64 .
```
#### Build
##### Build
To build, mount the local filesystem into the Docker container and build the ROM with `docker run sm64 make`.
##### macOS example for (U):
```
###### macOS example for (U):
```bash
docker run --rm --mount type=bind,source="$(pwd)",destination=/sm64 sm64 make VERSION=us -j4
```
##### Linux example for (U):
###### Linux example for (U):
For a Linux host, Docker needs to be instructed which user should own the output files:
```
```bash
docker run --rm --mount type=bind,source="$(pwd)",destination=/sm64 --user $UID:$GID sm64 make VERSION=us -j4
```
Resulting artifacts can be found in the `build` directory.
#### Nix Shell Environment
Those using the Nix package manager can run `nix-shell` to load an environment that provides the required dependencies.
## Project Structure
sm64

31
shell.nix Normal file
View File

@ -0,0 +1,31 @@
{ pkgs ? import <nixpkgs> {
# https://nixos.org/manual/nixpkgs/stable/#sec-cross-usage
crossSystem = (import <nixpkgs/lib>).systems.examples.mips-linux-gnu;
}
}:
let
hostPlatformCheck =
with pkgs.stdenv.hostPlatform;
if isMips then null
else abort "cross platform target must be a MIPS target";
in
pkgs.callPackage
({ mkShell
, gnumake42
}: mkShell {
# pulled from https://github.com/n64decomp/sm64#step-1-install-dependencies-1
depsBuildBuild = [
gnumake42 # v4.4 breaks the build!
];
strictDeps = true;
shellHook = ''
NEW_PATH_DIR=$(mktemp -d)
export PATH="$NEW_PATH_DIR:$PATH"
MAKE_PATH=$(which make)
ln -s $MAKE_PATH $NEW_PATH_DIR/gmake
'';
})
{ }

View File

@ -5,6 +5,7 @@ HOST_ENV := $(patsubst MINGW%,MinGW,$(HOST_ENV))
CC := gcc
CXX := g++
AR := ar
CFLAGS := -I . -I sm64tools -Wall -Wextra -Wno-unused-parameter -pedantic -O2 -s
LDFLAGS := -lm
ALL_PROGRAMS := armips textconv patch_elf_32bit aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv