This is an old revision of the document!
Build system setup macOS
This method is NOT OFFICIALLY supported. A native GNU/Linux environment is recommended.
Tested with macOS 10.15.7, Xcode 12.1 build 12A7403.
Tested with macOS 11.6, Xcode 13.0 build 13A233, arm64 kernel.
Install brew and Xcode.
We will be using a sparsebundle to allow us to have a case sensitive filesystem.
The size that you provide will be the max size of the volume for working with OpenWrt
hdiutil create -size 20g -type SPARSE -fs "Case-sensitive HFS+" -volname OpenWrt OpenWrt.sparseimage hdiutil attach OpenWrt.sparseimage
Change to the OpenWrt volume and create the necessary directories
cd /Volumes/OpenWrt
Install the necessary packages with brew
brew install coreutils findutils gawk grep gnu-getopt gnu-tar wget diffutils git-extras quilt make ncurses pkg-config
Create a file called env.sh in /Volumes/OpenWrt
This is to allow the utilities we just installed to be used instead of the macOS provided ones.
For x86_64 Apple hardware:
PATH="/usr/local/opt/make/libexec/gnubin:$PATH" PATH="/usr/local/opt/gnu-getopt/bin:$PATH" PATH="/usr/local/opt/gettext/bin:$PATH" PATH="/usr/local/opt/coreutils/bin:$PATH" PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH" export PATH
For arm64 (Apple Silicon(M1)) Apple hardware:
PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH" PATH="/opt/homebrew/opt/gnu-getopt/bin:$PATH" PATH="/opt/homebrew/opt/gettext/bin:$PATH" PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH" export PATH
Check homebrew offical page if you need more information related to PATH variable
When developing do source /Volumes/OpenWrt/env.sh to set up the path variable. This leaves your system in a clean state without symlinking.
Now proceed normally.
Golang related
For darwin/arm64 and linux/aarch64 golang package (feed “packages”) golang C-bootstrap method doesn't work, but it is possible to use external golang bootstrap. On MacOS arm64 the easiest way is to install golang using brew and use installed golang as bootstrap:
brew install golang
Then set CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT=“/opt/homebrew/opt/go/libexec” in .config file