configure: Move toolchain dependency declarations to a more appropriate place
configure: Split host and target libc detection
configure: Move log2 dependency declaration to a place it takes effect

It was incorrectly moved in c869fcdeac3b7cd71a852b928902daadeca55685.
alsdec: check block length

Fix writing over the end

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Addresses: CVE-2013-0845