Refactor handling of /lib64 etc. cases, move out of sysdeps/gnu/configure.ac.