From d736ed25f446fdf5544b36f5139c69b2cbce961b Mon Sep 17 00:00:00 2001
From: Hilko Bengen <bengen@hilluzination.de>
Date: Thu, 7 Mar 2013 19:59:26 +0100
Subject: [PATCH 03/37] Move Ruby-related checks from autoconf to extconf.rb; add extra check for rb_alloc_func_t
Ruby ships its own config.h which may or may not define the same
relevant constants as our autoconf-generated config.h. Instead of
trying to specify the exact path to the wanted header file we may just
as well simply use Ruby's autoconf-inspired checks and macros.
(cherry picked from commit 0ee24ccf8adb080260a5bb4260593cafe7bc016d)
---
configure.ac | 8 --------
generator/ruby.ml | 3 +++
ruby/ext/guestfs/extconf.rb.in | 4 ++++
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7a6df55..897e303 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1161,14 +1161,6 @@ AS_IF([test "x$enable_ruby" != "xno"],[
AC_MSG_RESULT([-l$libruby])
AC_CHECK_LIB([$libruby],[ruby_init],
[have_libruby=1],[have_libruby=])
-
- dnl Symbols that we substitute when missing.
- AS_IF([test -n "$have_libruby"],[
- old_LIBS="$LIBS"
- LIBS="$LIBS -l$libruby"
- AC_CHECK_FUNCS([rb_hash_lookup])
- LIBS="$old_LIBS"
- ])
],[
AC_MSG_RESULT([not found])
])
diff --git a/generator/ruby.ml b/generator/ruby.ml
index db16e2a..6065875 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -688,6 +688,9 @@ Init__guestfs (void)
e_Error = rb_define_class_under (m_guestfs, \"Error\", rb_eStandardError);
#ifdef HAVE_RB_DEFINE_ALLOC_FUNC
+#ifndef HAVE_TYPE_RB_ALLOC_FUNC_T
+#define rb_alloc_func_t void*
+#endif
rb_define_alloc_func (c_guestfs, (rb_alloc_func_t) ruby_guestfs_create);
#endif
diff --git a/ruby/ext/guestfs/extconf.rb.in b/ruby/ext/guestfs/extconf.rb.in
index e358551..e4c7441 100644
--- a/ruby/ext/guestfs/extconf.rb.in
+++ b/ruby/ext/guestfs/extconf.rb.in
@@ -29,6 +29,10 @@ unless have_library("guestfs", "guestfs_create", "guestfs.h")
raise "libguestfs not found"
end
+have_func("rb_hash_lookup")
+have_func("rb_define_alloc_func")
+have_type("rb_alloc_func_t")
+
$CFLAGS =
"#{$CFLAGS} @CFLAGS@ -DGUESTFS_PRIVATE=1 " <<
"@WARN_CFLAGS@ @WERROR_CFLAGS@"
--
1.7.4.1