modifications to support FreeBSD

First two commits aren't FreeBSD specific but are required, final commit adds a few things to support FreeBSD.

I've tested this on FreeBSD 9.0-RELEASE for both server and desktop versions.
+ gcc-4.6.4
+ R-2.15.0 and R-2.15.1
+ qt-4.8.2