Facilitate linking of static binaries
Minimal solution. The user has to manually set both
-DBUILD_SHARED_EXE=no and CFLAGS=CXXFLAGS=-static, perhaps manage
their own toolchain, and certainly make static libraries available for
all dependencies. Also does not auto-detect if compiler defaults to
static (Cray). Works better than LINK_SEARCH_END_STATIC because
otherwise dynamic flags can be added to the middle if some libraries
in default search path exist as both dyanmic and shared.
Fixes #911
Related to #1641
Change-Id: If7b8192b44c33c861f126e3422df04388d2f2be5