generalize pkg-config check
waf: some more tests and cleanups
waf: use arrays instead of hashes to preserve deps ordering
waf: remove iteration hack in check_pkg_config
add check for -lm
waf: add nanosleep check