Compiling gnu utilities on MacOSX

As someone had pointed out, I was using a gnu sed when modifying the make file for libgsm.
MacOSX does not ship with a gnu sed.

This is how I usually build gnu utilities (and basically, everything else I need and build from source)

As an example, how to build sed is shown:

First, obtain and unpack sed

$ /usr/bin/curl -O
$ tar xzpf sed-4.1.5

Set up compiler flags

$ export CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch x86_64 -arch ppc64 -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4"
$ export LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch x86_64 -arch ppc64 -arch ppc -arch i386 -mmacosx-version-min=10.4"

Start the compilation and install

$ ./configure --disable-dependency-tracking
$ make -j 4 && make install

That is it. The newly built sed can be found in /usr/local/bin.
Be sure that '/usr/local/bin' precedes '/usr/bin' in your $PATH.
Same for '/usr/local/man' in $MANPATH.

General hints:
This should work for most gnu utilities which do not have too many dependencies (libraries).
Sometimes, if compilation fails, try stripping "-arch x86_64 -arch ppc64" from the compiler flags.
If all fails, omit the compiler flags completely.

Things you may want to try to compile:

  • rdestkop-1.60
  • cabextract-1.2
  • wget-1.11.4
  • gawk-3.1.6
  • p7zip-4.65

Things you can compile but require some expertise as to which configure flags to use and to omit

  • lftp
  • openssl
  • nmap