MacDevCenter    
 Published on MacDevCenter (http://www.macdevcenter.com/)
 See this if you're having trouble printing code examples


Getting to the Source of Mac OS X

by Chris Coleman
12/21/2001

When Apple began developing Mac OS X, they did something really cool: they chose BSD Unix as the core foundation for the OS. On top of BSD Unix, they added their programming APIs, Graphics Engine, and Aqua GUI. This is common knowledge. But what many people don't know is that the source code for much of Mac OS X is available to the public.

But Apple didn't open source all of Mac OS X. They kept enough closed to make a very good commercial product while not limiting its usefulness for developers.

Darwin, the base operating system upon which Apple layered its components, is the open source component of Mac OS X. It's based largely on FreeBSD Unix and Mach technologies. Most of this code was already open, and Apple chose to keep it that way. The existing business-friendly license on the code allows Apple to create a proprietary version and maintain an open source version without compromising any of their intellectual property.

Darwin Can Stand on Its Own Two Feet

Since Darwin is there working all the time beneath the Aqua interface, this Unix-based core of Mac OS X can be accessed directly using the Terminal application. Apple has even taken things one step further and added enough of its own code to Darwin to make it a stand-alone operating system.

Related Reading

Mac OS X: The Missing ManualMac OS X: The Missing Manual
By David Pogue
Table of Contents
Index
Full Description
Sample Chapter

You can install Darwin on your computer system and have a fully functional Unix server, or activate the standard XFree86 graphics engine to turn it into a Unix desktop. Many popular Unix applications have already been ported to Darwin.

Installing Darwin as a standalone OS is much like installing BSD or Linux, especially versions that only have a text-based installer. It asks you a few questions about where you want to install it and then goes to work; it's still a very simple installer. The install notes recommend disconnecting all drives except the target drive. It says this is to prevent the accidental destruction of data on the wrong disk. This is the first release that Darwin has had its own installer, so this really isn't that unexpected.

Also new with this release, XFree86 comes installed by default. Since XFree86 for Darwin doesn't need a configuration file, you should be able to start X immediately. However, you may wish to install a different window manager than the default one.

If you're interested in working with XFree86, we've already published some articles to get you on your way. Michael Norton's Installing XFree86 on Mac OS X and my Rootless X Server on Mac OS X will provide you with all the info you need.

At this point, Darwin will feel very familiar to users of Unix. All the familiar tools are there, ranging from sed, to ssh, to vi, to Perl. It also has the standard suite of developer tools, like CVS, GCC, GNU Make, and even BSD Make.

If you register at their developer site, you can check out a current copy of the source code from CVS. If you don't register, you can get a copy on CD or download it project by project from the 1.4.1 Release site.

Apple also makes it very easy to contribute as a developer to the project. Just make your change available for download and submit a modification request at http://www.darwin.org/projects/modifications.html.

Darwin is Open Source

Darwin is 100% open source (you can check out the source code online). It's also free via a download, or available for purchase on CD with lots of Darwin-packaged applications. To download it, go to Darwin.org and grab the PowerPC version (it's a CD image that needs to be written to CD before installation). You can also purchase the CD from BSD Mall.

When a project is released into the open source community, it takes on a life of its own. How it's developed doesn't necessarily correspond with the goals of company sponsoring the project. The original creators have two basic options:
  1. Ignore, squash it, and don't let changes in to the code base.
  2. Or, accept it and let the code thrive and evolve.

Apple has chosen the latter option, even to the point that there's a download available for the Intel platform.

Darwin on Intel

Comment on this articleThere are many things to discuss related to Darwin. One topic in particular is its port to the Intel platform. What have your heard or seen?
Post your comments

Yes, that is what I said. Darwin, the core of Mac OS X, is available for the Intel platform. Granted, it only works on a limited number of hardware configurations, but work is progressing to increase its compatibility on more Intel processors. This port has been coordinated entirely by volunteers in the open source community.

Here's where the supported hardware stands at this point:

As you can see, the list of supported hardware is pretty slim. Also there are a few known issues to consider before installing on x86. From the release notes:

The installer is basically the same on x86 as on PowerPC. Both require you to burn the downloaded image to CD before installing. I didn't have much luck with the spare x86 hardware I had available, but I'd be interested in hearing some success stories.

A Brief Review of the State of Darwin

The code in Darwin is the same as the code used to build Mac OS X. So if you want access to the source code for Mac OS X, you need to become part of the Darwin project. The department at Apple responsible for Darwin seems very responsive to community needs and feedback. As you can tell from the inclusion of Intel support, this is a true open source project. Apple has fully embraced the open source spirit, without compromising its financial interests.

Copyright © 2009 O'Reilly Media, Inc.