Setup MacOSX as an OpenWrt build environment

Procedure on Debian Procedure on ~BSD Procedure on Mac OS

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

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.

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 python26 \
    subversion rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses findutils

Congratulation! You're all set :)

Now you can go to Easy Build and follow the instructions by skipping the dependencies steps.

Back to top · Last modified: 2013/07/14 09:17 by lorema