August 04, 2005

OSCON: Customizing MacOS X with Open Source Software

DarwinPorts
  • Conceptually similar to FreeBSD ports
  • Customization via "variants" system (unique to DarwinPorts)
Building Darwin
  • It's possible to patch and/or modify darwin code, compile it, and then layer MacOS X on top.
  • Software Update will over-write such a system, however
  • There are potential problems:
    • Default compiler version (MacOS X ships with several GCCs)
    • Many tools needed for the build don't come with OS X by default
    • Environment variables
    • Aliases
Default Compiler Version(s) - All of these gcc versions have been the default compiler in one release of MacOS X or another.
  • 2.95.2
  • 3.1
  • 3.3 (compiler for Tiger OS)
  • 3.5
  • 4.0 (default in Tiger)
  • The gcc_select command will switch the default around
Environment Variables
  • SRCROOT - where the source code lives
  • OBJROOT - intermediate .o files
  • SYMROOT - debug versions of binaries
  • DSTROOT - final finished binaries
  • MACOSX_DEPLOYMENT_TARGET - allows flagging APIs as deprecated
  • RC_RELEASE - Tiger
  • UNAME_RELEASE - 8.0
  • UNAME - Darwin
  • RC_ARCHS - ppc i386 (architectures that binaries should be compiled for)
  • RC_ProjectName - Name of project being built
  • Even more variables....
Build Aliases - same sources, different results (client vs. server, for example)
  • Based on $RC_ProjectName
  • Examples are DSPasswordServerPlugin, cctools (compiler), libc (& libc debug)

Need to download private headers. Apple really discourages the use of static libraries, to make the system more flexible, and easier to patch. Sometimes static libraries are needed by the system itself, so it is possible to build them. But Apple doesn't ship any static libraries by default.

Some internal tools are also needed: kextsymboltool, for example.

The good news is that DarwinBuild can track all of these potential problems, and can download all of the necessary bits to make compiling Darwin easy. It automatically sets up a chroot() environment, for example, so that build can be done without mucking with currently running system. You give DarwinBuild a release number (8C42, for example, which is 10.4.2), and it will fetch a plist file, which describes details of the build.

DarwinBuild can be used to build individual components, like bash for example. Just type 'darwinbuild bash', and it will fetch the latest sources, and do a build.

Next, we got a demo of using DarwinBuild to build a version of talk that has Bonjour support. Fairly nifty stuff. Using DarwinBuild, you can target specific releases of MacOS X -- building talk for a friend that is still running Panther, for example. Posted by andyr at August 4, 2005 12:06 PM
Comments
Post a comment









Remember personal info?