Search for libm regardless of configure flags.

Also switch to checking for sin(), since that's what's needed elsewhere.
There are places in the code that require sin() from libm.