~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to mkconfig.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!./miniruby -s
 
2
 
 
3
# avoid warnings with -d.
 
4
$install_name ||= nil
 
5
$so_name ||= nil
 
6
 
 
7
srcdir = File.dirname(__FILE__)
 
8
$:.replace [srcdir+"/lib", "."]
 
9
 
 
10
require "fileutils"
 
11
mkconfig = File.basename($0)
 
12
 
 
13
rbconfig_rb = ARGV[0] || 'rbconfig.rb'
 
14
unless File.directory?(dir = File.dirname(rbconfig_rb))
 
15
  FileUtils.makedirs(dir, :verbose => true)
 
16
end
 
17
 
 
18
version = RUBY_VERSION
 
19
def (config = "").write(arg)
 
20
  concat(arg.to_s)
 
21
end
 
22
$stdout = config
 
23
 
 
24
fast = {'prefix'=>TRUE, 'ruby_install_name'=>TRUE, 'INSTALL'=>TRUE, 'EXEEXT'=>TRUE}
 
25
print %[
 
26
# This file was created by #{mkconfig} when ruby was built.  Any
 
27
# changes made to this file will be lost the next time ruby is built.
 
28
 
 
29
module Config
 
30
  RUBY_VERSION == "#{version}" or
 
31
    raise "ruby lib version (#{version}) doesn't match executable version (\#{RUBY_VERSION})"
 
32
 
 
33
]
 
34
 
 
35
v_fast = []
 
36
v_others = []
 
37
vars = {}
 
38
has_version = false
 
39
continued_name = nil
 
40
continued_line = nil
 
41
File.foreach "config.status" do |line|
 
42
  next if /^#/ =~ line
 
43
  name = nil
 
44
  case line
 
45
  when /^s([%,])@(\w+)@\1(?:\|\#_!!_\#\|)?(.*)\1/
 
46
    name = $2
 
47
    val = $3.gsub(/\\(?=,)/, '')
 
48
  when /^S\["(\w+)"\]\s*=\s*"(.*)"\s*(\\)?$/
 
49
    name = $1
 
50
    val = $2
 
51
    if $3
 
52
      continued_line = []
 
53
      continued_line << val
 
54
      continued_name = name
 
55
      next
 
56
    end
 
57
  when /^"(.+)"\s*(\\)?$/
 
58
    if continued_line
 
59
      continued_line <<  $1
 
60
      unless $2
 
61
        val = continued_line.join("")
 
62
        name = continued_name
 
63
        continued_line = nil
 
64
      end
 
65
    end
 
66
  when /^(?:ac_given_)?INSTALL=(.*)/
 
67
    v_fast << "  CONFIG[\"INSTALL\"] = " + $1 + "\n"
 
68
  end
 
69
 
 
70
  if name
 
71
    next if /^(?:ac_.*|DEFS|configure_input|(?:top_)?srcdir|\w+OBJS)$/ =~ name
 
72
    next if /^\$\(ac_\w+\)$/ =~ val
 
73
    next if /^\$\{ac_\w+\}$/ =~ val
 
74
    next if /^\$ac_\w+$/ =~ val
 
75
    next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
 
76
    next if $so_name and /^RUBY_SO_NAME$/ =~  name
 
77
    if /^program_transform_name$/ =~ name and /^s(\\?.)(.*)\1$/ =~ val
 
78
      next if $install_name
 
79
      sep = %r"#{Regexp.quote($1)}"
 
80
      ptn = $2.sub(/\$\$/, '$').split(sep, 2)
 
81
      name = "ruby_install_name"
 
82
      val = "ruby".sub(/#{ptn[0]}/, ptn[1])
 
83
    end
 
84
    val.gsub!(/ +(?!-)/, "=") if name == "configure_args" && /mswin32/ =~ RUBY_PLATFORM
 
85
    val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump
 
86
    if /^prefix$/ =~ name
 
87
      val = "(TOPDIR || DESTDIR + #{val})"
 
88
    end
 
89
    v = "  CONFIG[\"#{name}\"] #{vars[name] ? '<< "\n"' : '='} #{val}\n"
 
90
    vars[name] = true
 
91
    if fast[name]
 
92
      v_fast << v
 
93
    else
 
94
      v_others << v
 
95
    end
 
96
    has_version = true if name == "MAJOR"
 
97
  end
 
98
#  break if /^CEOF/
 
99
end
 
100
 
 
101
drive = File::PATH_SEPARATOR == ';'
 
102
 
 
103
prefix = '/lib/ruby/' + RUBY_VERSION.sub(/\.\d+$/, '') + '/' + RUBY_PLATFORM
 
104
print "  TOPDIR = File.dirname(__FILE__).chomp!(#{prefix.dump})\n"
 
105
print "  DESTDIR = ", (drive ? "TOPDIR && TOPDIR[/\\A[a-z]:/i] || " : ""), "'' unless defined? DESTDIR\n"
 
106
print "  CONFIG = {}\n"
 
107
print "  CONFIG[\"DESTDIR\"] = DESTDIR\n"
 
108
 
 
109
unless has_version
 
110
  RUBY_VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) {
 
111
    print "  CONFIG[\"MAJOR\"] = \"" + $1 + "\"\n"
 
112
    print "  CONFIG[\"MINOR\"] = \"" + $2 + "\"\n"
 
113
    print "  CONFIG[\"TEENY\"] = \"" + $3 + "\"\n"
 
114
  }
 
115
  patchlevel = IO.foreach(File.join(srcdir, "version.h")) {|l|
 
116
    m = /^\s*#\s*define\s+RUBY_PATCHLEVEL\s+(\d+)/.match(l) and break m[1]
 
117
  }
 
118
  print "  CONFIG[\"PATCHLEVEL\"] = \"#{patchlevel}\"\n"
 
119
end
 
120
 
 
121
dest = drive ? /= \"(?!\$[\(\{])(?:[a-z]:)?/i : /= \"(?!\$[\(\{])/
 
122
v_others.collect! do |x|
 
123
  if /^\s*CONFIG\["(?!abs_|old)[a-z]+(?:_prefix|dir)"\]/ === x
 
124
    x.sub(dest, '= "$(DESTDIR)')
 
125
  else
 
126
    x
 
127
  end
 
128
end
 
129
 
 
130
if $install_name
 
131
  v_fast << "  CONFIG[\"ruby_install_name\"] = \"" + $install_name + "\"\n"
 
132
  v_fast << "  CONFIG[\"RUBY_INSTALL_NAME\"] = \"" + $install_name + "\"\n"
 
133
end
 
134
if $so_name
 
135
  v_fast << "  CONFIG[\"RUBY_SO_NAME\"] = \"" + $so_name + "\"\n"
 
136
end
 
137
 
 
138
print(*v_fast)
 
139
print(*v_others)
 
140
print <<EOS
 
141
  CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
 
142
  CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
 
143
  CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
 
144
  CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
 
145
  CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
 
146
  CONFIG["topdir"] = File.dirname(__FILE__)
 
147
  MAKEFILE_CONFIG = {}
 
148
  CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
 
149
  def Config::expand(val, config = CONFIG)
 
150
    val.gsub!(/\\$\\$|\\$\\(([^()]+)\\)|\\$\\{([^{}]+)\\}/) do |var|
 
151
      if !(v = $1 || $2)
 
152
        '$'
 
153
      elsif key = config[v = v[/\\A[^:]+(?=(?::(.*?)=(.*))?\\z)/]]
 
154
        pat, sub = $1, $2
 
155
        config[v] = false
 
156
        Config::expand(key, config)
 
157
        config[v] = key
 
158
        key = key.gsub(/\#{Regexp.quote(pat)}(?=\\s|\\z)/n) {sub} if pat
 
159
        key
 
160
      else
 
161
        var
 
162
      end
 
163
    end
 
164
    val
 
165
  end
 
166
  CONFIG.each_value do |val|
 
167
    Config::expand(val)
 
168
  end
 
169
end
 
170
RbConfig = Config # compatibility for ruby-1.9
 
171
CROSS_COMPILING = nil unless defined? CROSS_COMPILING
 
172
EOS
 
173
 
 
174
$stdout = STDOUT
 
175
mode = IO::RDWR|IO::CREAT
 
176
mode |= IO::BINARY if defined?(IO::BINARY)
 
177
open(rbconfig_rb, mode) do |f|
 
178
  if $timestamp and f.stat.size == config.size and f.read == config
 
179
    puts "#{rbconfig_rb} unchanged"
 
180
  else
 
181
    puts "#{rbconfig_rb} updated"
 
182
    f.rewind
 
183
    f.truncate(0)
 
184
    f.print(config)
 
185
  end
 
186
end
 
187
if String === $timestamp
 
188
  FileUtils.touch($timestamp)
 
189
end
 
190
 
 
191
# vi:set sw=2: