Solve issue with realpath on Mac OS X.

* realpath doesn't work on Mac OS systems. I found the following
  workaround that should work in any distro. For more references see the
  following: http://serverfault.com/questions/40144/how-can-i-retrieve-the-absolute-filename-in-a-shell-script-on-mac-os-x
Merge pull request #640 from rafael/fix-realpath-issue-on-mac

Solve issue with realpath on Mac OS X.