FooBarWidget / rubyenterpriseedition
- Source
- Commits
- Network (8)
- Wiki (2)
- Graphs
-
Tree:
0e4701b
Hongli Lai (Phusion) (author)
Mon Apr 20 12:37:51 -0700 2009
rubyenterpriseedition / mkconfig.rb
| 8884ab5e » | matz | 2000-08-03 | 1 | #!./miniruby -s | |
| 986c389e » | matz | 1998-01-16 | 2 | ||
| 4e44bd01 » | eban | 2003-07-27 | 3 | # avoid warnings with -d. | |
| 4 | $install_name ||= nil | ||||
| 5 | $so_name ||= nil | ||||
| 6 | |||||
| 8775c5ab » | nobu | 2005-02-06 | 7 | srcdir = File.dirname(__FILE__) | |
| 8 | $:.replace [srcdir+"/lib", "."] | ||||
| 9 | |||||
| 10 | require "fileutils" | ||||
| 93a2b973 » | nobu | 2002-10-26 | 11 | mkconfig = File.basename($0) | |
| 986c389e » | matz | 1998-01-16 | 12 | ||
| 13 | rbconfig_rb = ARGV[0] || 'rbconfig.rb' | ||||
| 8775c5ab » | nobu | 2005-02-06 | 14 | unless File.directory?(dir = File.dirname(rbconfig_rb)) | |
| 15 | FileUtils.makedirs(dir, :verbose => true) | ||||
| 16 | end | ||||
| 986c389e » | matz | 1998-01-16 | 17 | ||
| 5484fc75 » | eban | 2001-05-30 | 18 | version = RUBY_VERSION | |
| 64cf9365 » | nobu | 2005-11-10 | 19 | def (config = "").write(arg) | |
| 20 | concat(arg.to_s) | ||||
| 21 | end | ||||
| 22 | $stdout = config | ||||
| 986c389e » | matz | 1998-01-16 | 23 | ||
| 8884ab5e » | matz | 2000-08-03 | 24 | fast = {'prefix'=>TRUE, 'ruby_install_name'=>TRUE, 'INSTALL'=>TRUE, 'EXEEXT'=>TRUE} | |
| 986c389e » | matz | 1998-01-16 | 25 | print %[ | |
| 93a2b973 » | nobu | 2002-10-26 | 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 | |||||
| 986c389e » | matz | 1998-01-16 | 29 | module Config | |
| 5484fc75 » | eban | 2001-05-30 | 30 | RUBY_VERSION == "#{version}" or | |
| 31 | raise "ruby lib version (#{version}) doesn't match executable version (\#{RUBY_VERSION})" | ||||
| 4ade86d8 » | nobu | 2002-10-26 | 32 | ||
| 986c389e » | matz | 1998-01-16 | 33 | ] | |
| 34 | |||||
| 35 | v_fast = [] | ||||
| 36 | v_others = [] | ||||
| 9ac4aa09 » | nobu | 2006-05-24 | 37 | vars = {} | |
| 07bb9f21 » | matz | 1999-08-12 | 38 | has_version = false | |
| 90f8f745 » | nobu | 2007-01-29 | 39 | continued_name = nil | |
| 40 | continued_line = nil | ||||
| 31b9d287 » | matz | 2000-12-27 | 41 | File.foreach "config.status" do |line| | |
| 42 | next if /^#/ =~ line | ||||
| 90f8f745 » | nobu | 2007-01-29 | 43 | name = nil | |
| 44 | case line | ||||
| 45 | when /^s([%,])@(\w+)@\1(?:\|\#_!!_\#\|)?(.*)\1/ | ||||
| 976ac4d7 » | nobu | 2006-06-25 | 46 | name = $2 | |
| 47 | val = $3.gsub(/\\(?=,)/, '') | ||||
| 90f8f745 » | nobu | 2007-01-29 | 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 | ||||
| 9cf8093a » | shyouhei | 2008-06-07 | 71 | next if /^(?:ac_.*|configure_input|(?:top_)?srcdir|\w+OBJS)$/ =~ name | |
| 0c4a0dc9 » | nobu | 2005-04-15 | 72 | next if /^\$\(ac_\w+\)$/ =~ val | |
| 73 | next if /^\$\{ac_\w+\}$/ =~ val | ||||
| 74 | next if /^\$ac_\w+$/ =~ val | ||||
| 31b9d287 » | matz | 2000-12-27 | 75 | next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name | |
| 76 | next if $so_name and /^RUBY_SO_NAME$/ =~ name | ||||
| 976ac4d7 » | nobu | 2006-06-25 | 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 | ||||
| 90f8f745 » | nobu | 2007-01-29 | 84 | val.gsub!(/ +(?!-)/, "=") if name == "configure_args" && /mswin32/ =~ RUBY_PLATFORM | |
| 976ac4d7 » | nobu | 2006-06-25 | 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" | ||||
| 9ac4aa09 » | nobu | 2006-05-24 | 90 | vars[name] = true | |
| 986c389e » | matz | 1998-01-16 | 91 | if fast[name] | |
| 92 | v_fast << v | ||||
| 93 | else | ||||
| 94 | v_others << v | ||||
| 95 | end | ||||
| 07bb9f21 » | matz | 1999-08-12 | 96 | has_version = true if name == "MAJOR" | |
| 986c389e » | matz | 1998-01-16 | 97 | end | |
| 98 | # break if /^CEOF/ | ||||
| 99 | end | ||||
| 100 | |||||
| 0243b2c1 » | nobu | 2002-10-21 | 101 | drive = File::PATH_SEPARATOR == ';' | |
| 102 | |||||
| 0c4a0dc9 » | nobu | 2005-04-15 | 103 | prefix = '/lib/ruby/' + RUBY_VERSION.sub(/\.\d+$/, '') + '/' + RUBY_PLATFORM | |
| 104 | print " TOPDIR = File.dirname(__FILE__).chomp!(#{prefix.dump})\n" | ||||
| 0243b2c1 » | nobu | 2002-10-21 | 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 | ||||
| 5484fc75 » | eban | 2001-05-30 | 110 | RUBY_VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) { | |
| 07bb9f21 » | matz | 1999-08-12 | 111 | print " CONFIG[\"MAJOR\"] = \"" + $1 + "\"\n" | |
| 112 | print " CONFIG[\"MINOR\"] = \"" + $2 + "\"\n" | ||||
| 113 | print " CONFIG[\"TEENY\"] = \"" + $3 + "\"\n" | ||||
| 114 | } | ||||
| c2f8d063 » | knu | 2007-02-28 | 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" | ||||
| 07bb9f21 » | matz | 1999-08-12 | 119 | end | |
| 120 | |||||
| 0243b2c1 » | nobu | 2002-10-21 | 121 | dest = drive ? /= \"(?!\$[\(\{])(?:[a-z]:)?/i : /= \"(?!\$[\(\{])/ | |
| 122 | v_others.collect! do |x| | ||||
| 80d5af6a » | akr | 2003-04-09 | 123 | if /^\s*CONFIG\["(?!abs_|old)[a-z]+(?:_prefix|dir)"\]/ === x | |
| 0243b2c1 » | nobu | 2002-10-21 | 124 | x.sub(dest, '= "$(DESTDIR)') | |
| 85c11656 » | eban | 2000-06-18 | 125 | else | |
| 126 | x | ||||
| 127 | end | ||||
| 128 | end | ||||
| 129 | |||||
| 8884ab5e » | matz | 2000-08-03 | 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 | |||||
| 90f8f745 » | nobu | 2007-01-29 | 138 | print(*v_fast) | |
| 139 | print(*v_others) | ||||
| 07bb9f21 » | matz | 1999-08-12 | 140 | print <<EOS | |
| d7d4acb1 » | matz | 2001-05-07 | 141 | CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)" | |
| 142 | CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)" | ||||
| 143 | CONFIG["archdir"] = "$(rubylibdir)/$(arch)" | ||||
| 144 | CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)" | ||||
| 4fc6c3f7 » | eban | 2002-08-23 | 145 | CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)" | |
| 8775c5ab » | nobu | 2005-02-06 | 146 | CONFIG["topdir"] = File.dirname(__FILE__) | |
| 7e740395 » | eban | 2000-07-31 | 147 | MAKEFILE_CONFIG = {} | |
| 148 | CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup} | ||||
| 0243b2c1 » | nobu | 2002-10-21 | 149 | def Config::expand(val, config = CONFIG) | |
| 150 | val.gsub!(/\\$\\$|\\$\\(([^()]+)\\)|\\$\\{([^{}]+)\\}/) do |var| | ||||
| 151 | if !(v = $1 || $2) | ||||
| 152 | '$' | ||||
| 64cf9365 » | nobu | 2005-11-10 | 153 | elsif key = config[v = v[/\\A[^:]+(?=(?::(.*?)=(.*))?\\z)/]] | |
| 154 | pat, sub = $1, $2 | ||||
| 0243b2c1 » | nobu | 2002-10-21 | 155 | config[v] = false | |
| 0c4a0dc9 » | nobu | 2005-04-15 | 156 | Config::expand(key, config) | |
| 0243b2c1 » | nobu | 2002-10-21 | 157 | config[v] = key | |
| 64cf9365 » | nobu | 2005-11-10 | 158 | key = key.gsub(/\#{Regexp.quote(pat)}(?=\\s|\\z)/n) {sub} if pat | |
| 159 | key | ||||
| 7e740395 » | eban | 2000-07-31 | 160 | else | |
| 161 | var | ||||
| 162 | end | ||||
| 163 | end | ||||
| 164 | val | ||||
| 165 | end | ||||
| 166 | CONFIG.each_value do |val| | ||||
| 167 | Config::expand(val) | ||||
| 168 | end | ||||
| 07bb9f21 » | matz | 1999-08-12 | 169 | end | |
| 5a11e9b2 » | akr | 2006-02-20 | 170 | RbConfig = Config # compatibility for ruby-1.9 | |
| 84071071 » | eban | 2002-12-31 | 171 | CROSS_COMPILING = nil unless defined? CROSS_COMPILING | |
| 07bb9f21 » | matz | 1999-08-12 | 172 | EOS | |
| 64cf9365 » | nobu | 2005-11-10 | 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 | ||||
| 8775c5ab » | nobu | 2005-02-06 | 186 | end | |
| 187 | if String === $timestamp | ||||
| 188 | FileUtils.touch($timestamp) | ||||
| 189 | end | ||||
| 07bb9f21 » | matz | 1999-08-12 | 190 | ||
| 986c389e » | matz | 1998-01-16 | 191 | # vi:set sw=2: | |
