diff options
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | generator/generator_ruby.ml | 16 | ||||
-rw-r--r-- | ruby/Rakefile.in | 2 |
3 files changed, 23 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 65a03b86..ead3f9f9 100644 --- a/configure.ac +++ b/configure.ac @@ -981,7 +981,13 @@ AS_IF([test "x$enable_ruby" != "xno"],[ AC_CHECK_PROG([RAKE],[rake],[rake],[no]) AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=]) AC_SUBST([RAKE]) + AS_IF([test -n "$HAVE_LIBRUBY"],[ + old_LIBS="$LIBS" + LIBS="$LIBS -lruby" + AC_CHECK_FUNCS([rb_hash_lookup]) + LIBS="$old_LIBS" ]) +]) AM_CONDITIONAL([HAVE_RUBY], [test "x$RAKE" != "xno" && test -n "$HAVE_LIBRUBY"]) diff --git a/generator/generator_ruby.ml b/generator/generator_ruby.ml index d438a892..742a0cc4 100644 --- a/generator/generator_ruby.ml +++ b/generator/generator_ruby.ml @@ -35,6 +35,8 @@ let rec generate_ruby_c () = generate_header CStyle LGPLv2plus; pr "\ +#include <config.h> + #include <stdio.h> #include <stdlib.h> #include <stdint.h> @@ -59,6 +61,20 @@ let rec generate_ruby_c () = #define RSTRING_PTR(r) (RSTRING((r))->ptr) #endif +/* For RHEL 5 (Ruby 1.8.5) */ +#ifndef HAVE_RB_HASH_LOOKUP +VALUE +rb_hash_lookup (VALUE hash, VALUE key) +{ + VALUE val; + + if (!st_lookup (RHASH(hash)->tbl, key, &val)) + return Qnil; + + return val; +} +#endif /* !HAVE_RB_HASH_LOOKUP */ + static VALUE m_guestfs; /* guestfs module */ static VALUE c_guestfs; /* guestfs_h handle */ static VALUE e_Error; /* used for all errors */ diff --git a/ruby/Rakefile.in b/ruby/Rakefile.in index 9ae993bc..84a22034 100644 --- a/ruby/Rakefile.in +++ b/ruby/Rakefile.in @@ -38,7 +38,7 @@ CLOBBER.include [ "@builddir@/config.save", "@builddir@/ext/**/mkmf.log", # Build locally file MAKEFILE => EXT_CONF do |t| - unless sh "top_srcdir=$(pwd)/@top_srcdir@; top_builddir=$(pwd)/@top_builddir@; export ARCHFLAGS=\"-arch $(uname -m)\"; mkdir -p @builddir@/ext/guestfs; cd @builddir@/ext/guestfs; @RUBY@ #{EXT_CONF} --with-_guestfs-include=$top_srcdir/src --with-_guestfs-lib=$top_builddir/src/.libs" + unless sh "top_srcdir=$(pwd)/@top_srcdir@; top_builddir=$(pwd)/@top_builddir@; export ARCHFLAGS=\"-arch $(uname -m)\"; mkdir -p @builddir@/ext/guestfs; cd @builddir@/ext/guestfs; @RUBY@ #{EXT_CONF} --with-_guestfs-include=$top_srcdir/src:$top_builddir --with-_guestfs-lib=$top_builddir/src/.libs" $stderr.puts "Failed to run extconf" break end |