diff --git a/ChangeLog b/ChangeLog index e7a0bd348a..46d4a9eea9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Mar 11 11:53:35 2013 Nobuyoshi Nakada + + * lib/mkmf.rb (MakeMakefile#dir_config, MakeMakefile#_libdir_basename): + defer use of instance variable until needed. [Bug #8074] + Thu Mar 7 10:42:28 2013 KOSAKI Motohiro * lib/thread.rb (Queue#clear): return self. diff --git a/lib/mkmf.rb b/lib/mkmf.rb index fc12465123..e208515e8a 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -45,6 +45,16 @@ end # correctly compile and link the C extension to ruby and a third-party # library. module MakeMakefile + #### defer until this module become global-state free. + # def self.extended(obj) + # obj.init_mkmf + # super + # end + # + # def initialize(*args, rbconfig: RbConfig, **rest) + # init_mkmf(rbconfig::MAKEFILE_CONFIG, rbconfig::CONFIG) + # super(*args, **rest) + # end ## # The makefile configuration using the defaults from when ruby was built. @@ -1676,7 +1686,7 @@ SRC idir = with_config(target + "-include", idefault) $arg_config.last[1] ||= "${#{target}-dir}/include" ldir = with_config(target + "-lib", ldefault) - $arg_config.last[1] ||= "${#{target}-dir}/#{@libdir_basename}" + $arg_config.last[1] ||= "${#{target}-dir}/#{_libdir_basename}" idirs = idir ? Array === idir ? idir.dup : idir.split(File::PATH_SEPARATOR) : [] if defaults @@ -1693,7 +1703,7 @@ SRC ldirs = ldir ? Array === ldir ? ldir.dup : ldir.split(File::PATH_SEPARATOR) : [] if defaults - ldirs.concat(defaults.collect {|d| "#{d}/#{@libdir_basename}"}) + ldirs.concat(defaults.collect {|d| "#{d}/#{_libdir_basename}"}) ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR) end $LIBPATH = ldirs | $LIBPATH @@ -2378,8 +2388,6 @@ site-install-rb: install-rb $extout ||= nil $extout_prefix ||= nil - @libdir_basename = config["libdir"] && config["libdir"][/\A\$\(exec_prefix\)\/(.*)/, 1] or "lib" - $arg_config.clear dir_config("opt") end @@ -2404,6 +2412,12 @@ MESSAGE end end + private + + def _libdir_basename + @libdir_basename ||= config_string("libdir") {|name| name[/\A\$\(exec_prefix\)\/(.*)/, 1]} || "lib" + end + extend self init_mkmf diff --git a/test/mkmf/test_config.rb b/test/mkmf/test_config.rb new file mode 100644 index 0000000000..c0b2355ee1 --- /dev/null +++ b/test/mkmf/test_config.rb @@ -0,0 +1,14 @@ +require 'test/unit' +require 'mkmf' +require_relative '../ruby/envutil' + +class TestMkmf + class TestConfig < Test::Unit::TestCase + def test_dir_config + bug8074 = '[Bug #8074]' + assert_separately %w[-rmkmf - -- --with-foo-dir=/test/foo], %{ + assert_equal(%w[/test/foo/include /test/foo/lib], dir_config("foo"), #{bug8074.dump}) + } + end + end +end