~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to tool/mkconfig.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
]
36
36
 
37
37
arch = RUBY_PLATFORM
 
38
win32 = /mswin/ =~ arch
 
39
universal = /universal.*darwin/ =~ arch
38
40
v_fast = []
39
41
v_others = []
40
42
vars = {}
51
53
    name = $1
52
54
    val = $2
53
55
    if $3
54
 
      continued_line = []
55
 
      continued_line << val
 
56
      continued_line = [val]
56
57
      continued_name = name
57
58
      next
58
59
    end
59
60
  when /^"(.*)"\s*(\\)?$/
60
 
    if continued_line
61
 
      continued_line <<  $1
62
 
      next if $2
63
 
      val = continued_line.join("")
64
 
      name = continued_name
65
 
      continued_line = nil
66
 
    end
 
61
    next if !continued_line
 
62
    continued_line << $1
 
63
    next if $2
 
64
    val = continued_line.join
 
65
    name = continued_name
 
66
    continued_line = nil
67
67
  when /^(?:ac_given_)?INSTALL=(.*)/
68
68
    v_fast << "  CONFIG[\"INSTALL\"] = " + $1 + "\n"
69
69
  end
112
112
      end
113
113
    end
114
114
    if name == "configure_args"
115
 
      val.gsub!(/ +(?!-)/, "=") if /mswin32/ =~ RUBY_PLATFORM
 
115
      val.gsub!(/ +(?!-)/, "=") if win32
116
116
      val.gsub!(/--with-out-ext/, "--without-ext")
117
117
    end
118
118
    val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump
119
 
    if /^prefix$/ =~ name
 
119
    case name
 
120
    when /^prefix$/
120
121
      val = "(TOPDIR || DESTDIR + #{val})"
 
122
    when /^ARCH_FLAG$/
 
123
      val = "arch_flag || #{val}" if universal
 
124
    when /^UNIVERSAL_ARCHNAMES$/
 
125
      universal, val = val, 'universal' if universal
 
126
    when /^arch$/
 
127
      if universal
 
128
        val.sub!(/universal/, %q[#{arch && universal[/(?:\A|\s)#{Regexp.quote(arch)}=(\S+)/, 1] || '\&'}])
 
129
      end
121
130
    end
122
 
    v = "  CONFIG[\"#{name}\"] #{vars[name] ? '<< "\n"' : '='} #{val}\n"
 
131
    v = "  CONFIG[\"#{name}\"] #{win32 && vars[name] ? '<< "\n"' : '='} #{val}\n"
123
132
    vars[name] = true
124
133
    if fast[name]
125
134
      v_fast << v
139
148
prefix = "/lib/ruby/#{version}/#{arch}"
140
149
print "  TOPDIR = File.dirname(__FILE__).chomp!(#{prefix.dump})\n"
141
150
print "  DESTDIR = ", (drive ? "TOPDIR && TOPDIR[/\\A[a-z]:/i] || " : ""), "'' unless defined? DESTDIR\n"
 
151
print <<'ARCH' if universal
 
152
  arch_flag = ENV['ARCHFLAGS'] || ((e = ENV['RC_ARCHS']) && e.split.uniq.map {|a| "-arch #{a}"}.join(' '))
 
153
  arch = arch_flag && arch_flag[/\A\s*-arch\s+(\S+)\s*\z/, 1]
 
154
ARCH
 
155
print "  universal = #{universal}\n" if universal
142
156
print "  CONFIG = {}\n"
143
157
print "  CONFIG[\"DESTDIR\"] = DESTDIR\n"
144
158
 
145
159
versions = {}
146
160
IO.foreach(File.join(srcdir, "version.h")) do |l|
147
 
  m = /^\s*#\s*define\s+RUBY_(VERSION_(MAJOR|MINOR|TEENY)|PATCHLEVEL)\s+(-?\d+)/.match(l)
148
 
  if m
149
 
    versions[m[2]||m[1]] = m[3]
 
161
  m = /^\s*#\s*define\s+RUBY_(PATCHLEVEL)\s+(-?\d+)/.match(l)
 
162
  if m
 
163
    versions[m[1]] = m[2]
 
164
    break
 
165
  end
 
166
end
 
167
IO.foreach(File.join(srcdir, "include/ruby/version.h")) do |l|
 
168
  m = /^\s*#\s*define\s+RUBY_API_VERSION_(MAJOR|MINOR|TEENY)\s+(-?\d+)/.match(l)
 
169
  if m
 
170
    versions[m[1]] = m[2]
150
171
    break if versions.size == 4
151
172
  end
152
173
end
154
175
  print "  CONFIG[#{v.dump}] = #{versions[v].dump}\n"
155
176
end
156
177
 
157
 
dest = drive ? /= \"(?!\$[\(\{])(?:[a-z]:)?/i : /= \"(?!\$[\(\{])/
 
178
dest = drive ? %r'= "(?!\$[\(\{])(?i:[a-z]:)' : %r'= "(?!\$[\(\{])'
 
179
v_disabled = {}
158
180
v_others.collect! do |x|
159
 
  if /^\s*CONFIG\["(?!abs_|old)[a-z]+(?:_prefix|dir)"\]/ === x
 
181
  if /^\s*CONFIG\["((?!abs_|old)[a-z]+(?:_prefix|dir))"\]/ === x
 
182
    name = $1
 
183
    if /= "no"$/ =~ x
 
184
      v_disabled[name] = true
 
185
      v_others.delete(name)
 
186
      next
 
187
    end
160
188
    x.sub(dest, '= "$(DESTDIR)')
161
189
  else
162
190
    x
163
191
  end
164
192
end
 
193
v_others.compact!
165
194
 
166
195
if $install_name
167
196
  v_fast << "  CONFIG[\"ruby_install_name\"] = \"" + $install_name + "\"\n"
176
205
print <<EOS
177
206
  CONFIG["rubylibdir"] = "$(rubylibprefix)/$(ruby_version)"
178
207
  CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
 
208
EOS
 
209
print <<EOS unless v_disabled["sitedir"]
179
210
  CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
180
211
  CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
 
212
EOS
 
213
print <<EOS unless v_disabled["vendordir"]
181
214
  CONFIG["vendorlibdir"] = "$(vendordir)/$(ruby_version)"
182
215
  CONFIG["vendorarchdir"] = "$(vendorlibdir)/$(sitearch)"
 
216
EOS
 
217
print <<EOS
183
218
  CONFIG["topdir"] = File.dirname(__FILE__)
184
219
  MAKEFILE_CONFIG = {}
185
220
  CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
213
248
    )
214
249
  end
215
250
end
216
 
Config = RbConfig # compatibility for ruby-1.8.4 and older.
 
251
autoload :Config, "rbconfig/obsolete.rb" # compatibility for ruby-1.8.4 and older.
217
252
CROSS_COMPILING = nil unless defined? CROSS_COMPILING
218
253
EOS
219
254