[Libguestfs] [PATCH 2/4] Move Ruby-related checks from autoconf to extconf.rb; add extra check for rb_alloc_func_t

Hilko Bengen bengen at hilluzination.de
Thu Mar 7 18:59:26 UTC 2013


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.
---
 configure.ac                   |    8 --------
 generator/ruby.ml              |    5 +++--
 ruby/ext/guestfs/extconf.rb.in |    4 ++++
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6ecaf0c..6ed3609 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1168,14 +1168,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 27f689b..573f172 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -35,8 +35,6 @@ let rec generate_ruby_c () =
   generate_header CStyle LGPLv2plus;
 
   pr "\
-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -700,6 +698,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 b8bd74a..e049efb 100644
--- a/ruby/ext/guestfs/extconf.rb.in
+++ b/ruby/ext/guestfs/extconf.rb.in
@@ -33,5 +33,9 @@ $CFLAGS =
   "#{$CFLAGS} @CFLAGS@ -DGUESTFS_PRIVATE=1 " <<
   "@WARN_CFLAGS@ @WERROR_CFLAGS@"
 
+have_func("rb_hash_lookup")
+have_func("rb_define_alloc_func")
+have_type("rb_alloc_func_t")
+
 create_header
 create_makefile(extension_name, "@abs_srcdir@")
-- 
1.7.10.4




More information about the Libguestfs mailing list