[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git] / tool / fake.rb
blob0366144531c292b0e4fab321f0a61e44b72bcf4e
1 # Used by Makefile and configure for building Ruby.
2 # See common.mk and Makefile.in for details.
4 class File
5   sep = ("\\" if RUBY_PLATFORM =~ /mswin|bccwin|mingw/)
6   if sep != ALT_SEPARATOR
7     remove_const :ALT_SEPARATOR
8     ALT_SEPARATOR = sep
9   end
10 end
12 [[libpathenv, "."], [preloadenv, libruby_so]].each do |env, path|
13   env or next
14   e = ENV[env] or next
15   e = e.split(File::PATH_SEPARATOR)
16   path = File.realpath(path, builddir) rescue next
17   e.delete(path) or next
18   ENV[env] = (e.join(File::PATH_SEPARATOR) unless e.empty?)
19 end
21 static = !!(defined?($static) && $static)
22 $:.unshift(builddir)
23 posthook = proc do
24   RbConfig.fire_update!("top_srcdir", $top_srcdir)
25   RbConfig.fire_update!("topdir", $topdir)
26   $hdrdir.sub!(/\A#{Regexp.quote($top_srcdir)}(?=\/)/, "$(top_srcdir)")
27   if $extmk
28     $ruby = "$(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'"
29   else
30     $ruby = baseruby
31   end
32   $static = static
33   untrace_var(:$ruby, posthook)
34 end
35 prehook = proc do |extmk|
36 =begin
37   pat = %r[(?:\A(?:\w:|//[^/]+)|\G)/[^/]*]
38   dir = builddir.scan(pat)
39   pwd = Dir.pwd.scan(pat)
40   if dir[0] == pwd[0]
41     while dir[0] and dir[0] == pwd[0]
42       dir.shift
43       pwd.shift
44     end
45     builddir = File.join((pwd.empty? ? ["."] : [".."]*pwd.size) + dir)
46     builddir = "." if builddir.empty?
47   end
48 =end
49   join = proc {|*args| File.join(*args).sub!(/\A(?:\.\/)*/, '')}
50   $topdir ||= builddir
51   $top_srcdir ||= (File.identical?(top_srcdir, dir = join[$topdir, srcdir]) ?
52                      dir : top_srcdir)
53   $extout = '$(topdir)/.ext'
54   $extout_prefix = '$(extout)$(target_prefix)/'
55   config = RbConfig::CONFIG
56   mkconfig = RbConfig::MAKEFILE_CONFIG
57   $builtruby ||= File.join(builddir, config['RUBY_INSTALL_NAME'] + config['EXEEXT'])
58   RbConfig.fire_update!("builddir", builddir)
59   RbConfig.fire_update!("buildlibdir", builddir)
60   RbConfig.fire_update!("libdir", builddir)
61   RbConfig.fire_update!("prefix", $topdir)
62   RbConfig.fire_update!("top_srcdir", $top_srcdir ||= top_srcdir)
63   RbConfig.fire_update!("extout", $extout)
64   RbConfig.fire_update!("rubyhdrdir", "$(top_srcdir)/include")
65   RbConfig.fire_update!("rubyarchhdrdir", "$(extout)/include/$(arch)")
66   RbConfig.fire_update!("libdirname", "buildlibdir")
67   trace_var(:$ruby, posthook)
68   untrace_var(:$extmk, prehook)
69 end
70 trace_var(:$extmk, prehook)