Allow libsodium to be installed in a custom path and fix for SmartOS/Solaris build

The check for libsodium is moved to after the host system checks because in SmartOS the "-lssp" is required for the checks for libsodium.

All tests pass in SmartOS and Mac OS X at this commit.