This will be wrong for most set-up of macOS:
# Establish -lstdc++ or equivalent
if test "x$CXXLIB" == "x"; then
if test "x$CXX" == "xifort"; then
CXXLIB="-cxxlib"
else
CXXLIB="-lstdc++"
fi
fi
As well as some other systems, which happen to use libc++ (but not ifort fortran).