Note: This article assumes you are comfortable using the Mac OS X Terminal and have some familiarity with downloading and extracting Unix packages.

Some of you may have installed the packages on the development CD-ROM that comes with Mac OS X. This CD includes, among many other things, GNU C and a whole bunch of compilation tools. Because Mac OS X is based on Darwin, an open source Unix in the BSD family, you can install a lot of the programs that Linux and BSD users have been enjoying. However, there are a couple of things to watch out for.

When you first download and extract some source code, you might be tempted to edit the Makefile and just run make. Or, you might not know what to do at all. The first thing you should do is cd to the source code directory and read the INSTALL and README files (the name of the source code directory is usually the name of the package with a version number, such as foo-1.2.3).

./configure
Most open source packages include a configure script that determines what type of Unix you’re using and creates whatever Makefiles are needed to compile the application. To invoke this script, type ./configure, and press enter. In some cases, this script might fail. If so, this hint might help out.
Even if that hint works, it might not always lead to a successful compilation. For example, I was able to get lynx to configure on my system, but I got a vicious “signal 10″ error during compilation. I soon learned that the most stable version of Lynx does not support Mac OS X out of the box, but the latest development version does. So, I downloaded that version, and it works fine on my machine!

The configure script is created by the autoconf package, a powerful aid in developing code that compiles on a wide range of Unix-like operating systems.

make
After you configure the source code, run the make command (unless otherwise directed by the INSTALL or README file). This will compile the code. If the compilation succeeds, you should run any tests that were supplied. These can usually be run with the command make test or make check. An error in the tests indicates that something may have gone wrong with the compilation. If this happens, you should review the documentation that comes with the source code for instructions on reporting or correcting the error.

Installing it
If all went well, you can install the program. This is usually accomplished by the command make install, but please review the README and INSTALL files first. You may need to use the sudo command to assert your administrator privileges, as in sudo make install. When you use sudo, you’ll be asked for your password. Please note that this gives you total control over the system - if you’re installing a package that is poorly configured or contains malicious code, you could end up overwriting important system files and damaging your system.

If I’m installing unfamiliar software, I usually run make install without sudo and watch what it tries to do. In most cases, it will copy some files into the /usr/local directory somewhere. For the most part, this is safe, since Mac OS X does not place any critical files in that folder. If you decide to do this dry run, you’ll get a lot of error messages as you do it, since your user account doesn’t have the privileges to create files in /usr/local.