Build fixes for SunOS and possibly others

This commit is a result of trying to build on Solaris (specifically,
SmartOS) with GCC. The main fixes come in the form of adding support for
DTrace for those platforms which require that every object be
"instrumented" when generating the final link object.

Additional fixes include adding proper linker flags (nsl, socket), and
missing includes when necessary.

Finally, this also prints out a nice Thread ID display in logging.c

Change-Id: I30a875ba2de114fc6d29eca04bd512b7fbc26a81
Reviewed-on: http://review.couchbase.org/43787
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>