diff -ur ../ruby-1.8.6-p420.org/Makefile.in ./Makefile.in
--- ../ruby-1.8.6-p420.org/Makefile.in	2008-06-04 16:41:47.000000000 +0900
+++ ./Makefile.in	2011-08-25 00:19:40.000000000 +0900
@@ -24,6 +24,8 @@
 arch = @arch@
 sitearch = @sitearch@
 sitedir = @sitedir@
+vendorarch = @vendorarch@
+vendordir = @vendordir@
 
 TESTUI = console
 TESTS =
@@ -98,11 +100,11 @@
 
 miniruby$(EXEEXT):
 		@$(RM) $@
-		$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(MINIOBJS) $(LIBRUBY_A) $(LIBS) $(OUTFLAG)$@
+		$(PURIFY) $(CC) $(XLDFLAGS) $(LDFLAGS) $(MAINLIBS) $(MAINOBJ) $(MINIOBJS) $(LIBRUBY_A) $(LIBS) $(OUTFLAG)$@
 
 $(PROGRAM):
 		@$(RM) $@
-		$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) $(OUTFLAG)$@
+		$(PURIFY) $(CC) $(XLDFLAGS) $(LDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) $(OUTFLAG)$@
 
 # We must `rm' the library each time this rule is invoked because "updating" a
 # MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
diff -ur ../ruby-1.8.6-p420.org/configure ./configure
--- ../ruby-1.8.6-p420.org/configure	2010-09-22 02:26:51.000000000 +0900
+++ ./configure	2011-08-25 00:20:24.000000000 +0900
@@ -591,7 +591,9 @@
 MANTYPE
 NROFF
 configure_args
+vendordir
 sitedir
+vendorarch
 sitearch
 arch
 MAKEFILES
@@ -747,6 +749,7 @@
 enable_shared
 enable_install_doc
 with_sitedir
+with_vendordir
 with_search_path
 with_mantype
 '
@@ -1409,6 +1412,7 @@
   --with-dln-a-out        use dln_a_out if possible
   --with-static-linked-ext link external modules statically
   --with-sitedir=DIR      site libraries in DIR PREFIX/lib/ruby/site_ruby
+  --with-vendordir=DIR      vendor libraries in DIR PREFIX/lib/ruby/vendor_ruby
   --with-search-path=DIR specify the additional search path
   --with-mantype=TYPE specify man page type; TYPE is one of man and doc
 
@@ -9909,6 +9913,33 @@
 
 
 
+# Check whether --with-vendordir was given.
+if test "${with_vendordir+set}" = set; then :
+  withval=$with_vendordir; vendordir=$withval
+else
+  vendordir='${prefix}/lib/ruby/vendor_ruby'
+fi
+
+VENDOR_DIR="`eval \"echo ${vendordir}\"`"
+case "$target_os" in
+  cygwin*|mingw*|*djgpp*|os2_emx*)
+    RUBY_VENDOR_LIB_PATH="`expr "$VENDOR_DIR" : "$prefix\(/.*\)"`" ||
+    RUBY_VENDOR_LIB_PATH="$VENDOR_DIR";;
+  *)
+    RUBY_VENDOR_LIB_PATH="$VENDOR_DIR";;
+esac
+RUBY_VENDOR_LIB_PATH2="${RUBY_VENDOR_LIB_PATH}/${MAJOR}.${MINOR}"
+
+cat >>confdefs.h <<_ACEOF
+#define RUBY_VENDOR_LIB "${RUBY_VENDOR_LIB_PATH}"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define RUBY_VENDOR_LIB2 "${RUBY_VENDOR_LIB_PATH2}"
+_ACEOF
+
+
+
 configure_args=$ac_configure_args
 
 if test "$fat_binary" != no ; then
@@ -9924,6 +9955,10 @@
 _ACEOF
 
     cat >>confdefs.h <<_ACEOF
+#define RUBY_VENDOR_THIN_ARCHLIB "${RUBY_VENDOR_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}"
+_ACEOF
+
+    cat >>confdefs.h <<_ACEOF
 #define RUBY_PLATFORM __ARCHITECTURE__ "-${target_os}"
 _ACEOF
 
@@ -9936,8 +9971,10 @@
 fi
 
 case "$target_os" in
-  mingw*) sitearch="i386-$rb_cv_msvcrt" ;;
-  *) sitearch="${arch}" ;;
+  mingw*) sitearch="i386-$rb_cv_msvcrt"
+  		  vendorarch="i386-$rb_cv_msvcrt" ;;
+  *) sitearch="${arch}"
+     vendorarch="${arch}" ;;
 esac
 
 cat >>confdefs.h <<_ACEOF
@@ -9948,6 +9985,10 @@
 #define RUBY_SITE_ARCHLIB "${RUBY_SITE_LIB_PATH2}/${sitearch}"
 _ACEOF
 
+cat >>confdefs.h <<_ACEOF
+#define RUBY_VENDOR_ARCHLIB "${RUBY_VENDOR_LIB_PATH2}/${vendorarch}"
+_ACEOF
+
 
 
 # Check whether --with-search-path was given.
Only in .: configure.orig
diff -ur ../ruby-1.8.6-p420.org/instruby.rb ./instruby.rb
--- ../ruby-1.8.6-p420.org/instruby.rb	2007-02-13 08:01:19.000000000 +0900
+++ ./instruby.rb	2011-08-25 00:19:48.000000000 +0900
@@ -162,6 +162,8 @@
 archlibdir = CONFIG["archdir"]
 sitelibdir = CONFIG["sitelibdir"]
 sitearchlibdir = CONFIG["sitearchdir"]
+vendorlibdir = CONFIG["vendorlibdir"]
+vendorarchlibdir = CONFIG["vendorarchdir"]
 mandir = File.join(CONFIG["mandir"], "man")
 configure_args = Shellwords.shellwords(CONFIG["configure_args"])
 enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
@@ -202,7 +204,7 @@
   extout = "#$extout"
   install?(:ext, :arch, :'ext-arch') do
     puts "installing extension objects"
-    makedirs [archlibdir, sitearchlibdir]
+    makedirs [archlibdir, sitearchlibdir, vendorarchlibdir]
     if noinst = CONFIG["no_install_files"] and noinst.empty?
       noinst = nil
     end
@@ -210,7 +212,7 @@
   end
   install?(:ext, :comm, :'ext-comm') do
     puts "installing extension scripts"
-    makedirs [rubylibdir, sitelibdir]
+    makedirs [rubylibdir, sitelibdir, vendorlibdir]
     install_recursive("#{extout}/common", rubylibdir)
   end
 end
diff -ur ../ruby-1.8.6-p420.org/lib/mkmf.rb ./lib/mkmf.rb
--- ../ruby-1.8.6-p420.org/lib/mkmf.rb	2009-03-31 18:19:39.000000000 +0900
+++ ./lib/mkmf.rb	2011-08-25 00:20:02.000000000 +0900
@@ -51,6 +51,9 @@
 $sitedir = CONFIG["sitedir"]
 $sitelibdir = CONFIG["sitelibdir"]
 $sitearchdir = CONFIG["sitearchdir"]
+$vendordir = CONFIG["vendordir"]
+$vendorlibdir = CONFIG["vendorlibdir"]
+$vendorarchdir = CONFIG["vendorarchdir"]
 
 $mswin = /mswin/ =~ RUBY_PLATFORM
 $bccwin = /bccwin/ =~ RUBY_PLATFORM
@@ -417,7 +420,7 @@
 
 def try_func(func, libs, headers = nil, &b)
   headers = cpp_include(headers)
-  try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
+  try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
 #{COMMON_HEADERS}
 #{headers}
 /*top*/
@@ -429,6 +432,11 @@
 int main() { return 0; }
 int t() { #{func}(); return 0; }
 SRC
+int #{func}();
+/*top*/
+int main() { return 0; }
+int t() { #{func}(); return 0; }
+SRC
 end
 
 def try_var(var, headers = nil, &b)
@@ -1121,6 +1129,7 @@
 RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']}
 arch = #{CONFIG['arch']}
 sitearch = #{CONFIG['sitearch']}
+vendorarch = #{CONFIG['vendorarch']}
 ruby_version = #{Config::CONFIG['ruby_version']}
 ruby = #{$ruby}
 RUBY = $(ruby#{sep})
Only in ./lib: mkmf.rb.orig
diff -ur ../ruby-1.8.6-p420.org/mkconfig.rb ./mkconfig.rb
--- ../ruby-1.8.6-p420.org/mkconfig.rb	2008-06-08 01:37:10.000000000 +0900
+++ ./mkconfig.rb	2011-08-25 00:19:55.000000000 +0900
@@ -143,6 +143,14 @@
   CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
   CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
   CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
+  CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
+  CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(vendorarch)"
+  if defined?(VENDOR_SPECIFIC) && VENDOR_SPECIFIC
+ 	CONFIG["sitearch"] = CONFIG["vendorarch"]
+ 	CONFIG["sitedir"] = CONFIG["vendordir"]
+ 	CONFIG["sitelibdir"] = CONFIG["vendorlibdir"]
+ 	CONFIG["sitearchdir"] = CONFIG["vendorarchdir"]
+  end
   CONFIG["topdir"] = File.dirname(__FILE__)
   MAKEFILE_CONFIG = {}
   CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
diff -ur ../ruby-1.8.6-p420.org/ruby.c ./ruby.c
--- ../ruby-1.8.6-p420.org/ruby.c	2008-07-10 18:36:08.000000000 +0900
+++ ./ruby.c	2011-08-25 00:20:12.000000000 +0900
@@ -322,6 +322,13 @@
     incpush(RUBY_RELATIVE(RUBY_SITE_ARCHLIB));
     incpush(RUBY_RELATIVE(RUBY_SITE_LIB));
 
+    incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB2));
+#ifdef RUBY_VENDOR_THIN_ARCHLIB
+    incpush(RUBY_RELATIVE(RUBY_VENDOR_THIN_ARCHLIB));
+#endif
+    incpush(RUBY_RELATIVE(RUBY_VENDOR_ARCHLIB));
+    incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB));
+    
     incpush(RUBY_RELATIVE(RUBY_LIB));
 #ifdef RUBY_THIN_ARCHLIB
     incpush(RUBY_RELATIVE(RUBY_THIN_ARCHLIB));
