[darwinbuild-dev] HOWTO: Building Darwin 10.4.7 for PPC using builddarwin

Craig Harman charman at rcbi.rochester.edu
Thu Nov 2 10:22:07 PST 2006


This is a brief description of how I was able to build Darwin 10.4.7
for the PowerPC platform.  It is written by a newbie, and aimed at
other newbies.  Please feel free to chime in if you have any 
corrections or suggestions.  This procedure was tested on an 
OS X 10.4.8 G5 machine with Xcode 2.4.  Your mileage may vary, etc,
etc.

The easiest way to build Darwin is to use the darwinbuild program.
Unfortunately, building the latest versions of Darwin is currently
more difficult than it could be because we are in a transition period.
The OpenDarwin project is in the process of shutting down, the front
page of Apple's MacOSForge site has been offline since September 19th
(but other parts of the site are operational, if you know where to
look), and the relevant instructions for building darwin are scattered 
across the net.  This process should become much simpler once MacOSForge
is fully operational.


== DOWNLOADING AND COMPILING DARWINBUILD ==

Use Subversion to get the latest (currently not well advertised)
version of darwinbuild from MacOSForge.org:

  % svn checkout http://svn.macosforge.org/repository/darwinbuild/trunk/

This will create the trunk directory within your working directory.
The file trunk/README contains installation instructions, which are
the standard:

  % make
  % sudo make install

This should work fine if you are using GCC 4.01.  If you have used the
gcc_select command to switch to GCC 3.3, then you will get a
compilation error:

  cc: cannot read specs file for arch `i386'

because of a line in trunk/darwintrace/Makefile that indicates what
architectures Darwin should be compiled for:

                -arch i386 -arch ppc -arch ppc64 \

Removing the entries for the i386 and ppc64 architectures fixes the
error.

I had read online postings that earlier versions of Darwin should only
be compiled with GCC 3.3.  I'm assuming that this is no longer the
case, given that darwinbuild only compiles without errors using GCC
4.01.


== BUILDING DARWIN UP TO 10.4.5 ==

The darwinbuild README file contains instructions for building
Darwin:

  % hdiutil create -size 4g -type UDIF -fs HFSX -volname Builds \
        -uid 0 -gid 0 -attach Builds.dmg
  % sudo vsdbutil -a /Volumes/Builds
  % sudo -s
  Password:
  # cd /Volumes/Builds
  # mkdir Build8C46
  # cd Build8C46
  # darwinbuild -init 8C46
  Attempting to download
  http://svn.macosforge.org/repository/darwinbuild/trunk/plists//8C46.plist
  ...
  Download complete
  Attempting to download
  http://svn.macosforge.org/repository/darwinbuild/trunk/plists//8B15.plist
  ...
  Download complete
  Attempting to download
  http://svn.macosforge.org/repository/darwinbuild/trunk/plists//8A428.plist
  ...
  Download complete
  # ls
  .build  Headers Logs    Roots   Sources Symbols

If you are trying to build versions of Darwin 10.4.5 or earlier, you
should now be able to issue the command:

  % darwinbuild xnu

and the darwinbuld program will download the xnu kernel package, and
all of the packages that the xnu kernel depends on, from an online
repository.  The current online repository is on an opendarwin.org
server.  The OpenDarwin project is in the proces of being shut down,
and so their repository only contains source for Darwin up to 10.4.5.

Using darwinbuild to compile more recent versions of Darwin will be
covered below.  First, it is helpful to understand a little more about
how darwinbuild works.

The darwinbuild program is a shell script.  When it is executed with
the arguments:

  % darwinbuild -init [build_number]

it goes to the address given by the shell script variable DEFAULTPLISTSITE
(by default, http://svn.macosforge.org/repository/darwinbuild/trunk/plists/)
and looks for the file:

  DEFAULTPLISTSITE/[build_number].plist

Each build's .plist file can inherit information from an earlier
build's .plist file.  As you can see below in the sample output from
the darwinbuild's README file, build 8C46 (10.4.2) inherits
information from build 8B15 (10.4.1), which in turn inherits
information from build 8A428 (10.4.0):

  # darwinbuild -init 8C46
  Attempting to download
  http://svn.macosforge.org/repository/darwinbuild/trunk/plists//8C46.plist
  ...
  Download complete
  Attempting to download
  http://svn.macosforge.org/repository/darwinbuild/trunk/plists//8B15.plist
  ...
  Download complete
  Attempting to download
  http://svn.macosforge.org/repository/darwinbuild/trunk/plists//8A428.plist
  ...
  Download complete

At the moment, the .plist repository on MacOSForge:

  http://svn.macosforge.org/repository/darwinbuild/trunk/plists/

only contains .plist files up to build 8H14 (10.4.5). 


== BUILDING DARWIN FOR VERSIONS AFTER 10.4.5 ==

In order to use darwinbuild, we will need a valid set of .plist
files.  We can download the .plist files for 10.4 to 10.4.5 using:

  % svn checkout http://svn.macosforge.org/repository/darwinbuild/trunk/plists/

We can find the .plist files for 10.4.6 and 10.4.7 on Apple's Darwin
release page:

  http://www.opensource.apple.com/darwinsource/

The file:

  http://www.opensource.apple.com/darwinsource/10.4.6.ppc/release.plist

should be saved 8I127.plist, and the file:

  http://www.opensource.apple.com/darwinsource/10.4.7.ppc/release.plist

should be saved as 8J135.plist.  The Apple build numbers (in this case
8I127 and 8J135) can be found by looking at the contents of the .plist
files.

We now need to tell darwinbuild where to look for our .plist files.
This can be done by editing the darwinbuild script (in/usr/local/bin), 
and changing the value of the variable DEFAULTPLISTSITE from:

  DEFAULTPLISTSITE=http://svn.macosforge.org/repository/darwinbuild/trunk/plists/

to something like:

  DEFAULTPLISTSITE=file:///path/to/plist/folder

You should now be able to successfully run the command:

  darwinbuild -init 8J135

which will create the darwinbuild directory hieararchy needed to
actually compile Darwin.


Next, you will need to download a copy of the Darwin source.  You can
download the source from Apple with a free Apple Developer Connection
(ADC) account:

  http://www.opensource.apple.com/darwinsource/

Unfortunately, Apple doesn't provide a single file with all of the
Darwin source, and downloading each package individually can be
tedious.  The easiest way to download multiple Darwin packages is to
use the getDarwinSource Perl script:

  http://forums.macosxhints.com/archive/index.php/t-50441.html

be sure to scroll and grab the second version of the script.  You will
want to edit the @inclusions and @exclusions arrays to control which
Darwin packages should be downloaded.

Once you have downloaded all of the Darwin packages you need, you
should place the .tar.gz files in the Sources directory of the
darwinbuild directory hierarchy.  darwinbuild will look in this
directory for either directories or .tar.gz files with the package
name and version numbers specified in the .plist files.

You should now be able to issue a command like:

  % darwinbuild xnu

and darwinbuild will compile the specified package.


More information about the darwinbuild-dev mailing list