MacOS Building Support (#59)

* Fixed MacOS compilation

* Updated spimdisasm requirement to use latest develop

* Updated README

* Fixed python requirements

* Readded --gc-sections on mio0

* Added a conditional flag for gc-sections

* Fixed indentation errors
This commit is contained in:
Lywx 2023-12-26 14:55:57 -06:00 committed by GitHub
parent 510071802a
commit d7d9e472c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 10 deletions

View File

@ -5,6 +5,9 @@
MAKEFLAGS += --no-builtin-rules --no-print-directory
# Returns the path to the command $(1) if exists. Otherwise returns an empty string.
find-command = $(shell which $(1) 2>/dev/null)
#### Defaults ####
# If COMPARE is 1, check the output md5sum after building
@ -30,8 +33,16 @@ VERBOSE ?= 0
PRINT ?= printf
# Set prefix to mips binutils binaries (mips-linux-gnu-ld => 'mips-linux-gnu-') - Change at your own risk!
# In nearly all cases, not having 'mips-linux-gnu-*' binaries on the PATH is indicative of missing dependencies
MIPS_BINUTILS_PREFIX ?= mips-linux-gnu-
# Auto-detect prefix for MIPS toolchain
ifneq ($(call find-command,mips-linux-gnu-ld),)
MIPS_BINUTILS_PREFIX := mips-linux-gnu-
else ifneq ($(call find-command,mips64-linux-gnu-ld),)
MIPS_BINUTILS_PREFIX := mips64-linux-gnu-
else ifneq ($(call find-command,mips64-elf-ld),)
MIPS_BINUTILS_PREFIX := mips64-elf-
else
$(error Unable to detect a suitable MIPS toolchain installed)
endif
VERSION ?= us
@ -81,7 +92,7 @@ else ifeq ($(UNAME_S),Linux)
CC_CHECK_COMP := arm-linux-gnueabihf-gcc
endif
else ifeq ($(UNAME_S),Darwin)
DETECTED_OS := mac
DETECTED_OS := macos
MAKE := gmake
CPPFLAGS += -xc++
endif
@ -123,11 +134,19 @@ AS := $(MIPS_BINUTILS_PREFIX)as
LD := $(MIPS_BINUTILS_PREFIX)ld
OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy
OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump
CPP := cpp
ICONV := iconv
ASM_PROC := $(PYTHON) $(TOOLS)/asm-processor/build.py
CAT := cat
# Prefer clang as C preprocessor if installed on the system
ifneq (,$(call find-command,clang))
CPP := clang
CPPFLAGS := -E -P -x c -Wno-trigraphs -D_LANGUAGE_ASSEMBLY
else
CPP := cpp
CPPFLAGS := -P -Wno-trigraphs -D_LANGUAGE_ASSEMBLY
endif
ASM_PROC_FLAGS := --input-enc=utf-8 --output-enc=euc-jp --convert-statics=global-with-filename
SPLAT ?= $(PYTHON) $(TOOLS)/splat/split.py

View File

@ -37,6 +37,15 @@ sudo apt update
sudo apt install make git build-essential binutils-mips-linux-gnu python3 python3-pip clang-format-14 clang-tidy
```
### MacOS
#### 1. Install build dependencies
Install [Homebrew](https://brew.sh) and the following dependencies:
```
brew update
brew install coreutils make pkg-config tehzz/n64-dev/mips64-elf-binutils
```
#### 2. Clone the repository
Create your own fork of the repository at `https://github.com/sonicdcer/sf64`. Then clone your fork where you wish to have the project, with the command:

View File

@ -2,11 +2,13 @@ CC = gcc
UNAME_S := $(shell uname -s)
ifeq ($(OS),Windows_NT)
$(error Native Windows is currently unsupported for building this repository, use WSL instead c:)
$(error Native Windows is currently unsupported for building this repository, use WSL instead c:)
else ifeq ($(UNAME_S),Linux)
DETECTED_OS := linux
MIO0_FLAGS := --gc-sections
else ifeq ($(UNAME_S),Darwin)
DETECTED_OS := mac
DETECTED_OS := macos
MIO0_FLAGS :=
endif
RECOMP_DIR := ido-recomp/$(DETECTED_OS)
@ -30,6 +32,6 @@ recomp:
mio0:
@echo "Building mio0..."
$(CC) -Wall -Wextra -Wno-format-overflow -O2 -ffunction-sections -fdata-sections -DMIO0_STANDALONE -s -Wl,--gc-sections -o mio0 mio0-decompressor/libmio0.c
$(CC) -Wall -Wextra -Wno-format-overflow -O2 -ffunction-sections -fdata-sections -DMIO0_STANDALONE -s -Wl,${MIO0_FLAGS} -o mio0 mio0-decompressor/libmio0.c
.PHONY: all clean distclean default

View File

@ -1,4 +1,4 @@
spimdisasm==1.17.0
spimdisasm==1.20.0
rabbitizer==1.7.0
PyYAML
pylibyaml