check linker, other script fixups

As requested in #1672. Since I'm at it, a few other minor fixups:
 - add clang, cc fallbacks if $CC is unset and gcc is not found
 - replace backticks with POSIX-style (nestable) `$()` expansions
 - remove unnecessary escaped newlines over logical operator `||`.
 - use `/usr/bin/env sh` shebang so a better sh in path will override  `/bin/sh`
 - fix to wrap columns 80