Re-add link time optimization on OS X

In the new version of clang, -O4 does not imply -flto, so we set the
flag
Further work in pos_is_ok()

No functional change.
Use legal positions for endgame initialization

During endgame initialization we get the material
hash key of each endgame forging and ad-hoc position
that in same cases is illegal (leaves teh king under
capture). This is not a problem for the material key,
but rises an assert when SF is run in debug mode with
'testKingCapture' set in pos_is_ok().

So rewrite the code to always produce legal positions.

No functional change.
Merge branch 'master' into closed_knight