ext/re2/extconf.rb in re2-0.2.0 vs ext/re2/extconf.rb in re2-0.3.0
- old
+ new
@@ -10,9 +10,36 @@
$CFLAGS << " -Wall -Wextra -funroll-loops"
have_library("stdc++")
if have_library("re2")
+
+ # Determine which version of re2 the user has installed.
+ # Revision d9f8806c004d added an `endpos` argument to the
+ # generic Match() function.
+ #
+ # To test for this, try to compile a simple program that uses
+ # the newer form of Match() and set a flag if it is successful.
+ checking_for("RE2::Match() with endpos argument") do
+ test_re2_match_signature = <<SRC
+#include <re2/re2.h>
+
+int main() {
+ RE2 pattern("test");
+ re2::StringPiece *match;
+ pattern.Match("test", 0, 0, RE2::UNANCHORED, match, 0);
+
+ return 0;
+}
+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++")
+ $defs.push("-DHAVE_ENDPOS_ARGUMENT")
+ end
+ end
+
create_makefile("re2")
else
abort "You must have re2 installed and specified with --with-re2-dir, please see http://code.google.com/p/re2/wiki/Install"
end