Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Building on OS X

leitec edited this page Dec 15, 2014 · 14 revisions

Building on OS X requires installing several packages via MacPorts (or Homebrew, see below), and creating a disk image to contain the source tree. The latter is required due to the fact that the default OS X filesystem is not case-sensitive.

These instructions are based on http://www.doodle3d.com/help/building-open-wrt-os-x and http://www.acme-dot.com/building-openwrt-14-07-barrier-breaker-on-ubuntu-and-os-x/ and were tested on Mountain Lion and Yosemite.

Step zero, if you will, is installing XCode and its command-line tools (xcode-select --install, apparently), if you haven't yet. Then, install MacPorts. It seems also that some configure scripts call the Java compiler, which results in a few popups during the build if you do not have the JDK installed. It doesn't seem to affect anything, though.

Step one is to create and mount the disk image:

$ hdiutil create -size 20g -fs "Case-sensitive HFS+" -volname OpenWrt ~/OpenWrt.sparsebundle
$ open ~/OpenWrt.sparsebundle

Then, install the required packages via MacPorts:

$ sudo port install coreutils e2fsprogs ossp-uuid asciidoc bzip2 fastjar flex getopt gtk2 intltool jikes zlib openssl p5-extutils-makemaker python26 rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses findutils

This may take a while. When done, you can clone the Git repository:

$ cd /Volumes/OpenWrt
$ git clone git://github.com/leitec/openwrt-leitec leitec
$ cd leitec

and proceed as with any other OpenWrt build:

$ make menuconfig
$ make -j2

Change -j2 to -j4 or whatever matches how many cores your machine has. The initial build will take a long time due to building gcc and the like. Subsequent builds (say, if you change configuration) will be much faster.

Using Homebrew instead of MacPorts

I was able to build on Mountain Lion and Yosemite using the following packages:

brew install coreutils e2fsprogs gnu-getopt gawk wget findutils xz gnu-tar

Unlike with MacPorts, the gnu-getopt package doesn't install itself as just getopt, so you will have to make a link yourself. From the OpenWrt root, you can do:

$ mkdir -p staging_dir/host/bin
$ ln -s /usr/local/opt/gnu-getopt/bin/getopt staging_dir/host/bin/getopt

Note you will have to repeat this if you ever run make dirclean or another operation that empties staging_dir/host.

From here on, the standard instructions apply.