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.

A. Obtain build toolchain that is more suitable for Apple hardware:

  • Install Xcode or CLT:
    1. Obtain Xcode1 from here. Note: installer file download is over/near 5 GB, and needs 12+ GB space.
    2. If you prefer to not obtain Xcode, then one of the alternative is:
      • obtain Command-Line-Tools1 (CLT) from here, or Load it from App Store in macOS, or use below command. CLT is also known as Command Line Developer Tools. Note: installer download is under/near 300 MB, and needs around ~ 2 GB space.
      • inside Terminal1 utility/app, run this command to load CLT:
        xcode-select --install
  • Build toolchain from apple is first used to create a software components for openwrt build purpose, then those software components are used to create final openwrt components, in order to create cross-platform compatible openwrt firmware.

B. Unhide hidden files/folders in macOS:

  • We need to view full filename, file extensions, all files & directories, etc including hidden ones, very accurately, so that there is lesser mistakes.
  • Use Finder to start Terminal in macOS:
    • Finder is very similar to Windows-Explorer file-browser app/tool. In macOS > click on any empty area in Desktop screen > in top-side menu click on Window > click on Bring All to Front > in left-pane (in left side column) of Finder, go under Favorites and click on the Applications > then scroll down & go into Utilities sub-folder > then click on Terminal or Terminal.app to start it. macOS Terminal is very similar to Windows Command-Prompt, a command-line interface (CLI) tool.
    • Hotkeys to start Finder instantly: [Alt/Option⌥] + [Command⌘] + [Space-bar] then close the Search tab.
    • Hotkeys to start Terminal instantly: none.
  • Run below command inside Terminal:
    defaults write com.apple.Finder AppleShowAllFiles true
  • then you must reboot Mac-computer OR run (any one of the) below command:
    /usr/bin/sudo /usr/bin/killall Finder /System/Library/CoreServices/Finder.app

    or, run just this:

    /usr/bin/sudo /usr/bin/killall Finder

    or, just this:

    sudo killall Finder
  • then Finder will auto start, and all hidden files+folders will by-default begin to be shown to user in macOS Finder.
  • in macOS Finder or inside any other file browsing window in macOS, user can also press below THREE buttons altogether ONCE to show all HIDDEN files/folders:
    • [Command⌘] + [Shift⇧] + [.>]
    • if user press-es above three buttons again, file-browsing-window will HIDE the HIDDEN files/folders.
  • By default in macOS, Finder will keep most of the file's extension hidden. But we need to see all file's extension, so we can be sure & not make mistake. To view all file's extension, do below steps:
    • in macOS > start “Finder” app > goto main menu > Finder > Preferences > Advanced > select the Show All Filename Extensions option.

C. Install any one of the (3rd-party) package manager (pkg-mngr) software in macOS:

  1. Homebrew : Note: it shares user's usage/private data with Ggl.

D. Prepare a dedicated case-sensitive filesystem for OpenWRT build/compile:

  • 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

E. Go into OpenWRT build volume, with this command, in Terminal's build tab:

  • cd /Volumes/OpenWrt

F. Install necessary packages with below command(s):
Packages will be installed inside macOS default volume, not inside /Volumes/OpenWrt

  • if you have homebrew then run this:
    brew install coreutils findutils gawk grep gnu-getopt gnu-tar wget diffutils git-extras quilt svn make ncurses pkg-config
    • in above homebrew does not include the pre-requisites (aka: dependencies) packages mentioned here.
  • if you have MacPorts then run this:
    sudo port install libiconv gettext-runtime coreutils findutils gwhich gawk zlib pcre bzip2 ncurses grep getopt gettext-tools-libs gettext diffutils sharutils util-linux libxslt libxml2 help2man readline gtime gnutar unzip zip lzma xz libelf fastjar libusb libftdi0 expat sqlite3 openssl3 openssl kerberos5 dbus lz4 libunistring nettle icu gnutls p11-kit wget quilt subversion gmake pkgconfig cdrtools ccache curl xxhashlib rsync libidn perl5 p5.28-xml-parser p5.30-xml-parser p5-extutils-makemaker p5-data-dumper boost-jam boost boost-build bash bash-completion binutils m4 flex intltool patchutils swig git-extras git openjdk17 luajit libtool glib2 file python27 python310 mercurial asciidoc sdcc cutter gnu-classpath
    • in above MacPorts includes the pre-requisites (aka: dependencies) packages mentioned here. Space initially used by all of these packages: 4,069,448,790 bytes (2.45 GB on disk) for 129,663 items, (as of March-10, 2022). Note: As different packages are continuously modified & improved by their devs or releaser or adopter or maintainer, so their occupying space size & items count will be different in your computer in different time.

G. Optional-step: Start a build friendly common shell inside a specific Terminal tab:
We need+should use last stable version of bash shell, as it can be obtained & used by most devs/users:

  • If you downloaded new bash package, then start new bash shell inside a specific tab in Terminal, with this command:
    exec /opt/local/bin/bash
    • above command will work, as we have already downloaded last stable bash package via (MacPorts) pkg-mngr.
    • optional: approve/permit new bash shell in macOS: echo “/opt/local/bin/bash” | sudo tee -a /private/etc/shells
    • optional: if you want to continue to use the new bash always, then: click on apple symbol in topside apple menu-bar > System Preferences... > Users & Groups > Unlock the 🔒pane > control click on your user-name > select Advanced Options... > then update/change the Login shell into /opt/local/bin/bash > ok.

H. Allow build commands to find downloaded packages:

  • Create a file called env.sh inside /Volumes/OpenWrt
    • This is to allow the utilities (aka: packages) we just installed to be used, instead of the macOS provided ones.
  • For x86_64 Apple hardware, & when you have homebrew, then create env.sh file with below content:
    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/libexec/gnubin:$PATH"
    PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
    export PATH
  • For x86_64 Apple hardware, & when you have MacPorts, then create env.sh file with below content:
    PATH="/opt/local/libexec/gnubin:$PATH"
    PATH="/opt/local/bin:$PATH"
    PATH="/opt/local/sbin:$PATH"
    PATH="/opt/local/x86_64-apple-darwin19.6.0/bin:$PATH"
    export PATH
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk17-temurin/Contents/Home
  • For arm64 (Apple Silicon(M1)) Apple hardware, & when you have homebrew, then create env.sh file with below content:
    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
  • Optional: you may check homebrew official page or MacPorts-guide if you need more information related to PATH variable.
  • Allow build commands to find packages we installed via pkg-mngr by creating shell environment:
    • When developing, run below command to set up the path (and other) variable(s). This leaves your system in a clean state without symlinking.
      source /Volumes/OpenWrt/env.sh

I. Now proceed normally.

Golang1: 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

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2022/03/11 10:50
  • by aterik