build fixes for FreeBSD systems

  Build using the XSI-compliant strerror_r for FreeBSD as well as OSX
  and Solaris.  Add _POSIX_C_SOURCE check to GNU feature test macros.
use bourne-compliant shell in scripts