Fix makefiles and configure to improve system compatibility

Mostly brought on by using NERSC with Portland compilers.