From aca9ea7ac6cfb076a1bbdbb375f6faf67bc6be70 Mon Sep 17 00:00:00 2001 From: CrepeGoat Date: Sat, 2 Sep 2023 02:55:06 -0600 Subject: [PATCH 1/6] fix readme formatting --- README.md | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index e708a8b8a8..6908bb6681 100644 --- a/README.md +++ b/README.md @@ -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..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..z64` for asset extraction. @@ -122,31 +128,33 @@ 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 ``` From a66c44c5a0d6cb38590b909ee37f937fd66daf41 Mon Sep 17 00:00:00 2001 From: CrepeGoat Date: Sun, 8 Oct 2023 23:47:58 -0600 Subject: [PATCH 2/6] made nix-shell for manually creating ROM on aarch64-darwin Working commands: - `gmake VERSION=us` - `gmake VERSION=us COMPILER=gcc` TODOS - remove dirty change: `ar` should not be directly referenced -> move current `$(AR)` to `$(AR_CROSS)` and leave `$(AR)` intact? - add support for arbitrary build platforms (e.g., `*-linux`) - (?) add support for other host platforms (e.g., `mips[64]-*`) --- Makefile | 10 ++++++++++ shell.nix | 26 ++++++++++++++++++++++++++ tools/audiofile/Makefile | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 shell.nix diff --git a/Makefile b/Makefile index b267233e4d..56e86bc5fa 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000..9871237c63 --- /dev/null +++ b/shell.nix @@ -0,0 +1,26 @@ +{ pkgs ? import { + # https://nixos.org/manual/nixpkgs/stable/#sec-cross-usage + localSystem = (import ).systems.examples.x86_64-darwin; + crossSystem = (import ).systems.examples.mips-linux-gnu; + } +}: + +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 + ''; + }) +{ } diff --git a/tools/audiofile/Makefile b/tools/audiofile/Makefile index ae7d1e0215..97c45d6f01 100644 --- a/tools/audiofile/Makefile +++ b/tools/audiofile/Makefile @@ -1,7 +1,7 @@ CXX := g++ libaudiofile.a: audiofile.o - $(AR) rcs $@ $^ + ar rcs $@ $^ audiofile.o: audiofile.cpp audiofile.h aupvlist.h $(CXX) -std=c++11 -O2 -I. -c $< -o $@ From 64e0928b2bdc24cfaf13497f3b53fd6e49697009 Mon Sep 17 00:00:00 2001 From: CrepeGoat Date: Tue, 24 Oct 2023 20:33:01 -0600 Subject: [PATCH 3/6] turns out, this compiles fine on aarm64-darwin! --- shell.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/shell.nix b/shell.nix index 9871237c63..0c53b8c6fc 100644 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,5 @@ { pkgs ? import { # https://nixos.org/manual/nixpkgs/stable/#sec-cross-usage - localSystem = (import ).systems.examples.x86_64-darwin; crossSystem = (import ).systems.examples.mips-linux-gnu; } }: From 0431147fdda2cd1fc6aeacd90d646d0859ccb909 Mon Sep 17 00:00:00 2001 From: CrepeGoat Date: Tue, 24 Oct 2023 21:06:19 -0600 Subject: [PATCH 4/6] restricted valid host platforms to MIPS systems --- shell.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell.nix b/shell.nix index 0c53b8c6fc..6d937fe873 100644 --- a/shell.nix +++ b/shell.nix @@ -4,6 +4,12 @@ } }: +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 From 8b14062b47cc020fe1b286281dc6635b1abca68e Mon Sep 17 00:00:00 2001 From: CrepeGoat Date: Tue, 24 Oct 2023 22:28:46 -0600 Subject: [PATCH 5/6] changed tools/Makefile to also set `AR` to the system default --- tools/Makefile | 1 + tools/audiofile/Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/Makefile b/tools/Makefile index f3f9496fe9..e91c08d4ef 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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 diff --git a/tools/audiofile/Makefile b/tools/audiofile/Makefile index 97c45d6f01..ae7d1e0215 100644 --- a/tools/audiofile/Makefile +++ b/tools/audiofile/Makefile @@ -1,7 +1,7 @@ CXX := g++ libaudiofile.a: audiofile.o - ar rcs $@ $^ + $(AR) rcs $@ $^ audiofile.o: audiofile.cpp audiofile.h aupvlist.h $(CXX) -std=c++11 -O2 -I. -c $< -o $@ From 84deb53ff62a797183b81e2bd2d8507ec3e50aeb Mon Sep 17 00:00:00 2001 From: CrepeGoat Date: Tue, 24 Oct 2023 23:08:52 -0600 Subject: [PATCH 6/6] added nix-based build instructions to README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6908bb6681..1ea25df523 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,10 @@ docker run --rm --mount type=bind,source="$(pwd)",destination=/sm64 --user $UID: 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