﻿{"id":1036,"date":"2012-11-25T21:02:15","date_gmt":"2012-11-25T13:02:15","guid":{"rendered":"http:\/\/nick.workao.org\/?p=1036"},"modified":"2021-11-17T11:27:03","modified_gmt":"2021-11-17T03:27:03","slug":"howto-build-openwrt-trunk-from-svn-on-mac-os-x","status":"publish","type":"post","link":"http:\/\/nick.txtcc.com\/index.php\/linux\/1036","title":{"rendered":"[HOWTO] Build OpenWRT Trunk from svn on Mac OS X"},"content":{"rendered":"<p>I recommend following these steps\n1) Install XCode &#038; Macports\n2) Getting a build environment ready\n3) Grabbing sources\n4) Modifying Makefiles (e2fsprogs really doesn&#8217;t like 64-bit Lion, and qemu refuses to compile)\n5) Installing the missing dependancies\n6) <a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/build#updating.feeds\">Building OpenWRT<\/a> (from Updating Feeds on)<\/p>\n<p>&nbsp;<\/p>\n<p><strong>1.<\/strong> XCode &#038; Macports\n<strong>a.<\/strong> You will need to install <a href=\"https:\/\/developer.apple.com\/xcode\/\">Xcode 4.0<\/a> from the Apple developers&#8217; webpage, which will redirect you to the App Store entry for Xcode where you will follow the instructions on that page to install.<\/p>\n<p><strong>b.<\/strong> Then,\u00a0 grab <a href=\"https:\/\/distfiles.macports.org\/MacPorts\/MacPorts-2.0.3-10.7-Lion.dmg\">the latest MacPorts .pkg installer for Lion<\/a>.\nMount the disk image and install MacPorts with the .pkg file. Open the Terminal.app from \/Applications\/Utilities<\/p>\n<p>sudo port -v selfupdate &#038;&#038; sudo port install subversion<\/p>\n<p>Follow <a href=\"http:\/\/www.macports.org\/install.php#pkg\">these<\/a> directions if the above command does not work after mounting the dmg and installing.<\/p>\n<p>Then:<\/p>\n<p>port select &#8211;list gcc<\/p>\n<p>Should give you an output similar to<\/p>\n<p>air:~ alex$ port select &#8211;list gcc<\/p>\n<p>Available versions for gcc:<\/p>\n<p>apple-gcc42<\/p>\n<p>gcc42<\/p>\n<p>llvm-gcc42<\/p>\n<p>mp-gcc44 (active)<\/p>\n<p>none<\/p>\n<p>I do not believe the version of gcc matters, but if it does, here&#8217;s how to replicate my set up:<\/p>\n<p>sudo port install gcc44 &#038;&#038; sudo port select &#8211;set gcc mp-gcc44<\/p>\n<p>Don&#8217;t follow the above step unless you run into trouble later in the HOWTO when we try to compile OpenWRT.\u00a0 The above command will build gcc-4.4 from scratch and that takes time. A lot of time.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2.<\/strong> Set up the build environment\n<strong>a.<\/strong> Now install the packages needed to manipulate the OpenWRT source (horizontal scroll to see entire command, its long):<\/p>\n<p>sudo port install coreutils asciidoc binutils 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<\/p>\n<p>While this is compiling the packages for your system, continue on to <strong>2b<\/strong> and <strong>3a<\/strong> since they don&#8217;t depend on any of the above packages.<\/p>\n<p><strong>b.<\/strong> The OpenWRT source is case-sensitive, unfortunately HFS+ drives formatted by Apple are not set to be case-sensitive; so we&#8217;re going to create a <em>.sparseimage<\/em> workspace by opening <strong>Disk Utility<\/strong> in the \/Applications\/Utilities directory.<\/p>\n<p>Click File -> New -> Blank Disk Image&#8230;\nOn the top of the dialog that just came up fill in &#8220;<em>OpenWRT<\/em>&#8221; without the quotes in the <strong>Save As:<\/strong> field and in the lower <strong>Name:<\/strong> field.<\/p>\n<p>Choose a size <strong>larger than 3GB<\/strong>. My disk image is ~8G and will reach it&#8217;s limit after compiling the packages and firmware images more than a few times.\nIMPORTANT: In the <strong>Format:<\/strong> drop down, select\u00a0 <strong>Mac OS Extended (<em>case-sensitive<\/em>)\u00a0<\/strong><\/p>\n<p>In the <strong>Image Format:<\/strong> drop down select &#8220;<em>sparse disk image<\/em>&#8220;. Then click <strong>Create<\/strong>. The newly created disk image will be on the left panel of the Disk Utility, double clicking it will mount it on <strong>\/Volumes\/OpenWRT<\/strong><\/p>\n<p><strong>3.<\/strong>Grabbing the source tree\n<strong>a.<\/strong> Open the Terminal and type:<\/p>\n<p>cd \/Volumes\/OpenWRT &#038;&#038; svn co svn:\/\/svn.openwrt.org\/openwrt\/trunk\/<\/p>\n<p>Give it a few minutes while it pulls the source from the repository.<\/p>\n<p><strong>4.<\/strong> Modifying Makefiles\nOpen TextEdit.app and open \/Volume\/OpenWRT\/trunk\/tools\/Makefile<\/p>\n<p>cd \/Volume\/OpenWRT\/trunk &#038;&#038; open tools\/Makefile<\/p>\n<p>On <strong>line 17<\/strong> erase the &#8220;<em>e2fsprogs<\/em> entry so it should look like this:<\/p>\n<p>tools-y += sstrip ipkg-utils genext2fs\u00a0 mtd-utils mkimage<\/p>\n<p>Comment out <strong>line 22<\/strong> like so:<\/p>\n<p>#tools-$(CONFIG_TARGET_x86) += qemu<\/p>\n<p>Then go on to comment out line 50, line 52, line 58; they are the build dependencies for mtd-utils (dep: e2fsprogs), qemu (dep: e2fsprogs), and e2fsprogs respectively.<\/p>\n<p><strong>5.<\/strong> Installing the missing dependencies\nNow let&#8217;s install and copy MacPort&#8217;s e2fsprogs and osso-uuid&#8217;s libraries and headers so we can build <strong>tools\/mtd-utils<\/strong> correctly<\/p>\n<p>sudo port install e2fsprogs osso-uuid<\/p>\n<p>Followed by:<\/p>\n<p>cd \/Volumes\/OpenWRT\/trunk;<\/p>\n<p>mkdir -p staging_dir\/host\/include\/e2fsprogs;<\/p>\n<p>cp -R \/opt\/local\/include\/ossp staging_dir\/host\/include\/e2fsprogs\/;<\/p>\n<p>cp \/opt\/local\/lib\/libuuid* staging_dir\/host\/lib<\/p>\n<p>Then follow this <a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/build#updating.feeds\">manual<\/a> on how to build OpenWRT now that you have successfully built the necessary tools to compile OpenWRT images on Mac OS X 10.7 Lion.<\/p>\n<p>Start from the section titled &#8220;<strong>Updating Feeds<\/strong>&#8221; and follow the wiki in it&#8217;s entirety. Do not select any &#8216;qemu&#8217; entries when you reach the <strong>make menuconfig<\/strong> step; qemu will not build on 64-bit Lion.<\/p>","protected":false},"excerpt":{"rendered":"<p>I recommend following these steps 1) Install XCode &#038; Macports 2) Getting a build environment re&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,340,39],"tags":[350,341,342,349,144],"class_list":["post-1036","post","type-post","status-publish","format-standard","hentry","category-linux","category-mac-os","category-scm","tag-build","tag-lion","tag-mac","tag-openwrt","tag-svn"],"_links":{"self":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=1036"}],"version-history":[{"count":2,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1036\/revisions"}],"predecessor-version":[{"id":1038,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/1036\/revisions\/1038"}],"wp:attachment":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=1036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=1036"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=1036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}