Skip to content

Commit 442f0ba

Browse files
committed
🔨 Script for gcc setup on macOS (Simulator build)
1 parent 40aab1e commit 442f0ba

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

buildroot/bin/mac_gcc

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env zsh
2+
#
3+
# Prepare a 'gcc' compatible with the native Simulator build.
4+
# Support for MacPorts and Homebrew.
5+
# To reset and use the system (Clang) compiler, run with 'apple'.
6+
#
7+
# Usage: mac_gcc apple|macports|homebrew
8+
#
9+
10+
which port >/dev/null && HAS_MACPORTS=1
11+
which brew >/dev/null && HAS_HOMEBREW=1
12+
13+
if [[ $1 == "apple" || $1 == "darwin" || $1 == "system" ]]; then
14+
15+
if ((HAS_MACPORTS)); then
16+
cd /opt/local/bin
17+
sudo rm -f gcc g++ cc ld
18+
cd -
19+
fi
20+
21+
if ((HAS_HOMEBREW)); then
22+
cd /opt/homebrew/bin
23+
sudo rm -f gcc g++ cc
24+
cd -
25+
fi
26+
27+
elif [[ $1 =~ ".*ports" ]]; then
28+
29+
((HAS_MACPORTS)) || { echo "MacPorts is not installed"; exit 1; }
30+
31+
GCCV=$( find /opt/local/bin -name "gcc-mp-*" | sort -r | head -1 | sed 's/.*gcc-mp-//' )
32+
[[ $GCCV -ge 11 ]] || GCCV=14
33+
34+
getport() { port installed $1 | grep $1 || sudo port install $1; }
35+
getports() { for p in $@; do getport $p; done; }
36+
37+
getports "gcc$GCCV" glm mesa libsdl2 libsdl2_net
38+
39+
cd /opt/local/bin
40+
sudo rm -f gcc g++ cc ld
41+
sudo ln -s "gcc-mp-$GCCV" gcc
42+
sudo ln -s "g++-mp-$GCCV" g++
43+
sudo ln -s g++ cc
44+
sudo ln -s ld-classic ld
45+
cd -
46+
47+
elif [[ $1 =~ ".*brew" ]]; then
48+
49+
((HAS_HOMEBREW)) || { echo "Homebrew is not installed"; exit 1; }
50+
51+
GCCV=$( find /opt/homebrew/bin -name "gcc-*" | sort -r | head -1 | sed 's/.*gcc-//' )
52+
[[ $GCCV -ge 11 ]] || { brew install gcc@14 ; GCCV=14 }
53+
54+
brew install glm mesa sdl2 sdl2_net
55+
56+
cd /opt/homebrew/bin
57+
sudo rm -f gcc g++ cc
58+
sudo ln -s "gcc-$GCCV" gcc
59+
sudo ln -s "g++-$GCCV" g++
60+
sudo ln -s g++ cc
61+
cd -
62+
63+
else
64+
65+
echo "Usage: $(basename $0) apple|macports|homebrew"
66+
67+
fi
68+
69+
rehash

ini/native.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags}
8181
# Simulator for macOS (MacPorts)
8282
#
8383

84+
#
85+
# Use the script buildroot/bin/mac_gcc to prepare your environment.
8486
#
8587
# MacPorts:
88+
# https://www.macports.org/install.php
89+
#
8690
# sudo port install gcc14 glm mesa libsdl2 libsdl2_net
8791
#
8892
# cd /opt/local/bin

0 commit comments

Comments
 (0)