Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix install #89

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 31 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
```
Expand All @@ -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.
Expand All @@ -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
Expand Down
31 changes: 31 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -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
'';
})
{ }
1 change: 1 addition & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down