On Tue, Jan 21, 2003 at 06:38:00PM +0900, Yukihiro Matsumoto wrote:
> Hi,
> 
> In message "Re: [RFC] mkmf.rb - add files to clean and distclean targets"
>     on 03/01/21, Alexander Bokovoy <a.bokovoy / sam-solutions.net> writes:
> 
> |Would you be interested in seeing this patch? It is pretty compact.
> 
> Show us the code, please.
Attached. The patch is against mid-November CVS (I haven't tried against
current CVS).

For convenience of use in distribution builds I've added 
$vendordir/vendor-specific.rb file which contains following one-liner:

VENDOR_SPECIFIC=true

And in RPM spec files I run extconf.rb as

ruby -rvendor-specific extconf.rb

(this is actually RPM macro %ruby_configure)

After that all extensions automatically get installed into vendor-specific
paths instead of site-install. This allowed to make the patch more simple.


-- 
/ Alexander Bokovoy
---
You can never do just one thing.
		-- Hardin
diff -ur ruby.orig/configure.in ruby/configure.in
--- ruby.orig/configure.in	2002-11-14 15:51:18 +0200
+++ ruby/configure.in	2002-11-19 13:16:32 +0200
@@ -1213,15 +1213,17 @@
     RUBY_LIB_PREFIX="/lib/ruby"
     ;;
   *)
-    RUBY_LIB_PREFIX="${prefix}/lib/ruby"
+    RUBY_LIB_PREFIX="${prefix}/share/ruby"
+    RUBY_LIB_PREFIX2="${prefix}/lib/ruby"
     ;;
 esac
 RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
+RUBY_LIB_PATH2="${RUBY_LIB_PREFIX2}/${MAJOR}.${MINOR}"
 
 AC_ARG_WITH(sitedir,
-	    [  --with-sitedir=DIR      site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
+	    [  --with-sitedir=DIR      site libraries in DIR [PREFIX/share/ruby/site_ruby]],
             [sitedir=$withval],
-            [sitedir='${prefix}/lib/ruby/site_ruby'])
+            [sitedir='${prefix}/share/ruby/site_ruby'])
 SITE_DIR="`eval \"echo ${sitedir}\"`"
 case "$target_os" in
   cygwin*|mingw*|*djgpp*|os2_emx*)
@@ -1231,14 +1233,34 @@
     RUBY_SITE_LIB_PATH="$SITE_DIR";;
 esac
 RUBY_SITE_LIB_PATH2="${RUBY_SITE_LIB_PATH}/${MAJOR}.${MINOR}"
+RUBY_SITE_LIB_PATH3="`echo ${RUBY_SITE_LIB_PATH2}|sed -e 's@/share/@/lib/@;'`"
 
 AC_DEFINE_UNQUOTED(RUBY_LIB, "${RUBY_LIB_PATH}")
 AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
 AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
 
+AC_ARG_WITH(vendordir,
+	    [  --with-vendordir=DIR      vendor libraries in DIR [PREFIX/share/ruby/vendor_ruby]],
+            [vendordir=$withval],
+            [vendordir='${prefix}/share/ruby/vendor_ruby'])
+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}"
+RUBY_VENDOR_LIB_PATH3="`echo ${RUBY_VENDOR_LIB_PATH2}|sed -e 's@/share/@/lib/@;'`"
+
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${RUBY_VENDOR_LIB_PATH}")
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB2, "${RUBY_VENDOR_LIB_PATH2}")
+
 AC_SUBST(arch)dnl
 AC_SUBST(sitearch)dnl
 AC_SUBST(sitedir)dnl
+AC_SUBST(vendordir)dnl
 
 configure_args=$ac_configure_args
 AC_SUBST(configure_args)dnl
@@ -1262,8 +1284,16 @@
   *) sitearch="${arch}" ;;
 esac
 
-AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
-AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
+archdir="${RUBY_LIB_PATH2}/${arch}"
+sitearchdir="${RUBY_SITE_LIB_PATH3}/${sitearch}"
+vendorarchdir="${RUBY_VENDOR_LIB_PATH3}/${sitearch}"
+
+AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${archdir}")
+AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${sitearchdir}")
+AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCHLIB, "${vendorarchdir}")
+AC_SUBST(archdir)dnl
+AC_SUBST(sitearchdir)dnl
+AC_SUBST(vendorarchdir)dnl
 
 AC_ARG_WITH(search-path,
 		[  --with-search-path=DIR specify the additional search path],
diff -ur ruby.orig/mkconfig.rb ruby/mkconfig.rb
--- ruby.orig/mkconfig.rb	2002-10-27 04:16:51 +0200
+++ ruby/mkconfig.rb	2002-11-19 15:33:27 +0200
@@ -102,10 +102,13 @@
 print v_fast, v_others
 print <<EOS
   CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
-  CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
-  CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
+  CONFIG["rubylibdir"] = "$(datadir)/ruby/$(ruby_version)"
   CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
-  CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
+  if defined?(VENDOR_SPECIFIC) && VENDOR_SPECIFIC
+	CONFIG["sitedir"] = "$(vendordir)"
+	CONFIG["sitelibdir"] = "$(vendordir)/$(ruby_version)"
+	CONFIG["sitearchdir"] = CONFIG["vendorarchdir"]
+  end
   CONFIG["compile_dir"] = "#{Dir.pwd}"
   MAKEFILE_CONFIG = {}
   CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
diff -ur ruby.orig/ruby.c ruby/ruby.c
--- ruby.orig/ruby.c	2002-10-29 23:35:28 +0200
+++ ruby/ruby.c	2002-11-19 13:08:15 +0200
@@ -283,11 +283,14 @@
 #endif
 
     ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB2));
+    ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB2));
 #ifdef RUBY_SITE_THIN_ARCHLIB
     ruby_incpush(RUBY_RELATIVE(RUBY_SITE_THIN_ARCHLIB));
 #endif
     ruby_incpush(RUBY_RELATIVE(RUBY_SITE_ARCHLIB));
     ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB));
+    ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_ARCHLIB));
+    ruby_incpush(RUBY_RELATIVE(RUBY_VENDOR_LIB));
 
     ruby_incpush(RUBY_RELATIVE(RUBY_LIB));
 #ifdef RUBY_THIN_ARCHLIB