Index: configure.ac
===================================================================
--- configure.ac.orig	2012-05-14 11:56:04.447928052 +0200
+++ configure.ac	2012-05-14 12:03:02.562272828 +0200
@@ -462,14 +462,17 @@ ac_cv_my_have_ruby="no"
 if test "${enable_ruby}" != "no"; then
   AC_PATH_PROG(RUBY, ruby, no)
   if test "${RUBY}" != "no"; then
-    RUBY_CFLAGS="-I$(ruby -r rbconfig -e 'print Config::CONFIG@<:@"archdir"@:>@')"
+    RUBY_CFLAGS=$(pkg-config --cflags ruby-1.9)
+    if test -z "$RUBY_CFLAGS"; then
+      RUBY_CFLAGS="-I$(ruby -r rbconfig -e 'print Config::CONFIG@<:@"archdir"@:>@')"
+    fi
     RUBY_LIBS="-L$(ruby -r rbconfig -e 'print Config::CONFIG@<:@"libdir"@:>@') -l$(ruby -r rbconfig -e 'print Config::CONFIG@<:@"RUBY_SO_NAME"@:>@')"
-    RUBY_SITEARCHDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"sitearchdir"@:>@'`
-    RUBY_SITELIBDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"sitelibdir"@:>@'`
+    RUBY_VENDORARCHDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"vendorarchdir"@:>@'`
+    RUBY_VENDORLIBDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"vendorlibdir"@:>@'`
     AC_SUBST(RUBY_CFLAGS)
     AC_SUBST(RUBY_LIBS)
-    AC_SUBST(RUBY_SITEARCHDIR)
-    AC_SUBST(RUBY_SITELIBDIR)
+    AC_SUBST(RUBY_VENDORARCHDIR)
+    AC_SUBST(RUBY_VENDORLIBDIR)
     CPPFLAGS="${CPPFLAGS} ${RUBY_CFLAGS}"
     AC_CHECK_HEADERS([ruby.h],
      [ac_cv_my_have_ruby="yes"
Index: ruby/Makefile.am
===================================================================
--- ruby/Makefile.am.orig	2012-05-14 11:56:04.460927441 +0200
+++ ruby/Makefile.am	2012-05-14 11:56:04.474926783 +0200
@@ -1,10 +1,10 @@
 
-rubylibdir = $(RUBY_SITEARCHDIR)
-rubysitedir = $(RUBY_SITELIBDIR)
+rubylibdir = $(RUBY_VENDORARCHDIR)
+rubyvendordir = $(RUBY_VENDORLIBDIR)
 
 if USE_RUBY
 rubylib_LTLIBRARIES = caca.la
-rubysite_DATA = lib/caca.rb
+rubyvendor_DATA = lib/caca.rb
 TESTS = test
 endif
 
Index: ruby/caca-canvas.c
===================================================================
--- ruby/caca-canvas.c.orig	2010-02-16 00:49:40.000000000 +0100
+++ ruby/caca-canvas.c	2012-05-14 12:05:27.623453608 +0200
@@ -274,7 +274,7 @@ static VALUE draw_polyline(VALUE self, V
     int error = 0;
     VALUE v, x, y;
 
-    n = RARRAY(points)->len;
+    n = RARRAY_LEN(points);
 
     ax = (int*)malloc(n*sizeof(int));
     if(!ax)
@@ -290,7 +290,7 @@ static VALUE draw_polyline(VALUE self, V
     for(i=0; i<n; i++)
     {
         v = rb_ary_entry(points, i);
-        if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
+        if((TYPE(v) == T_ARRAY) && (RARRAY_LEN(v) == 2))
         {
             x = rb_ary_entry(v,0);
             y = rb_ary_entry(v,1);
@@ -336,7 +336,7 @@ static VALUE draw_thin_polyline(VALUE se
     int error = 0;
     VALUE v, x, y;
 
-    n = RARRAY(points)->len;
+    n = RARRAY_LEN(points);
 
     ax = (int*)malloc(n*sizeof(int));
     if(!ax)
@@ -352,7 +352,7 @@ static VALUE draw_thin_polyline(VALUE se
     for(i=0; i<n; i++)
     {
         v = rb_ary_entry(points, i);
-        if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
+        if((TYPE(v) == T_ARRAY) && (RARRAY_LEN(v) == 2))
         {
             x = rb_ary_entry(v,0);
             y = rb_ary_entry(v,1);
@@ -459,7 +459,7 @@ static VALUE fill_triangle_textured(VALU
     float cuv[6];
     VALUE v;
 
-    l = RARRAY(coords)->len;
+    l = RARRAY_LEN(coords);
     if(l != 6 && l != 3)
     {
         rb_raise(rb_eArgError, "invalid coords list");
@@ -471,14 +471,14 @@ static VALUE fill_triangle_textured(VALU
             ccoords[i] = NUM2INT(v);
         else
         {
-            if((TYPE(v) != T_ARRAY) || (RARRAY(v)->len != 2))
+            if((TYPE(v) != T_ARRAY) || (RARRAY_LEN(v) != 2))
                 rb_raise(rb_eArgError, "invalid coords list");
             ccoords[2*i] = NUM2INT(rb_ary_entry(v, 0));
             ccoords[2*i+1] = NUM2INT(rb_ary_entry(v, 1));
         }
     }
 
-    l = RARRAY(uv)->len;
+    l = RARRAY_LEN(uv);
     if(l != 6 && l != 3)
     {
         rb_raise(rb_eArgError, "invalid uv list");
@@ -490,7 +490,7 @@ static VALUE fill_triangle_textured(VALU
             cuv[i] = NUM2DBL(v);
         else
         {
-            if((TYPE(v) != T_ARRAY) || (RARRAY(v)->len != 2))
+            if((TYPE(v) != T_ARRAY) || (RARRAY_LEN(v) != 2))
                 rb_raise(rb_eArgError, "invalid uv list");
             ccoords[2*i] = NUM2DBL(rb_ary_entry(v, 0));
             ccoords[2*i+1] = NUM2DBL(rb_ary_entry(v, 1));
@@ -600,7 +600,7 @@ static VALUE render_canvas(VALUE self, V
 static VALUE import_from_memory(VALUE self, VALUE data, VALUE format)
 {
     long int bytes;
-    bytes = caca_import_canvas_from_memory (_SELF, StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
+    bytes = caca_import_canvas_from_memory (_SELF, StringValuePtr(data), RSTRING_LEN(StringValue(data)), StringValuePtr(format));
     if(bytes <= 0)
         rb_raise(rb_eRuntimeError, strerror(errno));
 
@@ -610,7 +610,7 @@ static VALUE import_from_memory(VALUE se
 static VALUE import_area_from_memory(VALUE self, VALUE x, VALUE y, VALUE data, VALUE format)
 {
     long int bytes;
-    bytes = caca_import_area_from_memory (_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
+    bytes = caca_import_area_from_memory (_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(data), RSTRING_LEN(StringValue(data)), StringValuePtr(format));
     if(bytes <= 0)
         rb_raise(rb_eRuntimeError, strerror(errno));
 
Index: ruby/caca-dither.c
===================================================================
--- ruby/caca-dither.c.orig	2010-02-16 00:49:47.000000000 +0100
+++ ruby/caca-dither.c	2012-05-14 12:06:49.420608093 +0200
@@ -48,7 +48,7 @@ static VALUE set_dither_palette(VALUE se
     VALUE v, r, g, b, a;
     int error = 0;
 
-    if(RARRAY(palette)->len != 256)
+    if(RARRAY_LEN(palette) != 256)
     {
         rb_raise(rb_eArgError, "Palette must contain 256 elements");
     }
@@ -84,7 +84,7 @@ static VALUE set_dither_palette(VALUE se
     for(i=0; i<256; i++)
     {
         v = rb_ary_entry(palette, i);
-        if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 4))
+        if((TYPE(v) == T_ARRAY) && (RARRAY_LEN(v) == 4))
         {
             r = rb_ary_entry(v,0);
             g = rb_ary_entry(v,1);
