Fix building with gcc-4.7.2.

Set -fpermissive to work around '<::' when building with gcc-4.7.2 and use c++0x/c++11 depending on GCC version.