summaryrefslogtreecommitdiff
path: root/tool/mkconfig.rb
diff options
context:
space:
mode:
authorsho-h <sho-h@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 06:59:31 +0000
committersho-h <sho-h@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 06:59:31 +0000
commit639ccc40ecc398ee805c3a7663d9cd8cda22dfc3 (patch)
tree4cc674038608a472e79351f28f66eef6164d4f98 /tool/mkconfig.rb
parent73b3b10d8db30d3c6b7c53ae0da64c39b55d899f (diff)
* tool/mkconfig.rb: [DOC] add rbconfig documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/mkconfig.rb')
-rwxr-xr-xtool/mkconfig.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
index ee0642c..264dd99 100755
--- a/tool/mkconfig.rb
+++ b/tool/mkconfig.rb
@@ -164,6 +164,9 @@ rubyarchdir = vars.expand(vars["rubyarchdir"] ||= "")
relative_archdir = rubyarchdir.rindex(prefix, 0) ? rubyarchdir[prefix.size..-1] : rubyarchdir
puts %[\
# frozen-string-literal: false
+#
+# The module storing Ruby interpreter configurations on building.
+#
# This file was created by #{mkconfig} when ruby was built. It contains
# build information for ruby which is used e.g. by mkmf to build
# compatible native extensions. Any changes made to this file will be
@@ -174,13 +177,16 @@ module RbConfig
raise "ruby lib version (#{version}) doesn't match executable version (\#{RUBY_VERSION})"
]
+print " # Ruby installed directory.\n"
print " TOPDIR = File.dirname(__FILE__).chomp!(#{relative_archdir.dump})\n"
+print " # DESTDIR on make install. \n"
print " DESTDIR = ", (drive ? "TOPDIR && TOPDIR[/\\A[a-z]:/i] || " : ""), "'' unless defined? DESTDIR\n"
print <<'ARCH' if universal
arch_flag = ENV['ARCHFLAGS'] || ((e = ENV['RC_ARCHS']) && e.split.uniq.map {|a| "-arch #{a}"}.join(' '))
arch = arch_flag && arch_flag[/\A\s*-arch\s+(\S+)\s*\z/, 1]
ARCH
print " universal = #{universal}\n" if universal
+print " # The hash configurations stored.\n"
print " CONFIG = {}\n"
print " CONFIG[\"DESTDIR\"] = DESTDIR\n"
@@ -245,8 +251,41 @@ EOS
print <<EOS
CONFIG["archdir"] = "$(rubyarchdir)"
CONFIG["topdir"] = File.dirname(__FILE__)
+ # Almost same with CONFIG. MAKEFILE_CONFIG has other variable
+ # reference like below.
+ #
+ # MAKEFILE_CONFIG["bindir"] = "$(exec_prefix)/bin"
+ #
+ # The values of this constant is used for creating Makefile.
+ #
+ # require 'rbconfig'
+ #
+ # print <<-END_OF_MAKEFILE
+ # prefix = \#{Config::MAKEFILE_CONFIG['prefix']}
+ # exec_prefix = \#{Config::MAKEFILE_CONFIG['exec_prefix']}
+ # bindir = \#{Config::MAKEFILE_CONFIG['bindir']}
+ # END_OF_MAKEFILE
+ #
+ # => prefix = /usr/local
+ # exec_prefix = $(prefix)
+ # bindir = $(exec_prefix)/bin MAKEFILE_CONFIG = {}
+ #
+ # RbConfig.expand is used for resolving references like above in rbconfig.
+ #
+ # require 'rbconfig'
+ # p Config.expand(Config::MAKEFILE_CONFIG["bindir"])
+ # # => "/usr/local/bin"
MAKEFILE_CONFIG = {}
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
+
+ # call-seq:
+ #
+ # RbConfig.expand(val) -> string
+ # RbConfig.expand(val, config) -> string
+ #
+ # expands variable with given +val+ value.
+ #
+ # RbConfig.expand("$(bindir)") # => /home/foobar/all-ruby/ruby19x/bin
def RbConfig::expand(val, config = CONFIG)
newval = val.gsub(/\\$\\$|\\$\\(([^()]+)\\)|\\$\\{([^{}]+)\\}/) {
var = $&
@@ -269,6 +308,10 @@ print <<EOS
RbConfig::expand(val)
end
+ # call-seq:
+ #
+ # RbConfig.ruby -> path
+ #
# returns the absolute pathname of the ruby command.
def RbConfig.ruby
File.join(