Description: RE2 now requires C++11
Author: Stefano Rivera <stefanor@debian.org>
Forwarded: https://github.com/mudge/re2/pull/30
Bug-Debian: https://bugs.debian.org/820349

--- a/ext/re2/extconf.rb
+++ b/ext/re2/extconf.rb
@@ -8,12 +8,35 @@ require 'mkmf'
 
 incl, lib = dir_config("re2", "/usr/local/include", "/usr/local/lib")
 
-$CFLAGS << " -Wall -Wextra -funroll-loops"
+# for try_compile: Pass -x c++ to force gcc to compile the test program as C++
+# (as it will end in .c by default).
+cxx_source = "-x c++"
+
+if defined? $CXXFLAGS
+  $CXXFLAGS << " -Wall -Wextra -std=c++11"
+  cxx_source << " #{$CXXFLAGS}"
+else
+  $CFLAGS << " -Wall -Wextra -std=c++11"
+end
 
 have_library("stdc++")
 have_header("stdint.h")
 have_func("rb_str_sublen")
 
+checking_for("C++11 support") do
+  trivial_test = <<SRC
+int main() {
+  return 0;
+}
+SRC
+
+  if !try_compile(trivial_test, cxx_source)
+    abort "Require a compiler with C++11 support"
+  else
+    true
+  end
+end
+
 if have_library("re2")
 
   # Determine which version of re2 the user has installed.
@@ -35,9 +58,7 @@ int main() {
 }
 SRC
 
-    # Pass -x c++ to force gcc to compile the test program
-    # as C++ (as it will end in .c by default).
-    if try_compile(test_re2_match_signature, "-x c++")
+    if try_compile(test_re2_match_signature, cxx_source)
       $defs.push("-DHAVE_ENDPOS_ARGUMENT")
     end
   end
