User Tools

Site Tools

Setup MacOSX as an OpenWrt build environment

:!: Please MERGE this page and macosx.lion into this page: buildroot.exigence.macosx. Also consult the OpenWrt Forum: Build OpenWrt on Mac OS X 10.7 Lion

This guide will show you how to build an OpenWrt firmware on MacOSX. It was tested on Mountain Lion 10.8.3; however, it should be easily portable on other versions as well.

There are multiple challenges in building OpenWrt on MacOSX.

  • OpenWrt requires a case-sensitive filesystem whereas the filesystem provided by default on a fresh MacOSX installation is case-insensitive.
  • A bunch of development packages are missing from the system that would usually be available in a regular Linux distribution.

There are multiple ways to fix this, but for the sake of this wiki we will show how to do that using a disk image (to avoid repartitioning the hard drive) and MacPorts.

All the commands below have to be run in a terminal. You can use either the terminal available in MacOSX by default (available in “Application” –> “Utilities” –> “Terminal”) or a third party terminal. I would personally recommend the following third party terminal (called iTerm2), that provides features most Gnome users are probably used to and that the MacOSX default terminal is lacking: At the end of the installation, this terminal will be available in “Application” –> “Utilities” –> “iTerm”.

Disk image creation

Ok, so let's start by creating a disk image where we will perform all our OpenWrt development. For that, we will use the native MacOSX command “hdiutil” to create a new disk image and attach it to the system.

hdiutil create -size 20g -fs "Case-sensitive HFS+" -volname OpenWrt OpenWrt.dmg
hdiutil attach OpenWrt.dmg

These commands will create a 20GB image in your current directory, and attach it with the volume name “OpenWrt”. After executing them, you should see a new “OpenWrt” volume available in the left pane of your “Finder”. It should be empty.

Let's move into this new image so we're prepared for the next steps:

 cd /Volumes/OpenWrt

Packages installation

Next step will be to install all the packages necessary to build an OpenWrt firmware on your system. We can see two types of packages here:

  • The XCode framework - that's the Apple development SDK. It contains the core compilers and libraries.
  • The MacPorts framework - it's a package manager (similar to apt-get on Debian/Ubuntu) used to download and install open source components on your system. We can see it as a project created to fill the gap between what gets installed by Xcode and what would be available on LInux based development framework. More information on MacPorts can be found here:

XCode installation

Xcode installation is pretty straightforward:

  • Open the “App Store”
  • Search for “Xcode” in the top right corner search box
  • Select “Xcode” and “Install”
  • Enter your Apple login information if you're prompted; that should start the download and installation process
  • Make sure the command line utilities are installed:
Blah-MacBook:OpenWrt Blah$ xcode-select --install 

MacPort installation

The MacPorts packages are available on their official download website:

Here, select the latest MacPorts release available for your system and download the corresponding *.pkg file.

After download, go to your finder, and execute the file. Follow the on-screen procedure until completion.

Once you're done, go back to your terminal and let's use it in order to install the packages required to build an OpenWrt firmware. If MacPorts have been correctly installed, the “port” command should now be available.

First, update to the latest MacPorts Portfiles:

Blah-MacBook:OpenWrt Blah$ sudo port selfupdate

Then install the packages:

Blah-MacBook:OpenWrt Blah$ sudo port install coreutils e2fsprogs ossp-uuid asciidoc binutils \
    bzip2 fastjar flex getopt gtk2 intltool jikes hs-zlib openssl p5-extutils-makemaker python27 \
    subversion rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses findutils \
    grep gnutar

Congratulation! You're all set :)

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
docs/guide-developer/ · Last modified: 2019/08/05 10:37 by jefferyto