The Apple XServe platforms come with 'darwin', an open source POSIX-compliant computer operating system released by Apple Inc. This includes a C/C++ compiler that has been derived from the open source gcc compiler. However, it is currently based on gcc 4.0.1 which was release in 2005, and it may be necessary to install a newer version, perhaps in a user area to overcome bugs with the earlier version.
I had to install a newer version because gcc 4.0.1 is unable to cope with pre-compiled headers that use anonymous namespaces, and boost libraries, which logically belong in precompiled headers, make considerable use of anonymous namespaces.
It is common to create a directory '~/local' which will contain the include and library files that are associated with locally installed programs. The following can be included in the .profile to ensure that locally installed code is used in preference to system programs.
If the files are to be installed in another location then ~/local should be replaced with this new location (e.g. /User/common/local) in all the following examples.
gcc is dependent on two maths libraries:
The GNU Bignum library (gmp), available from http://gmplib.org/
This now appears to be installed, so an installation is no longer necessary
If it is not installed then it should be installed before mpfr as mfpr is dependant on gmp.
gmp 4.1.4 should be downloaded and built, in that 4.2.X is unable to build on darwin because the configure operation returns: "configure: error: no version of add found in path'. Once a later version of gcc has been installed it is then appears to be possible to install 4.2.X, presumably because gcc has added 'add'.
gmp should be downloaded and unpacked (tar -xzf xxx.tar.gz), and then installed with
./configure --prefix=~/local /local --host=none-apple-darwin
The precision floating point library mpfr, available from http://www.mpfr.org/
Both should be downloaded and unpacked (tar -xzf xxx.tar.gz), and then installed with
This puts the associated header files for each library into ~/local/include and the library files into ~/local/lib
In order that the library files can be found during the process of building gcc, the following should then be run
The full source should be downloaded from http://gcc.gnu.org/. The core source is not suitable because it does not contain the C++ compiler.
./configure --prefix=~/local --enable-languages=c,c++ --with-gmp=~/local --with-mpfr=~/local
make check (which may not work)
It is recommended that only the languages required are configured as the whole process is extremely lengthy (One step in the java build takes over an hour in itself), and problems were encountered building the java compiler.
Note that after it is installed, when ./configuring other libraries for installation it will still (correctly) determine that the toolset to be used is darwin. This should not be overruled, e.g. with --use-toolset=gcc.
The source for boost can be downloaded from http://www.boost.org/ and unpacked in the usual way. This has to be compiled using 'darwin' even after a new gcc compiler has been installed as the gcc compiler will have taken on the characteristics of its darwin host (eg the dylib suffix for dynamic libraries).
The generic gcc does not support the command "-no-cpp-precomp" so line 332 (or thereabouts) of tools\build\v2\tools\darwin.jam must be editted to remove "-no-cpp-precomp" so that it reads:
flags darwin.compile OPTIONS : -gdwarf-2 ;
The "-no-cpp-precomp" option is obsolete even for darwin.
Boost (version 1.43) can then be configured, built and installed as follows.