Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 203 lines (184 sloc) 5.578 kb
8884ab5 matz - nakada win32 patch
matz authored
1 #!./miniruby -s
986c389 Initial revision
matz authored
2
4e44bd0 @eban * mkconfig.rb: initialize global variables to avoid warnings.
eban authored
3 # avoid warnings with -d.
4 $install_name ||= nil
5 $so_name ||= nil
6
8775c5a @nobu * mkconfig.rb: no longer embed srcdir and compile_dir into
nobu authored
7 srcdir = File.dirname(__FILE__)
4abc782 @nobu * mkconfig.rb: should not use the libraries under the source directory
nobu authored
8 $:.replace [srcdir+"/lib"] unless defined?(CROSS_COMPILING)
9 $:.unshift(".")
8775c5a @nobu * mkconfig.rb: no longer embed srcdir and compile_dir into
nobu authored
10
11 require "fileutils"
93a2b97 @nobu * fixed generator script name.
nobu authored
12 mkconfig = File.basename($0)
986c389 Initial revision
matz authored
13
14 rbconfig_rb = ARGV[0] || 'rbconfig.rb'
8775c5a @nobu * mkconfig.rb: no longer embed srcdir and compile_dir into
nobu authored
15 unless File.directory?(dir = File.dirname(rbconfig_rb))
16 FileUtils.makedirs(dir, :verbose => true)
17 end
986c389 Initial revision
matz authored
18
5484fc7 @eban * mkconfig.rb, ext/configsub.rb: VERSION -> RUBY_VERSION.
eban authored
19 version = RUBY_VERSION
64cf936 @nobu * Makefile.in (OUTFLAG): keep trailing spaces. [ruby-dev:27666]
nobu authored
20 def (config = "").write(arg)
21 concat(arg.to_s)
22 end
23 $stdout = config
986c389 Initial revision
matz authored
24
8884ab5 matz - nakada win32 patch
matz authored
25 fast = {'prefix'=>TRUE, 'ruby_install_name'=>TRUE, 'INSTALL'=>TRUE, 'EXEEXT'=>TRUE}
986c389 Initial revision
matz authored
26 print %[
93a2b97 @nobu * fixed generator script name.
nobu authored
27 # This file was created by #{mkconfig} when ruby was built. Any
28 # changes made to this file will be lost the next time ruby is built.
29
986c389 Initial revision
matz authored
30 module Config
5484fc7 @eban * mkconfig.rb, ext/configsub.rb: VERSION -> RUBY_VERSION.
eban authored
31 RUBY_VERSION == "#{version}" or
32 raise "ruby lib version (#{version}) doesn't match executable version (\#{RUBY_VERSION})"
4ade86d @nobu * moved a blank line.
nobu authored
33
986c389 Initial revision
matz authored
34 ]
35
36 v_fast = []
37 v_others = []
9ac4aa0 @nobu * mkconfig.rb: merge multiple entries to an entry with multiple lines.
nobu authored
38 vars = {}
07bb9f2 1.4.0
matz authored
39 has_version = false
896759c @shyouhei merge revision(s) 22932:
shyouhei authored
40 has_patchlevel = false
90f8f74 @nobu * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
nobu authored
41 continued_name = nil
42 continued_line = nil
31b9d28 changes from personal modifies -- matz
matz authored
43 File.foreach "config.status" do |line|
44 next if /^#/ =~ line
90f8f74 @nobu * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
nobu authored
45 name = nil
46 case line
47 when /^s([%,])@(\w+)@\1(?:\|\#_!!_\#\|)?(.*)\1/
976ac4d @nobu * Makefile.in, mkconfig.rb: catch-up for latest autoconf.
nobu authored
48 name = $2
49 val = $3.gsub(/\\(?=,)/, '')
90f8f74 @nobu * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
nobu authored
50 when /^S\["(\w+)"\]\s*=\s*"(.*)"\s*(\\)?$/
51 name = $1
52 val = $2
53 if $3
54 continued_line = []
55 continued_line << val
56 continued_name = name
57 next
58 end
3dbcd24 @shyouhei merge revision(s) 20587:
shyouhei authored
59 when /^"(.*)"\s*(\\)?$/
90f8f74 @nobu * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
nobu authored
60 if continued_line
61 continued_line << $1
3dbcd24 @shyouhei merge revision(s) 20587:
shyouhei authored
62 next if $2
63 val = continued_line.join("")
64 name = continued_name
65 continued_line = nil
90f8f74 @nobu * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
nobu authored
66 end
67 when /^(?:ac_given_)?INSTALL=(.*)/
68 v_fast << " CONFIG[\"INSTALL\"] = " + $1 + "\n"
69 end
70
71 if name
d42c145 @nobu * configure.in (AC_SYS_LARGEFILE): keep results also in command
nobu authored
72 next if /^(?:ac_.*|configure_input|(?:top_)?srcdir|\w+OBJS)$/ =~ name
0c4a0dc @nobu * configure.in (RUBY_PROG_INSTALL): not add -p option to INSTALL.
nobu authored
73 next if /^\$\(ac_\w+\)$/ =~ val
74 next if /^\$\{ac_\w+\}$/ =~ val
75 next if /^\$ac_\w+$/ =~ val
31b9d28 changes from personal modifies -- matz
matz authored
76 next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
77 next if $so_name and /^RUBY_SO_NAME$/ =~ name
95c01b7 @knu Merge changes from ruby_1_8 to reduce warnings and potentially improve
knu authored
78 next if /^(?:X|(?:MINI|RUN)RUBY$)/ =~ name
976ac4d @nobu * Makefile.in, mkconfig.rb: catch-up for latest autoconf.
nobu authored
79 if /^program_transform_name$/ =~ name and /^s(\\?.)(.*)\1$/ =~ val
80 next if $install_name
81 sep = %r"#{Regexp.quote($1)}"
82 ptn = $2.sub(/\$\$/, '$').split(sep, 2)
83 name = "ruby_install_name"
84 val = "ruby".sub(/#{ptn[0]}/, ptn[1])
85 end
90f8f74 @nobu * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
nobu authored
86 val.gsub!(/ +(?!-)/, "=") if name == "configure_args" && /mswin32/ =~ RUBY_PLATFORM
976ac4d @nobu * Makefile.in, mkconfig.rb: catch-up for latest autoconf.
nobu authored
87 val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump
88 if /^prefix$/ =~ name
89 val = "(TOPDIR || DESTDIR + #{val})"
90 end
91 v = " CONFIG[\"#{name}\"] #{vars[name] ? '<< "\n"' : '='} #{val}\n"
9ac4aa0 @nobu * mkconfig.rb: merge multiple entries to an entry with multiple lines.
nobu authored
92 vars[name] = true
986c389 Initial revision
matz authored
93 if fast[name]
94 v_fast << v
95 else
96 v_others << v
97 end
896759c @shyouhei merge revision(s) 22932:
shyouhei authored
98 case name
99 when "MAJOR"
100 has_version = true
101 when "PATCHLEVEL"
102 has_patchlevel = true
103 end
986c389 Initial revision
matz authored
104 end
105 # break if /^CEOF/
106 end
107
0243b2c @nobu * configure.in (XCFLAGS): CFLAGS to comile ruby itself.
nobu authored
108 drive = File::PATH_SEPARATOR == ';'
109
0c4a0dc @nobu * configure.in (RUBY_PROG_INSTALL): not add -p option to INSTALL.
nobu authored
110 prefix = '/lib/ruby/' + RUBY_VERSION.sub(/\.\d+$/, '') + '/' + RUBY_PLATFORM
111 print " TOPDIR = File.dirname(__FILE__).chomp!(#{prefix.dump})\n"
0243b2c @nobu * configure.in (XCFLAGS): CFLAGS to comile ruby itself.
nobu authored
112 print " DESTDIR = ", (drive ? "TOPDIR && TOPDIR[/\\A[a-z]:/i] || " : ""), "'' unless defined? DESTDIR\n"
113 print " CONFIG = {}\n"
114 print " CONFIG[\"DESTDIR\"] = DESTDIR\n"
115
116 unless has_version
5484fc7 @eban * mkconfig.rb, ext/configsub.rb: VERSION -> RUBY_VERSION.
eban authored
117 RUBY_VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) {
07bb9f2 1.4.0
matz authored
118 print " CONFIG[\"MAJOR\"] = \"" + $1 + "\"\n"
119 print " CONFIG[\"MINOR\"] = \"" + $2 + "\"\n"
120 print " CONFIG[\"TEENY\"] = \"" + $3 + "\"\n"
121 }
896759c @shyouhei merge revision(s) 22932:
shyouhei authored
122 end
123 unless has_patchlevel
c3719da @nobu * mkconfig.rb (patchlevel): read from version.h.
nobu authored
124 patchlevel = IO.foreach(File.join(srcdir, "version.h")) {|l|
125 m = /^\s*#\s*define\s+RUBY_PATCHLEVEL\s+(\d+)/.match(l) and break m[1]
126 }
127 print " CONFIG[\"PATCHLEVEL\"] = \"#{patchlevel}\"\n"
07bb9f2 1.4.0
matz authored
128 end
129
0243b2c @nobu * configure.in (XCFLAGS): CFLAGS to comile ruby itself.
nobu authored
130 dest = drive ? /= \"(?!\$[\(\{])(?:[a-z]:)?/i : /= \"(?!\$[\(\{])/
131 v_others.collect! do |x|
80d5af6 @akr * regex.c (re_compile_pattern): /[\--\-]/ was warned. warn /]/.
akr authored
132 if /^\s*CONFIG\["(?!abs_|old)[a-z]+(?:_prefix|dir)"\]/ === x
0243b2c @nobu * configure.in (XCFLAGS): CFLAGS to comile ruby itself.
nobu authored
133 x.sub(dest, '= "$(DESTDIR)')
85c1165 @eban 2000-06-19
eban authored
134 else
135 x
136 end
137 end
138
8884ab5 matz - nakada win32 patch
matz authored
139 if $install_name
140 v_fast << " CONFIG[\"ruby_install_name\"] = \"" + $install_name + "\"\n"
141 v_fast << " CONFIG[\"RUBY_INSTALL_NAME\"] = \"" + $install_name + "\"\n"
142 end
143 if $so_name
144 v_fast << " CONFIG[\"RUBY_SO_NAME\"] = \"" + $so_name + "\"\n"
145 end
146
90f8f74 @nobu * mkconfig.rb: autoconf 2.61 support. [ruby-core:10016]
nobu authored
147 print(*v_fast)
148 print(*v_others)
07bb9f2 1.4.0
matz authored
149 print <<EOS
d7d4acb * parse.y (arg): "||=" should not warn for uninitialized instance
matz authored
150 CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
151 CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
152 CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
153 CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
4fc6c3f @eban * configure.in: RUBY_SO_NAME is msvcrt-rubyXX on mswin32/mingw32.
eban authored
154 CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
629a9e6 @knu Merge from ruby_1_8.
knu authored
155 CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
156 CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(sitearch)"
8775c5a @nobu * mkconfig.rb: no longer embed srcdir and compile_dir into
nobu authored
157 CONFIG["topdir"] = File.dirname(__FILE__)
7e74039 @eban eban
eban authored
158 MAKEFILE_CONFIG = {}
159 CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
0243b2c @nobu * configure.in (XCFLAGS): CFLAGS to comile ruby itself.
nobu authored
160 def Config::expand(val, config = CONFIG)
161 val.gsub!(/\\$\\$|\\$\\(([^()]+)\\)|\\$\\{([^{}]+)\\}/) do |var|
162 if !(v = $1 || $2)
163 '$'
64cf936 @nobu * Makefile.in (OUTFLAG): keep trailing spaces. [ruby-dev:27666]
nobu authored
164 elsif key = config[v = v[/\\A[^:]+(?=(?::(.*?)=(.*))?\\z)/]]
165 pat, sub = $1, $2
0243b2c @nobu * configure.in (XCFLAGS): CFLAGS to comile ruby itself.
nobu authored
166 config[v] = false
0c4a0dc @nobu * configure.in (RUBY_PROG_INSTALL): not add -p option to INSTALL.
nobu authored
167 Config::expand(key, config)
0243b2c @nobu * configure.in (XCFLAGS): CFLAGS to comile ruby itself.
nobu authored
168 config[v] = key
64cf936 @nobu * Makefile.in (OUTFLAG): keep trailing spaces. [ruby-dev:27666]
nobu authored
169 key = key.gsub(/\#{Regexp.quote(pat)}(?=\\s|\\z)/n) {sub} if pat
170 key
7e74039 @eban eban
eban authored
171 else
172 var
173 end
174 end
175 val
176 end
177 CONFIG.each_value do |val|
178 Config::expand(val)
179 end
07bb9f2 1.4.0
matz authored
180 end
5a11e9b @akr * mkconfig.rb: alias RbConfig for Config.
akr authored
181 RbConfig = Config # compatibility for ruby-1.9
8407107 @eban * Makefile.in, {win32,bcc32}/Makefile.sub: add new target:
eban authored
182 CROSS_COMPILING = nil unless defined? CROSS_COMPILING
07bb9f2 1.4.0
matz authored
183 EOS
64cf936 @nobu * Makefile.in (OUTFLAG): keep trailing spaces. [ruby-dev:27666]
nobu authored
184
185 $stdout = STDOUT
186 mode = IO::RDWR|IO::CREAT
187 mode |= IO::BINARY if defined?(IO::BINARY)
188 open(rbconfig_rb, mode) do |f|
189 if $timestamp and f.stat.size == config.size and f.read == config
190 puts "#{rbconfig_rb} unchanged"
191 else
192 puts "#{rbconfig_rb} updated"
193 f.rewind
194 f.truncate(0)
195 f.print(config)
196 end
8775c5a @nobu * mkconfig.rb: no longer embed srcdir and compile_dir into
nobu authored
197 end
198 if String === $timestamp
199 FileUtils.touch($timestamp)
200 end
07bb9f2 1.4.0
matz authored
201
986c389 Initial revision
matz authored
202 # vi:set sw=2:
Something went wrong with that request. Please try again.