Recently, I had cause to tinker about with decoding some Camera RAW files that were unsupported by my usual converter, and I decided to try Dave Coffin’s opensource dcraw. Visiting Dave’s dcraw page, there were links to another site that has nightly builds from Dave’s source. The only problem with that was that the binaries available for Mac were not based on the latest source file. (Dave only shares the source code) File dates on the download are 2009.
So, in the absence of a useful working binary, I decided to download the C source file and compile it myself. Apple distributes the development environment for Mac OSX (XCode) at no charge, how hard could it be?
Well, it turns out it’s not that hard, just complex to achieve, and many false leads to follow that might deter you in the process. I followed a few myself but as it turns out, if you happen to find the right places to look it will come together pretty easily. The object of this blog entry is to point out one way that works (I’m sure there are others) I’ll make this point form with minimal in depth explanations. If you get stuck or need more clarity please leave a comment. (Comments are moderated, but I do check them so don’t be deterred)
Lets get to work:
1) Install XCode.
On Lion, XCode is no longer on the install DVD, it’s in the App Store as a free App. Just purchase it as you would any other app using your AppleID. Be warned, it’s a fair size download! Also, on Lion Apple has changed the install location, older versions were installed in /Developer, this version is installed in /Applications as XCode.app
Unless you want to keep the old versions in /Developer (if you even have them) you can delete them to save disk space.
2) Start XCode and accept the license agreement.
3) In Xcode, install the commandline tools.
Go to the XCode menu, select Preferences, then ‘Downloads’. Select ‘Command Line Tools’ and click the ‘install’ button.
Note that you need an Apple Developer ID to download the command line tools. This is no big deal, and won’t cost anything. You can add the DeveloperID to your existing AppleID. The download will prompt you for your DeveloperID and forward you to Developer registration if you don’t have one. Once you have registered and confirmed the registration via the email that Apple will send you, you will need to restart the Command Line Tools download from within XCode as above. Once installed, head to the next step:
4) Download and install MacPorts
The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system. If you’ve played with Linux, much of the content of MacPorts will be familiar to you.
The Lion MacPorts installer is here. Download the installer disk image and run the installer from the disk image.
5. Use MacPorts to download, build and install dcraw, including dependancies required to run and build dcraw.
If all goes well, this is the last step. Open Terminal and type:
sudo port install dcraw
You will be prompted for your password and then the process of downloading and building dcraw will begin.
Depending on the speed of your computer and your internet connection, this will take a little while, but at the end you should have a functional and up to date dcraw installed at /opt/local/bin/dcraw (v9.12 at this time)