OpenWrt Forum Archive

Topic: Instructions for building on OS X

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I helped a friend get OpenWrt building under OS X, and I thought I'd share the process:

1) First of all, you can not build on an HFS partition - the Linux kernel will not build on a filesystem that is not case sensitive.  Luckily, Disk Utility is here to save the day.  Create a 2 GB disk image in disk utility, then in Terminal:

sudo diskutil eraseVolume "Case-sensitive HFS+" newvolname volume


where volume is the mounted disk image volume

2) Install Fink.  This will give you wget and gettext.

3) Using FinkCommander (or via the cmdline), install the fileutils package.  This gives you the versions of cp and install that you'll need.

4) Using FinkCommander install the findutils package.   This gives you the version of xargs that you'll need.

5) Something in the build process wants true to be in /bin, so run

sudo ln -s /usr/bin/true /bin/true

6) Go ahead and fetch OpenWrt from CVS in the volume that you created in step 1.

7) msgfmt is in a different location than on a Linux box.  Apply the following patch to binutils-uclibc.mk:

--- binutils-uclibc.mk.dist     2004-08-13 17:19:48.170000000 +0000
+++ binutils-uclibc.mk  2004-08-13 17:20:49.960000000 +0000
@@ -54,7 +54,7 @@
                echo -e "nnYou must install 'flex' on your build machinen"; 
                exit 1; 
        fi;
-       @if [ ! -x /usr/bin/msgfmt ] ; then 
+       @if [ ! -x /sw/bin/msgfmt ] ; then 
                echo -e "nnYou must install 'gettext' on your build machinen"
; 
                exit 1; 
        fi;


A better change would be to remove the absolute path from the .mk altogether, which would then work on both platforms...
[/b]

8) squashfs isn't set up to be built under OS X.  The issue is with the code for endianness.  Apply the following patch to squashfs.patch

--- squashfs.patch.dist 2004-08-13 17:27:03.950000000 +0000
+++ squashfs.patch      2004-08-13 17:37:40.840000000 +0000
@@ -4,6 +4,21 @@

 --- squashfs1.3r3/squashfs-tools/mksquashfs.c-dist     2004-03-29 20:35:37.0000
00000 -0600
 +++ squashfs1.3r3/squashfs-tools/mksquashfs.c  2004-03-29 22:28:51.000000000 -0
600
+@@ -33,7 +33,13 @@
+ #include <dirent.h>
+ #include <string.h>
+ #include <zlib.h>
+-#include <endian.h>
++#ifdef __APPLE__
++      #include <machine/endian.h>
++      #define __BYTE_ORDER BYTE_ORDER
++      #define __BIG_ENDIAN BIG_ENDIAN
++#else
++      #include <endian.h>
++#endif
+ #include <stdlib.h>
+ #include <signal.h>
+ #include <setjmp.h>
 @@ -136,6 +136,8 @@
        stotal_bytes, stotal_inode_bytes, stotal_directory_bytes, sinode_count,
sfile_count, ssym_count, sdev_count, sdir_count, sdup_files;
  int restore = 0;
@@ -34,3 +49,20 @@
                } else {
                        ERROR("%s: invalid optionnn", argv[0]);
  printOptions:
+--- squashfs1.3r3/squashfs-tools/read_fs.c-dist        2004-01-18 20:35:37.0000
00000 -0600
++++ squashfs1.3r3/squashfs-tools/read_fs.c     2004-08-12 22:28:51.000000000 -0
600
+@@ -34,7 +34,13 @@
+ #include <zlib.h>
+ #include <sys/mman.h>
+
+-#include <endian.h>
++#ifdef __APPLE__
++       #include <machine/endian.h>
++       #define __BYTE_ORDER BYTE_ORDER
++       #define __BIG_ENDIAN BIG_ENDIAN
++#else
++       #include <endian.h>
++#endif
+ #include "read_fs.h"
+ #include <squashfs_fs.h>
+

9) At this point, it is necessary to get the build process started, so that some of the files can get downloaded.  Go ahead and run "make" from buildroot.    The build should fail while attempting to compile the kernel.

10) OS X does not have GNU expr (OS X's is POSIX compliant, just not GNU compatible).  Grab the file linux-2.4-bsd-expr.patch from the crosstool project.  Here it is for convenience

# http://in3www.epfl.ch/~schaffne/linux-2.4-bsd-expr.patch
The following makes it possible to compile linux 2.4.19 to 2.4.25 on Mac OS X,
where "expr" doesn't understand the "length" construct
(which it doesn't have to, according to SuSv3
(see http://www.opengroup.org/onlinepubs/007904975/utilities/expr.html)
See also http://sources.redhat.com/ml/crossgcc/2004-02/msg00131.html

Fixes error
  expr: syntax error
  KERNELRELEASE "2.4.21" exceeds 64 characters
  make: *** [include/linux/version.h] Error 1


diff -ur linux-2.4.23-old/Makefile linux-2.4.23/Makefile
--- linux-2.4.23-old/Makefile    2003-12-09 14:27:56.000000000 +0100
+++ linux-2.4.23/Makefile    2003-12-09 14:28:37.000000000 +0100
@@ -353,7 +353,7 @@
     @rm -f .ver1
 
 include/linux/version.h: ./Makefile
-    @expr length "$(KERNELRELEASE)" <= $(uts_len) > /dev/null || 
+    @expr "$(KERNELRELEASE)" : '.*' <= $(uts_len) > /dev/null || 
       (echo KERNELRELEASE "$(KERNELRELEASE)" exceeds $(uts_len) characters >&2; false)
     @echo #define UTS_RELEASE "$(KERNELRELEASE)" > .ver
     @echo #define LINUX_VERSION_CODE `expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)` >> .ver


A sample command line to do the patch

cd build_mipsel/WRT54GS/release/src/linux/linux/
patch -p1 < linux-2.4-bsd-expr.patch

11) The final problem is that the executables for producing the final flash images are only provided to us from Linksys as i386 binaries.  Luckily, enough work has been done to document their behavior to reproduce them.  The source is attached (addpattern.c & trx.c).  The source we produced is a bit crude, but gets the job done.  Compile using

gcc addpattern.c -o addpattern
gcc trx.c -o trx


Replace the tools in /buildroot/build_mipsel/WRT54GS/release/tools/ with the OSX versions provided.

12) Go back to the buildroot directory and run "make" again.  This time the build should run to completion, yielding the openwrt-g-code.bin and openwrt-gs-code.bin files.  You will probably see some complaints about the package build process.  As we weren't interested in producing any packages, we did not pursue this aspect of the build.

13) Upload your .bin file via tftp (also available via fink) or the web interface and enjoy!

-----------

Of the steps outlined above, I believe that steps 7, 8, 10, and 11 can actually be integrated into the OpenWrt CVS code, yielding a project that will build across i386 Linux, OS X, and PPC Linux.  The code provided in step 11 will help eliminate another couple of closed-source parts of the WRT54G build process.

The only tricky parts of this whole process was figuring out step 1, and writing the code for step 11.

I don't have an OS X of my own anymore to pursue this aspect of OpenWrt much further, but I felt it was important to share this effort, and allow our OS X-based brethern to participate in the OpenWrt project too.

Enjoy!

Fantastic work!  smile  How many man-hours did all that take?!?

Yes, this is excellent. One note, though, the forum inserts nasty characters in the code blocks, so you can't just copy-paste the patches. Maybe post the patches as an attachment, instead? I hand-applied them.

It'd be really cool if the maintainers would incorporate your findings into the project. Not too much work is necessary on their part-- you've done all the hard stuff. Anyway, bravo to you.

Thanks much.

It'd be really cool if the maintainers would incorporate your findings into the project.

The problem is that much of the instructions given are obsolete. It's not that they just turned obsolete, it's the fact that much of it was obsoleted weeks before the original post was written. The addpattern and trx programs had been replaced for several weeks before the original post was made and squashfs-1.3 hasn't been used for months.

The problem is that much of the instructions given are obsolete. It's not that they just turned obsolete, it's the fact that much of it was obsoleted weeks before the original post was written. The addpattern and trx programs had been replaced for several weeks before the original post was made and squashfs-1.3 hasn't been used for months.

I would have posted this all earlier, but life's been a bit busy.  Sorry if I came in a little late on some of it...

I admit to not being aware of new replacements for the addpattern & trx programs.  However, the squashfs patches supplied actually weren't developed for version 1.3.  I took the current squashfs.mk files (as of a few days ago), and added my minor patches to them.  Anyways, it turns out the patch for squashfs is just as applicable to squashfs 2.0.  Ideally I'd get something submitted to the squashfs authors for OS X related fixes, but this solves the immediate issue.

It would still be nice if steps 7, 8, and 10 were integrated to complete OS X compatibility.  Then all people would need to do is install Fink + the necessary Fink packages.

Finally, I'm sorry if the patches got munged.  I'm afraid that I no longer have access to the system that I did all of this work on, so hopefully it makes enough sense to get it all to work.

This step-by-step guide works wonderfull!
I just did build OpenWRT on Mac OS X, only thing I did not need was addpattern and trx stuff.
Many thanks!
Greetings,
Holo

Edit:
Build maybe run now, but the image is corrupt. My router now sits there with blinking Power and alternating DMZ. Reflashing same image did not help.
I got this warnings while building sqashfs:
mksquashfs.c: In function `create_inode':
mksquashfs.c:484: warning: integer constant is too large for "long" type
mksquashfs.c:554: warning: integer constant is too large for "long" type
mksquashfs.c:559: warning: integer constant is too large for "long" type
mksquashfs.c:581: warning: integer constant is too large for "long" type
mksquashfs.c: In function `write_file':
mksquashfs.c:1043: warning: integer constant is too large for "long" type
mksquashfs.c:1109: warning: integer constant is too large for "long" type
mksquashfs.c: In function `dir_scan':
mksquashfs.c:1288: warning: integer constant is too large for "long" type
mksquashfs.c:1365: warning: integer constant is too large for "long" type

Edit2:
I replaced addpattern and trx with the sources found in this thread, made a full clean rebuild. Now the router comes up, no more blinking. It responds to ping, but i cannot telnet in.
Now I did all I can think of, and still no working OpenWRT:(

Edit3:
It finally works, the last problem was selfmade. I had played with the router before it got flashed with OpenWRT. I had changed the IP. After remebering that I can log in and everythink seems to be fine.

I haven't looked at the addpattern & trx source currently distributed with OpenWrt (where exactly are they in the distribution?), but I suspect that the source is not clean on big endian systems.  The source I posted is clean for both big & little endian systems (in a hacky sort of way - I don't think OS X has the same byte swapping routines as Linux, so I just put something together.

Edit:
OK, I found where the source is located.  It does look like the source is not safe for those on big endian systems.  Things like the magic number and length fields need to be written using an endian safe method (not memcpy())

Yeah, the image I built was also corrupt-- I just tried it last night. I had a linux box sitting around, so I just build it there instead. Still, it'd be nice to have endian-safe code...

hello all,

now how is it going on? I just got hold of a mac. Is it possible to build on OSX with less patching now? An alternative would be the FreeBSD box, but I don't have any linux around to build on.


regards

Thanks to the poineering work of the previous posters, I managed to build a working image. This is my first day with OpenWRT, and I'm not a Linux person, so these instructions might seem a little funny to the regular forum participants.

This installation does not use fink. I don't like fink, it seems to keep breaking an otherwise fine OS installation.
Instead, we'll build manually and put all our tools into /usr/local.

1) Create the case sensitive volume using
      hdiutil create -megabytes 2048 -fs "Case-sensitive HFS+" -volname "Development" -type SPARSE wrt54image -attach
    This will create a case sensitive filesystem inside a disk image that can grow up to 2 GB.

2) Create a link to the case sensitive area from your preferred projects directory
      ln -s /Volumes/Development build

3) Build and install wget from ftp://ftp.gnu.org/pub/gnu/wget/wget-1.9.1.tar.gz and put it into /usr/local/bin.
    There are binary wget packages available.

4) Build GNU cp and ginstall for OS X, and put them into /usr/local/bin:
    Get http://ftp.gnu.org/pub/gnu/coreutils/co … .1.tar.bz2 an unpack it into build/
      cd build/coreutils-5.2.1
      ./configure
      make
      sudo cp src/cp /usr/local/bin/
      sudo cp src/ginstall /usr/local/bin/install

5) Build GNU xargs and find for OS X, and put them into /usr/local/bin. The findutils don't
    compile with gcc 3.3, so we temporarily switch to version 3.1.
    Get http://ftp.gnu.org/pub/gnu/findutils/fi … .20.tar.gz and unpack it into build/
      cd build/findutils-4.1.20
      ./configure --disable-nls
      sudo gcc_select 3.1
      make
      sudo gcc_select 3.3
      sudo cp xargs/xargs /usr/local/bin
      sudo cp find/find /usr/local/bin

6) Install gettext.pkg from http://www.ellert.se/twain-sane/ -- it will end up in /usr/local/bin.

7) Create an openwrt directory inside your disk image and cd in.
      mkdir openwrt
      cd openwrt

8)  Get the latest code from CVS:
      cvs -d:pserver:anonymous@openwrt.org:/openwrt login
      cvs -d:pserver:anonymous@openwrt.org:/openwrt co buildroot
    You can later update using
      cvs up -Pd
    Change into the buildroot directory.

9) Copy missing snapshot files into sources/dl/. Currently, at least the following
    are required:
    http://www.paris-sansfil.fr/~thus/src/o … 16.tar.bz2
    http://www.paris-sansfil.fr/~thus/src/o … 16.tar.bz2
    http://www.paris-sansfil.fr/~thus/src/o … 16.tar.bz2

10) Install the OS X patches for sstrip, trx and mksquashfs.
    These are mainly to deal with endianness in build tools vs. runtime. I used elf.h from the WRT54G linux kernel source tree and modified it a bit.
    See *.patch attachments.

11) In order to make sure we use the GNU utilities, instead of "make" use
      PATH=/usr/local/bin:$PATH make
    It will take a while as we will now download the Linksys sources, and compile
    tons of files.
    The build will stall at
      Support ET_DYN in shared library loader (UCLIBC_PIE_SUPPORT) [N/y/?] (NEW)
    until you hit enter.

12) Save the sources/dl directory for next time.

13) Clean out the build volume, unmount it and shrink the image file back using
      hdiutil compact wrt54image

And are the patches that allow "make packages" to succeed. I haven't tested all of the packages, but at least they build.

See next message for the rest.

[Continued]

Hi robertm,

nice tutorials, although I can't get it to build so far.

First of all a sidenote, I had to install gcc3.1, as it isn't installed per default with Xcode 1.5.

Next, patching sstrip.c won't go. It looks like the original sstrip.c has already been changed for big endians. Running make from there won't work either, so I applied the patch by hand.

make brings up:

/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:62:27: endian.h: No such file or directory
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:63:24: elf.h: No such file or directory

-- which is for what we changed with the patch

and continues:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:316: error: parse error before "Elf32_Ehdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `readelfheaderident':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:319: error: `fd' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:319: error: (Each undeclared identifier is reported only once
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:319: error: for each function it appears in.)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:319: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:319: error: `EI_NIDENT' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:324: error: `EI_MAG0' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:324: error: `ELFMAG0' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:325: error: `EI_MAG1' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:325: error: `ELFMAG1' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:326: error: `EI_MAG2' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:326: error: `ELFMAG2' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:327: error: `EI_MAG3' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:327: error: `ELFMAG3' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:343: error: `EI_DATA' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:343: error: `ELFDATA2LSB' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:346: error: `ELFDATA2MSB' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:363: error: `EI_CLASS' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "Elf32_Ehdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `readelfheader32':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `fd' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `EI_NIDENT' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `Elf32_Ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `Elf32_Phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `ET_EXEC' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `ET_DYN' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "Elf32_Ehdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `readphdrtable32':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `phdrs' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `fd' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "const"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `getmemorysize32':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `Elf32_Phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "const"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `phdrs' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `PT_NULL' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `newsize' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before '*' token
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `modifyheaders32':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `Elf32_Phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `newsize' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `uint16_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `uint32_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `phdrs' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "Elf32_Ehdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `commitchanges32':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `fd' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `phdrs' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: `newsize' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:367: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "Elf64_Ehdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `readelfheader64':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `fd' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `EI_NIDENT' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `Elf64_Ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `Elf64_Phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `ET_EXEC' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `ET_DYN' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "Elf64_Ehdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `readphdrtable64':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `phdrs' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `fd' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "const"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `getmemorysize64':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `Elf64_Phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "const"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `phdrs' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `PT_NULL' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `newsize' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before '*' token
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `modifyheaders64':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `Elf64_Phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `phdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `newsize' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `uint16_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `uint32_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `phdrs' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "Elf64_Ehdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `commitchanges64':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `fd' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `uint64_t' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `__res' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `phdrs' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: `newsize' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:369: error: parse error before "__res"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: In function `main':
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:409: error: parse error before "Elf32_Ehdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:409: warning: no semicolon at end of struct or union
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:410: error: `Elf64_Ehdr' undeclared (first use in this function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c: At top level:
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:411: warning: data definition has no type or storage class
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:413: error: parse error before "Elf32_Phdr"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:413: warning: no semicolon at end of struct or union
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:414: warning: data definition has no type or storage class
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:415: error: parse error before '}' token
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:415: warning: data definition has no type or storage class
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:416: error: `newsize' used prior to declaration
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:420: error: parse error before "if"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:430: error: conflicting types for `progname'
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:73: error: previous declaration of `progname'
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:430: error: `argv' undeclared here (not in a function)
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:430: warning: data definition has no type or storage class
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:432: error: parse error before "for"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:432: error: parse error before '!=' token
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:435: error: `fd' used prior to declaration
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:435: error: initializer element is not constant
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:435: warning: data definition has no type or storage class
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:436: error: parse error before "if"
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:465: warning: parameter names (without types) in function declaration
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:465: warning: data definition has no type or storage class
/Volumes/Development/openwrt/buildroot/sources/openwrt/tools/sstrip.c:466: error: parse error before '}' token
make: *** [/Volumes/Development/openwrt/buildroot/build_mipsel/staging_dir/bin/sstrip] Error 1

It neither knows endian.h nor elf.h..., curious

I don't have time to further investigate the problem right now. I will see if I can have another try tomorrow.

perhaps there is already a solution for my problem until then.

I guess my instructions could use some improvement:

You need gcc 3.3, not 3.1. The latest development tools download from Apple has gcc 3.3 (gcc 3.1 is required for the fiindutils build as noted above).

I also noticed that the patches I posted didn't conform to the openwrt patch standard. Prepend "buildroot/" to the file names in "---" lines and remove the ".old" extension, prepend "buildroot-osx/" to the file names "+++" lines. I've done this for the two basic patches and attached them. You apply them as follows:
1) BEFORE you make (best to clean out everything and start from scratch): make sure you're one level up from buildroot and do patch -p0 < tools-osx.patch
2) Let make run its course, it will be a while (boy do I need a new dual 2.5GHz G5), and it will fail at the last stage. Then apply the second patch and make again. This time it should be really quick and complete successfully.

Last but not least don't apply the packages patches until the OS build has completed. I need to figure out why adding "/usr/local/bin" in the TARGET_PATH line in buildroot/Makefile breaks the OS build.

Okay, make did run through now. I have the openwrt-gs-code.bin to flash the router. BTW: in the userdoc it says one should use mtd and update using the linux.trx. Would using the linksys bin also work? Or should one better update it via TFTP?

For make packages, it won't go. It starts with oidentd, which brings up this:

cp src/oidentd /tmp/oidentd/usr/sbin
tar: root: %s: Invalid group
tar: Error is not recoverable: exiting now
tar: root: %s: Invalid group
tar: Error is not recoverable: exiting now
tar: ./data.tar.gz: Cannot stat: (null)
tar: ./control.tar.gz: Cannot stat: (null)
tar: Error exit delayed from previous errors
rm: /Volumes/Development/openwrt/buildroot/build_mipsel/IPKG_BUILD.22651/data.tar.gz: No such file or directory
rm: /Volumes/Development/openwrt/buildroot/build_mipsel/IPKG_BUILD.22651/control.tar.gz: No such file or directory
make: *** [/Volumes/Development/openwrt/buildroot/build_mipsel/oidentd-2.0.7_mipsel.ipk] Error 1

I found out that oidentd is copied to a file called sbin, replacing the created sbin-dir. I checked my PATH and neither cp in /bin nor the version in /usr/local/bin won't do it correctly.

Removing oidentd from the packages continues with the other packages. Let's see what else fails.

tar: root: %s: Invalid group
tar: Error is not recoverable: exiting now
tar: root: %s: Invalid group
tar: Error is not recoverable: exiting now
tar: ./data.tar.gz: Cannot stat: (null)
tar: ./control.tar.gz: Cannot stat: (null)
tar: Error exit delayed from previous errors
rm: /Volumes/Development/openwrt/buildroot/build_mipsel/IPKG_BUILD.24386/data.tar.gz: No such file or directory
rm: /Volumes/Development/openwrt/buildroot/build_mipsel/IPKG_BUILD.24386/control.tar.gz: No such file or directory
make: *** [iproute2-ipk] Error 1

won't build for iproute2. tar has some problem with users and groups, I can't figure out what's the cause for this, yet.

I've posted the patches for all packages above. Here's the relevant one again.

If you apply it after the fact, make sure you delete

buildroot/build_mipsel/staging_dir/bin/ipkg*

- oidentd works
- pppoecd works too
- iproute2 won't do it:

In file included from utils.c:28:
/Volumes/Development/openwrt/buildroot/build_mipsel/WRT54GS/release/src/linux/linux/include/linux/pkt_sched.h:32: error: parse error before "__u64"


make[2]: *** [utils.o] Error 1
make[1]: *** [all] Error 2
make: *** [/Volumes/Development/openwrt/buildroot/build_mipsel/iproute2/tc/tc] Error 2

I'm still building on the others.

Works for me. However, I have to change buildroot/Makefile before I make packages:

TARGET_PATH=$(STAGING_DIR)/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin

Then
PATH=/usr/local/bin:$PATH make iproute2

Undo the change to Makefile before making the kernel.

I already had this in my Makefile. What actually does the default version look like?

My PATH is also set to start with /usr/local/bin and uses the cp and stuff from there first in order.

Still iproute2 won't do it. Looks like some more tries with changes here and there. I will copy the whole thingy to my FreeBSD box in parallel with the hope of an easier way to success there smile.

The discussion might have continued from here.