OpenWrt Buildroot – Installation
OpenWrt Buildroot is the preferred toolchain to build OpenWrt. It is recommended that you use a GNU/Linux Distribution (Debian is recommended), either a standalone installation or one running in a virtual environment (VMware or Qemu).
- Suse 12.3 uses the rpm package manager. Please note that Suse 12.3 may work to compile, but has not been tested by OpenWRT Community
Cygwin will probably not work correctly, and while it is possible to build OpenWrt images on a ~BSD or on MacOS X system, success is not guaranteed. Feel free to try and then report back with your results. Don't forget to read Troubleshooting. Build OpenWrt on Mac OS X 10.7 Lion
Prerequisites
- 350 MB of hard disk space for the source files to be downloaded.
- 3-4 GB of available hard disk space to build (i.e. cross-compile) OpenWrt.
Procedure
| 1. Do everything as non-root user! 2. Issue all OpenWrt Buildroot commands in the <buildsystem root> directory, e.g. ~/openwrt/trunk/3. Do not build in a directory that has spaces in its full path |
- Install
subversion(short:svn), to conveniently download the OpenWrt source code, andbuild toolsto do the cross-compilation process:sudo apt-get update sudo apt-get install subversion build-essential
Some feeds (e.g. LuCI, openwrt-routing and telephony) are not available over svn but only viagit. If you want to obtain their source-code, you need to install git as well. In Debian do:sudo apt-get install git-core
- for information about the subversion tool see
svnand subversion documentation (multiple languages) - for information about the build tools see
makeand build-essential - for information about git see
git(7)
- Download the OpenWrt sources with
svn.mkdir ~/openwrt cd ~/openwrt svn co svn://svn.openwrt.org/openwrt/trunk/ cd trunk
- this creates a directory 'trunk', which is the main OpenWrt source code dir
- for trunk rev R27988, it contains 14,382 files with an overall size of 150 MiB
- OpenWrt Buildroot is included
- for more information about Downloading Sources.
- Download and install feeds using feeds script. (optional)
./scripts/feeds update -a ./scripts/feeds install -a
- after this, Revision 7367, the
trunk-dir contained 26,650 files with an overall size of 302 MiB (to install only individual packages:./scripts/feeds install PACKAGENAME)
- Use one of the following commands to check for missing packages on the system you want to build OpenWrt on:
make defconfig make prereq make menuconfig
- this will list missing system packages needed to successfully build OpenWrt using OpenWrt Buildroot.
- Install the missing packages. On a fresh Debian 7 Wheezy 32/64Bit these are:
libncurses5-dev zlib1g-dev gawk
- Proceed with build (i.e. cross-compile the downloaded sources to binaries)
After the cross-compilation process (as described here), the trunk-directory contained 244,451 files with a total size of 3.2GiB!
Table of known prerequisites and their corresponding packages
Here's a table with the package name for each prerequisite separated for different Linux distributions.
| Prerequisite | Debian | Suse | Red Hat | OS X (via MacPorts) | Fedora | NetBSD |
|---|---|---|---|---|---|---|
| asciidoc | asciidoc | asciidoc | asciidoc | asciidoc | asciidoc | ? |
| bash | bash | bash | ? | bash | bash | bash |
| binutils | binutils | binutils | binutils | binutils | binutils | ? |
| bzip2 | bzip2 | bzip2 | bzip2 | bzip2 | bzip2 | ? |
| fastjar | fastjar | fastjar | libgcj | fastjar | libgcj | ? |
| flex | flex | flex | ? | flex | flex | ? |
| git | git-core | git-core | ? | ? | git | ? |
| g++ | g++ | gcc-c++ | gcc-c++ | ? | gcc-c++ | ? |
| gcc | gcc | gcc | gcc | ? | gcc | ? |
| getopt | util-linux | util-linux | ? | getopt | util-linux | getopt |
| GNU awk | gawk | gawk | gawk | gawk | gawk | ? |
| gtk2.0-dev | libgtk2.0-dev | ? | gtk2-devel | gtk2 | gtk2-devel | ? |
| intltool-update | intltool | intltool | intltool | intltool | intltool | ? |
| jikes | — | jikes | ? | jikes | — | ? |
| libz, libz-dev | zlib1g-dev | zlib-devel | zlib-devel | zlib | zlib-devel | ? |
| make | make | make | ? | gmake | make | gmake |
| ncurses | libncurses5-dev | ncurses-devel | ncurses-devel | ncurses | ncurses-devel | ? |
| openssl/ssl.h | libssl-dev | libopenssl-devel | openssl-devel | openssl | openssl-devel | ? |
| patch | patch | patch | ? | patchutils | patch | ? |
| perl-ExtUtils-MakeMaker | perl-modules | perl-ExtUtils-MakeMaker | perl-ExtUtils-MakeMaker | p5-extutils-makemaker | perl-ExtUtils-MakeMaker | ? |
| python2.6-dev | python2.6-dev | python-devel | ? | python26 | python-devel | ? |
| rsync | rsync | rsync | ? | rsync | rsync | ? |
| ruby | ruby | ruby | ? | ruby | ruby | ? |
| sdcc | sdcc | sdcc | sdcc | sdcc | sdcc | ? |
| unzip | unzip | unzip | ? | unzip | unzip | ? |
| wget | wget | wget | wget | wget | wget | ? |
| working-sdcc | — | ? | ? | ? | — | ? |
| xgettext | gettext | ? | ? | gettext | gettext | ? |
| xsltproc | xsltproc | libxslt | ? | libxslt | libxslt | ? |
| zlib, zlib-static | zlib1g-dev | zlib-devel | ? | ? | zlib-devel | ? |
Unfortunately not all dependencies are checked by make config:
| Package | Prerequisite | Debian | Suse | Red Hat | OS X | Fedora | NetBSD |
|---|---|---|---|---|---|---|---|
| intltool | [Perl] XML::Parser | libxml-parser-perl | ? | perl-XML-Parser | ? | perl-XML-Parser | ? |
Examples of Package Installations
Debian 5 Lenny:
apt-get install gawk ncurses-dev unzip zlib1g-dev
Debian 6 Squeeze:
apt-get install libncurses5-dev zlib1g-dev gawk flex libssl-dev sdcc-nf
Debian 7 Wheezy:
apt-get install libncurses5-dev zlib1g-dev gawk
Fedora 17:
yum install -y subversion binutils bzip2 gcc gcc-c++ gawk gettext flex libz-dev flex ncurses-devel zlib-devel make patch unzip perl-ExtUtils-MakeMaker mkdir ~/openwrt cd openwrt svn co svn://svn.openwrt.org/openwrt/trunk/ cd trunk ./scripts/feeds update -a ./scripts/feeds install -a make prereq make menuconfig ionice -c 3 nice -n 20 make -j 3 #always put nproc +1
Fedora 18 - 64Bit (Maybe also for lower versions, some packages seem to be missing above):
yum install -y subversion binutils bzip2 gcc gcc-c++ gawk gettext flex ncurses-devel zlib-devel make patch unzip perl-ExtUtils-MakeMaker \ glibc glibc-devel glibc-static quilt ncurses-lib sed sdcc intltool sharutils bison
#Maybe you need glibc.i686 glibc-static.i686 glibc-devel.i686 libgcc.i686 too
openSuSE 11.1
zypper install binutils bzip2 gawk gcc gcc-c++ gettext make ncurses-devel patch unzip wget zlib-devel flex git-core
Ubuntu 9.10:
sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib bison autoconf screen gcc g++ binutils patch bzip2 flex make gettext unzip libc6 git-core
Ubuntu 11.10:
sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt
Ubuntu 12.04LTS:
sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl
Ubuntu 64bit:
sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext
Mac OS X (tested on 64-bit Lion & Mountain Lion):
- Download & useMacPorts .pkg Installer, and install the following packages with the help of Mac-Ports:
sudo port -v selfupdate
sudo port install coreutils 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 e2fsprogs ossp-uuid gawk findutils
- Required for 64-bit OS X: After checking out the source tree via svn above, we need to edit trunk/tools/Makefile
- On line 17, erase the instance of "e2fsprogs" but leave the rest of the line
- Comment out line 22, line 50, line 52, line 58 with the hash symbol, by putting # at the beginning of each line. They are the lines that issue qemu to be built, followed by the build dependancies for mtd-utils (dep: e2fsprogs), qemu (dep: e2fsprogs), and e2fsprogs respectively.
- Then copy the required headers and libraries to compile tools/mtd-utils
cd trunk; mkdir -p staging_dir/host/include/e2fsprogs; cp -R /opt/local/include/ossp staging_dir/host/include/e2fsprogs/; cp /opt/local/lib/libuuid* staging_dir/host/lib
See thread: [HOWTO] Build OpenWRT Trunk from svn on Mac OS X 10.7 Lion for more details
Notes:
- In Debian or Ubuntu use
apt-cache search ""
to find prerequisite packages. Naming is sometimes different - In openSuSE some packages require additional repositories. Search on http://packages.opensuse-community.org and add repositories like that:
zypper ar "http://download.opensuse.org/repositories/devel:/languages:/perl/openSUSE_11.1/devel:languages:perl.repo"
- To build your images on a Mac OS X Machine all you need is the package "fileutils" from the fink project. (Tested on Leopard 10.5.3)
Downloading Sources
Short version: https://dev.openwrt.org/wiki/GetSource
You have two choices:
- Download the latest stable release, or
- Download the bleeding edge development snapshot (currently named "Barrier Breaker", but often called "trunk").
The official repository is in svn but you can also choose to use git if you're building trunk. Refer to the GetSource for the URLs and amend the following commands appropriately.
Using Release Sources (stable)
As of this writing, the latest stable release is OpenWrt 10.03 "Backfire". There is a Backfire branch in SVN repository, which is still slowly being updated with verified patches. Using it will most likely produce a stable and working OpenWrt installation, but all the newest features and patches might not be there. As an example, this will check out the source code that the backfire release is built from (plus the latest backported fixes from trunk):
svn checkout svn://svn.openwrt.org/openwrt/branches/backfire
You could alternatively download a 'tagged' version of the backfire sources. For instance, if you insist on using the pristine release sources (no backported fixes applied after the last release), you could use:
svn checkout svn://svn.openwrt.org/openwrt/tags/backfire_10.03
You can check out a certain revision:
svn checkout --revision=24045 svn://svn.openwrt.org/openwrt/branches/backfire/ ./build_dir
As for the packages copy feeds.conf.default in ./build_dir to feeds.conf and add "@24045" at the end of the line that checks out the package feed:
src-svn packages svn://svn.openwrt.org/openwrt/packages@24045
Using Development Sources (bleeding edge)
The development branch (trunk) contains everything from documentation to experimental patches.
- get latest
svn checkout svn://svn.openwrt.org/openwrt/trunk/
- get certain revision
svn co svn://svn.openwrt.org/openwrt/trunk/@<rev#>
Troubleshooting
- Beware of unusual environment variables such as
GREP_OPTIONSwhich should not have–initial-tabor other options affecting its outputSEDshould not be set. If it is, run `unset SED` before compiling. (See Ticket 10612.)
doc/howto/buildroot.exigence.txt · Last modified: 2013/05/20 04:10 by ileadu
