libscrypt check fails when libscrypt requires libm

See legacy/trac#19161 (moved) for background.

When libscrypt requires libm, our current check fails to detect libscrypt. This caused a failure to build (legacy/trac#19161 (moved)), which we fixed by not calling libscrypt_scrypt() unless that function was actually found.

But we still have a problem here: We would like to detect libscrypt in these cases, and actually use it as appropriate.

Isis and I wrote a solution in isis's branch bug19161_028, but it has some remaining infelicities, I think. Will transcribe those in a comment.