1 AC_DEFUN([RFX_CHECK_RUBY],
3 AC_PATH_PROG([RUBY], [ruby],,)
11 AC_MSG_CHECKING([for ruby's include directory])
12 if test "x$RUBY" '!=' "x";then
13 rubyinc=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "archdir"))' 2>/dev/null`
14 if test -d $rubyinc;then
15 AC_MSG_RESULT($rubyinc)
17 # If we got a sensible archdir, we also ask ruby to supply us with CPPFLAGS
19 AC_MSG_CHECKING([for ruby's cpp flags])
20 rubycpp=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "CPPFLAGS"))' 2>/dev/null`
21 AC_MSG_RESULT($rubycpp)
23 AC_MSG_CHECKING([for ruby's ld flags])
24 rubyld=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "LIBRUBYARG_SHARED"))' 2>/dev/null`
25 rubyld2=`$RUBY -e 'require "rbconfig";v=Config::expand(Config::CONFIG.send("\x5b\x5d", "LIBRUBY_LDSHARED"));puts v.gsub(/^g?cc/,"")' 2>/dev/null`
26 AC_MSG_RESULT("$rubyld $rubyld2")
28 AC_MSG_CHECKING([for ruby library name])
29 rubylib=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "RUBY_SO_NAME"))' 2>/dev/null`
30 AC_MSG_RESULT($rubylib)
32 RUBY_CPPFLAGS="$rubycpp -I$rubyinc $RUBY_CPPFLAGS"
33 RUBY_LDFLAGS="$rubyld $rubyld2 $RUBY_LDFLAGS"
34 RUBY_INSTALLDIR="$rubyinc"
36 AC_MSG_RESULT('unknown')
39 AC_MSG_RESULT('unknown')
42 #OLDLDFLAGS="$LDFLAGS"
43 #LDFLAGS="$LDFLAGS $RUBY_LDFLAGS"
44 #AC_CHECK_LIB($rubylib, rb_define_method, HAVE_RUBY_LIB=1,)
45 #LDFLAGS="$OLDLDFLAGS"
47 OLDCPPFLAGS="$CPPFLAGS"
48 CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS"
49 AC_CHECK_HEADERS([ruby.h],[HAVE_RUBY_H=1])
50 CPPFLAGS="$OLDCPPFLAGS"
52 AC_MSG_CHECKING([whether we should compile the ruby module])
53 if test "x${HAVE_RUBY_H}" '!=' "x";then
54 #RUBY_LIBS="$RUBY_LIBS -l$rubylib"
56 cat > conftest.c << EOF
59 VALUE foobar_set_foo(VALUE module, VALUE _key, VALUE _value)
65 foobar = rb_define_module("foobar");
66 rb_define_module_function(foobar, "set_foo", foobar_set_foo, 2);
69 int main() {return 0;}
71 ac_link='$CC $SHARED $CPPFLAGS $RUBY_CPPFLAGS $CFLAGS conftest.c $LDFLAGS $RUBY_LDFLAGS $LIBS $RUBY_LIBS -o conftest${SLEXT}'
72 if { (eval echo ruby.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${SLEXT}; then
75 echo "configure: failed program was:" >&5
81 if test "x${RUBY_OK}" '=' "xyes"; then
84 AC_SUBST(RUBY_CPPFLAGS)
85 AC_SUBST(RUBY_LDFLAGS)
86 AC_SUBST(RUBY_INSTALLDIR)