>From 0b550dc95b2b0f35e5cad203d5b0af6d0f3a61ab Mon Sep 17 00:00:00 2001
From: Phil Pirozhkov <philip.pirozhkov@ontarget-group.com>
Date: Tue, 10 Apr 2012 18:18:07 +0400
Subject: [PATCH] rubymod build fixed and unified for ruby 1.8/1.9

---
 libs/esl/ruby/Makefile  |    6 ++----
 libs/esl/ruby/cflags.rb |    8 ++++++++
 2 files changed, 10 insertions(+), 4 deletions(-)
 create mode 100644 libs/esl/ruby/cflags.rb

diff --git a/libs/esl/ruby/Makefile b/libs/esl/ruby/Makefile
index 227e9f3..21ed211 100644
--- a/libs/esl/ruby/Makefile
+++ b/libs/esl/ruby/Makefile
@@ -1,6 +1,5 @@
-## no idea how to simply ask ruby which one to use
-LOCAL_CFLAGS=-I$(shell ruby -e 'require "rbconfig"; puts RbConfig::CONFIG["topdir"]')
-LOCAL_LDFLAGS=$(shell ruby -e 'require "rbconfig"; puts RbConfig::CONFIG["LIBS"]')
+LOCAL_LDFLAGS=$(shell ruby -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBYARG"]')
+LOCAL_CFLAGS=$(shell ruby cflags.rb)
 
 all: ESL.so
 
@@ -20,4 +19,3 @@ swigclean:
 	rm -f esl_wrap.* ESL.so
 
 reswig:	swigclean esl_wrap.cpp
-
diff --git a/libs/esl/ruby/cflags.rb b/libs/esl/ruby/cflags.rb
new file mode 100644
index 0000000..45c10b1
--- /dev/null
+++ b/libs/esl/ruby/cflags.rb
@@ -0,0 +1,8 @@
+require 'rbconfig'
+
+cflags = if RUBY_VERSION =~ /1.9/ then
+  "-I#{RbConfig::CONFIG['rubyhdrdir']} -I#{RbConfig::CONFIG['rubyhdrdir']}/#{RbConfig::CONFIG['arch']}"
+else
+  "-I#{RbConfig::CONFIG["topdir"]}"
+end
+puts cflags
\ No newline at end of file
-- 
1.7.9.6

