diff --git a/common.mk b/common.mk index cc67e67db8..6a395e3ae6 100644 --- a/common.mk +++ b/common.mk @@ -863,7 +863,8 @@ $(arch:noarch=ignore)-fake.rb: $(srcdir)/template/fake.rb.in $(tooldir)/generic_ $(ECHO) generating $@ $(Q) $(CPP) -DRUBY_EXPORT $(INCFLAGS) $(CPPFLAGS) "$(srcdir)/version.c" | \ $(BOOTSTRAPRUBY) "$(tooldir)/generic_erb.rb" -o $@ "$(srcdir)/template/fake.rb.in" \ - i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)" + i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)" \ + LIBPATHENV="$(LIBPATHENV)" PRELOADENV="$(PRELOADENV)" LIBRUBY_SO="$(LIBRUBY_SO)" noarch-fake.rb: # prerequisite of yes-fake $(Q) exit > $@ diff --git a/template/Makefile.in b/template/Makefile.in index 85a907dcd5..93fa02d9d7 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -127,6 +127,9 @@ BUILTIN_TRANSSRCS = @BUILTIN_TRANSSRCS@ BUILTIN_TRANSOBJS = @BUILTIN_TRANSOBJS@ POSTLINK = @POSTLINK@ +LIBPATHENV = @LIBPATHENV@ +PRELOADENV = @PRELOADENV@ + RUBY_BASE_NAME=@RUBY_BASE_NAME@ RUBY_API_VERSION=@RUBY_API_VERSION@ RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@ diff --git a/template/fake.rb.in b/template/fake.rb.in index e7706a88ae..5e52d95594 100644 --- a/template/fake.rb.in +++ b/template/fake.rb.in @@ -52,6 +52,9 @@ class Object % } end builddir = File.dirname(File.expand_path(__FILE__)) +libpathenv = libpathenv = "<%=arg['LIBPATHENV']%>" +preloadenv = preloadenv = "<%=arg['PRELOADENV']%>" +libruby_so = libruby_so = "<%=arg['LIBRUBY_SO']%>" srcdir = "<%=arg['srcdir']%>" top_srcdir = File.realpath(srcdir, builddir) fake = File.join(top_srcdir, "tool/fake.rb") diff --git a/tool/fake.rb b/tool/fake.rb index 91dfb041c4..195ae0a5a0 100644 --- a/tool/fake.rb +++ b/tool/fake.rb @@ -9,6 +9,14 @@ class File end end +[[libpathenv, "."], [preloadenv, libruby_so]].each do |env, path| + env or next + e = ENV[env] or next + e = e.split(File::PATH_SEPARATOR) + e.delete(File.expand_path(path, builddir)) or next + ENV[env] = (e.join(File::PATH_SEPARATOR) unless e.empty?) +end + static = !!(defined?($static) && $static) $:.unshift(builddir) posthook = proc do