Backport autoconf changes to detect C++11 flags.

Thrift master has autoconf detection for c++11 flags. I just cherry picked those changes so we don't have to trip on this every time we build.