detect ruby in configure script
authorMatthias Kramm <kramm@quiss.org>
Wed, 24 Feb 2010 02:14:31 +0000 (18:14 -0800)
committerMatthias Kramm <kramm@quiss.org>
Wed, 24 Feb 2010 02:15:34 +0000 (18:15 -0800)
Makefile.common.in
configure
configure.in
lib/ruby/Makefile.in [new file with mode: 0644]
lib/ruby/extconf.rb
lib/ruby/gfx.c
lib/ruby/test.rb
m4/ruby.m4 [new file with mode: 0644]

index f879212..1f0ad79 100644 (file)
@@ -22,9 +22,14 @@ SLL=$(LIBTOOL) --mode=link @CXX@ $(DEFS) -rpath $(libdir)
 LIBS= @LDFLAGS@ @LIBS@
 CXXLIBS=@CXXLIBS@
 transform = @program_transform_name@
+CPPFLAGS=@CPPFLAGS@
+
 PYTHON_LIB=@PYTHON_LIB@
 PYTHON_INCLUDES=@PYTHON_INCLUDES@
-CPPFLAGS=@CPPFLAGS@
+
+RUBY_CPPFLAGS=@RUBY_CPPFLAGS@
+RUBY_LDFLAGS=@RUBY_LDFLAGS@
+RUBY_LIBS=@RUBY_LIBS@
 
 # libtool stuff
 OBJEXT=@OBJEXT@
index 4f67cc7..cdafce4 100755 (executable)
--- a/configure
+++ b/configure
@@ -644,6 +644,10 @@ PDF2PDF
 DEVICE_PDF
 LIBPDF
 PDF2SWF
+RUBY_LDFLAGS
+RUBY_CPPFLAGS
+RUBY_LIBS
+RUBY
 HAVE_PYTHON_IMAGING
 PYTHON_INCLUDES
 PYTHON_LIB
@@ -10106,7 +10110,303 @@ if test "x$PYTHON_OK" '!=' "xyes";then
     # fail silently- the most users won't have any need for the
     # python interface anyway
 else
-    pythonrfxswf="lib/python/Makefile"
+    pythongfx="lib/python/Makefile"
+fi
+
+# ------------------------------------------------------------------
+
+
+# Extract the first word of "ruby", so it can be a program name with args.
+set dummy ruby; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_RUBY+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  case $RUBY in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_RUBY="$RUBY" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_RUBY="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+RUBY=$ac_cv_path_RUBY
+if test -n "$RUBY"; then
+  { $as_echo "$as_me:$LINENO: result: $RUBY" >&5
+$as_echo "$RUBY" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+RUBY_CPPFLAGS=""
+RUBY_LDFLAGS=""
+RUBY_LIBS=""
+
+rubylib=ruby18
+
+{ $as_echo "$as_me:$LINENO: checking for ruby's include directory" >&5
+$as_echo_n "checking for ruby's include directory... " >&6; }
+if test "x$RUBY" '!=' "x";then
+    rubyinc=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "archdir"))' 2>/dev/null`
+    if test -d $rubyinc;then
+       { $as_echo "$as_me:$LINENO: result: $rubyinc" >&5
+$as_echo "$rubyinc" >&6; }
+
+       # If we got a sensible archdir, we also ask ruby to supply us with CPPFLAGS
+       # and LDFLAGS.
+       { $as_echo "$as_me:$LINENO: checking for ruby's cpp flags" >&5
+$as_echo_n "checking for ruby's cpp flags... " >&6; }
+       rubycpp=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "CPPFLAGS"))' 2>/dev/null`
+       { $as_echo "$as_me:$LINENO: result: $rubycpp" >&5
+$as_echo "$rubycpp" >&6; }
+
+       { $as_echo "$as_me:$LINENO: checking for ruby's ld flags" >&5
+$as_echo_n "checking for ruby's ld flags... " >&6; }
+       rubyld=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "LIBRUBYARG_SHARED"))' 2>/dev/null`
+       { $as_echo "$as_me:$LINENO: result: $rubyld" >&5
+$as_echo "$rubyld" >&6; }
+
+       { $as_echo "$as_me:$LINENO: checking for ruby library name" >&5
+$as_echo_n "checking for ruby library name... " >&6; }
+       rubylib=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "RUBY_SO_NAME"))' 2>/dev/null`
+       { $as_echo "$as_me:$LINENO: result: $rubylib" >&5
+$as_echo "$rubylib" >&6; }
+
+       RUBY_CPPFLAGS="$rubycpp -I$rubyinc $RUBY_CPPFLAGS"
+       RUBY_LDFLAGS="$rubyld $RUBY_LDFLAGS"
+    else
+       { $as_echo "$as_me:$LINENO: result: 'unknown'" >&5
+$as_echo "'unknown'" >&6; }
+    fi
+else
+    { $as_echo "$as_me:$LINENO: result: 'unknown'" >&5
+$as_echo "'unknown'" >&6; }
+fi
+
+#OLDLDFLAGS="$LDFLAGS"
+#LDFLAGS="$LDFLAGS $RUBY_LDFLAGS"
+#AC_CHECK_LIB($rubylib, rb_define_method, HAVE_RUBY_LIB=1,)
+#LDFLAGS="$OLDLDFLAGS"
+
+OLDCPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS"
+
+for ac_header in ruby.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+                $as_echo "$as_val"'`
+              { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+                $as_echo "$as_val"'`
+              { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+
+fi
+as_val=`eval 'as_val=${'$as_ac_Header'}
+                $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ HAVE_RUBY_H=1
+fi
+
+done
+
+CPPFLAGS="$OLDCPPFLAGS"
+
+{ $as_echo "$as_me:$LINENO: checking whether we should compile the ruby module" >&5
+$as_echo_n "checking whether we should compile the ruby module... " >&6; }
+if test "x${HAVE_RUBY_H}" '!=' "x";then
+    #RUBY_LIBS="$RUBY_LIBS -l$rubylib"
+
+    cat > conftest.c << EOF
+#include <ruby.h>
+static VALUE foobar;
+VALUE foobar_set_foo(VALUE module, VALUE _key, VALUE _value)
+{
+    return Qnil;
+}
+int Init_foobar()
+{
+    foobar = rb_define_module("foobar");
+    rb_define_module_function(foobar, "set_foo", foobar_set_foo, 2);
+}
+int main() {return 0;}
+EOF
+    ac_link='$CC $SHARED $CPPFLAGS $RUBY_CPPFLAGS $CFLAGS conftest.c $LDFLAGS $RUBY_LDFLAGS $LIBS $RUBY_LIBS -o conftest${ac_exeext}'
+    if { (eval echo ruby.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+       RUBY_OK=yes
+    else
+        echo "configure: failed program was:" >&5
+        cat conftest.c >&5
+    fi
+    rm -f conftest*
+fi
+
+if test "x${RUBY_OK}" '=' "xyes"; then
+    { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+
+
+else
+    { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+    RUBY_CPPFLAGS=""
+    RUBY_LDFLAGS=""
+    RUBY_LIBS=""
+fi
+
+
+if test "x$RUBY_OK" '!=' "xyes";then
+    echo all install uninstall clean: > lib/ruby/Makefile
+    # fail silently- the most users won't have any need for the
+    # ruby interface anyway
+else
+    rubygfx="lib/python/Makefile"
 fi
 
 # ------------------------------------------------------------------
@@ -10258,7 +10558,7 @@ fi
 
 if test -f "release.in"; then release_in="./release"; fi
 if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
-FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythonrfxswf} ${lame_makefile} lib/readers/Makefile"
+FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythongfx} ${lame_makefile} lib/readers/Makefile"
 ac_config_files="$ac_config_files ${FILES}"
 
 cat >confcache <<\_ACEOF
index 732e2ce..165d7e1 100644 (file)
@@ -382,7 +382,19 @@ if test "x$PYTHON_OK" '!=' "xyes";then
     # fail silently- the most users won't have any need for the
     # python interface anyway
 else
-    pythonrfxswf="lib/python/Makefile"
+    pythongfx="lib/python/Makefile"
+fi
+
+# ------------------------------------------------------------------
+
+RFX_CHECK_RUBY
+
+if test "x$RUBY_OK" '!=' "xyes";then
+    echo all install uninstall clean: > lib/ruby/Makefile
+    # fail silently- the most users won't have any need for the
+    # ruby interface anyway
+else
+    rubygfx="lib/python/Makefile"
 fi
 
 # ------------------------------------------------------------------
@@ -571,7 +583,7 @@ AH_BOTTOM([
 
 if test -f "release.in"; then release_in="./release"; fi
 if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
-FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythonrfxswf} ${lame_makefile} lib/readers/Makefile"
+FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythongfx} ${lame_makefile} lib/readers/Makefile"
 AC_OUTPUT(${FILES})
 
 dnl new autoconf
diff --git a/lib/ruby/Makefile.in b/lib/ruby/Makefile.in
new file mode 100644 (file)
index 0000000..bac1a5a
--- /dev/null
@@ -0,0 +1,20 @@
+top_builddir = ../..
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+include ../../Makefile.common
+
+all: gfx.$(SLEXT)
+
+gfx.$(O): gfx.c 
+       $(C) $(RUBY_CPPFLAGS) -Wall -Wno-unused -fPIC -c gfx.c -o gfx.$(O)
+
+GFX_DEPS=../libgfxpdf$(A) ../libgfxswf$(A)  ../librfxswf$(A) ../libgfx$(A) ../libocr$(A) ../libbase$(A) 
+gfx.$(SLEXT): gfx.$(O) $(GFX_DEPS) Makefile
+       $(L) $(RUBY_LDFLAGS) $(SHARED) gfx.$(O) -o gfx.$(SLEXT) $(GFX_DEPS) $(PYTHON_LIB) $(LIBS) $(RUBY_LIBS) $(CXXLIBS)
+
+clean:
+       rm -f *.o *.$(O) *.$(SLEXT) *.so
+
+install:
+
+.PHONY: all
index 5a6d41c..513f4a2 100644 (file)
@@ -2,12 +2,12 @@ require 'mkmf'
 require 'rbconfig'
 
 $LDFLAGS << " -L.. "
-$LIBS << " -lstdc++ "
+$LIBS << " -lm -lstdc++ "
 
 dir_config 'gfx'
 
 have_library("z", "deflate")
-have_library("m", "sqrt")
+have_library("zzip", "zzip_get_default_io")
 have_library("jpeg", "jpeg_write_raw_data")
 have_library("fftw3", "fftw_plan_dft_r2c_2d")
 have_library("freetype", "FT_Init_FreeType")
@@ -15,7 +15,7 @@ have_library("fontconfig", "FcInit")
 have_library("base", "ringbuffer_init")
 have_library("gfx", "gfxfontlist_create")
 have_library("gfxpdf", "gfxsource_pdf_create")
-have_library("rfxswf", "swf_ReadSWF")
+have_library("rfxswf", "swf_uncgi")
 have_library("gfxswf", "gfxdevice_swf_init")
 
 create_makefile('gfx')
index 9c3af37..648e902 100644 (file)
@@ -9,6 +9,7 @@
 #include "../pdf/pdf.h"
 #include "../mem.h"
 #include "../types.h"
+#include "../log.h"
 
 #define RUBY_GFX_VERSION  "0.9.0"
 
@@ -87,7 +88,7 @@ static VALUE doc_get_page(VALUE cls, VALUE _nr)
     page->doc = doc;
     if(!page->page) {
        rb_raise(rb_eArgError, "No page %d in document", nr);
-       return;
+       return Qnil;
     }
     return v;
 }
@@ -496,6 +497,10 @@ static VALUE convert_font(gfxfont_t*font)
     }
     return v2;
 }
+static VALUE convert_gradient(gfxgradient_t*gradient)
+{
+    return Qnil; //TODO
+}
 #define HEAD \
     device_internal_t*i = (device_internal_t*)dev->internal; \
     VALUE v = i->v;
index dc96d1b..afccbc9 100644 (file)
@@ -1,7 +1,5 @@
 require 'gfx'
 
-pdf = GFX::PDF.new('segfault.pdf')
-
 class TestRender < GFX::Device
     def startpage(width,height)
         puts "startpage(#{width},#{height})"
@@ -41,6 +39,8 @@ class TestRender < GFX::Device
     end
 end
 
+pdf = GFX::PDF.new('abcdef.pdf')
+
 r = TestRender.new
 pdf.each_page do |page|
     puts "#{page.nr} #{page.width}x#{page.height}"
diff --git a/m4/ruby.m4 b/m4/ruby.m4
new file mode 100644 (file)
index 0000000..f64d6e6
--- /dev/null
@@ -0,0 +1,89 @@
+AC_DEFUN([RFX_CHECK_RUBY],
+[
+AC_PATH_PROG([RUBY], [ruby],,)
+
+RUBY_CPPFLAGS=""
+RUBY_LDFLAGS=""
+RUBY_LIBS=""
+
+rubylib=ruby18
+
+AC_MSG_CHECKING([for ruby's include directory])
+if test "x$RUBY" '!=' "x";then
+    rubyinc=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "archdir"))' 2>/dev/null`
+    if test -d $rubyinc;then
+       AC_MSG_RESULT($rubyinc)
+
+       # If we got a sensible archdir, we also ask ruby to supply us with CPPFLAGS
+       # and LDFLAGS.
+       AC_MSG_CHECKING([for ruby's cpp flags])
+       rubycpp=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "CPPFLAGS"))' 2>/dev/null`
+       AC_MSG_RESULT($rubycpp)
+       
+       AC_MSG_CHECKING([for ruby's ld flags])
+       rubyld=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "LIBRUBYARG_SHARED"))' 2>/dev/null`
+       AC_MSG_RESULT($rubyld)
+       
+       AC_MSG_CHECKING([for ruby library name])
+       rubylib=`$RUBY -e 'require "rbconfig";puts Config::expand(Config::CONFIG.send("\x5b\x5d", "RUBY_SO_NAME"))' 2>/dev/null`
+       AC_MSG_RESULT($rubylib)
+
+       RUBY_CPPFLAGS="$rubycpp -I$rubyinc $RUBY_CPPFLAGS"
+       RUBY_LDFLAGS="$rubyld $RUBY_LDFLAGS"
+    else
+       AC_MSG_RESULT('unknown')
+    fi
+else
+    AC_MSG_RESULT('unknown')
+fi
+
+#OLDLDFLAGS="$LDFLAGS"
+#LDFLAGS="$LDFLAGS $RUBY_LDFLAGS"
+#AC_CHECK_LIB($rubylib, rb_define_method, HAVE_RUBY_LIB=1,)
+#LDFLAGS="$OLDLDFLAGS"
+
+OLDCPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $RUBY_CPPFLAGS"
+AC_CHECK_HEADERS([ruby.h],[HAVE_RUBY_H=1])
+CPPFLAGS="$OLDCPPFLAGS"
+
+AC_MSG_CHECKING([whether we should compile the ruby module])
+if test "x${HAVE_RUBY_H}" '!=' "x";then
+    #RUBY_LIBS="$RUBY_LIBS -l$rubylib"
+
+    cat > conftest.c << EOF
+#include <ruby.h>
+static VALUE foobar;
+VALUE foobar_set_foo(VALUE module, VALUE _key, VALUE _value)
+{
+    return Qnil;
+}
+int Init_foobar()
+{
+    foobar = rb_define_module("foobar");
+    rb_define_module_function(foobar, "set_foo", foobar_set_foo, 2);
+}
+int main() {return 0;}
+EOF
+    ac_link='$CC $SHARED $CPPFLAGS $RUBY_CPPFLAGS $CFLAGS conftest.c $LDFLAGS $RUBY_LDFLAGS $LIBS $RUBY_LIBS -o conftest${ac_exeext}'
+    if { (eval echo ruby.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+       RUBY_OK=yes
+    else
+        echo "configure: failed program was:" >&5
+        cat conftest.c >&5
+    fi
+    rm -f conftest*
+fi
+
+if test "x${RUBY_OK}" '=' "xyes"; then 
+    AC_MSG_RESULT([yes])
+    AC_SUBST(RUBY_LIBS)
+    AC_SUBST(RUBY_CPPFLAGS)
+    AC_SUBST(RUBY_LDFLAGS)
+else
+    AC_MSG_RESULT([no])
+    RUBY_CPPFLAGS=""
+    RUBY_LDFLAGS=""
+    RUBY_LIBS=""
+fi
+])