Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../opt/alt/ruby27/share/ruby
File: mkmf.rb
# -*- coding: us-ascii -*-
[0] Fix | Delete
# frozen-string-literal: false
[1] Fix | Delete
# module to create Makefile for extension modules
[2] Fix | Delete
# invoke like: ruby -r mkmf extconf.rb
[3] Fix | Delete
[4] Fix | Delete
require 'rbconfig'
[5] Fix | Delete
require 'fileutils'
[6] Fix | Delete
require 'shellwords'
[7] Fix | Delete
[8] Fix | Delete
class String
[9] Fix | Delete
# :stopdoc:
[10] Fix | Delete
[11] Fix | Delete
# Wraps a string in escaped quotes if it contains whitespace.
[12] Fix | Delete
def quote
[13] Fix | Delete
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
[14] Fix | Delete
end
[15] Fix | Delete
[16] Fix | Delete
# Escape whitespaces for Makefile.
[17] Fix | Delete
def unspace
[18] Fix | Delete
gsub(/\s/, '\\\\\\&')
[19] Fix | Delete
end
[20] Fix | Delete
[21] Fix | Delete
# Generates a string used as cpp macro name.
[22] Fix | Delete
def tr_cpp
[23] Fix | Delete
strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
[24] Fix | Delete
end
[25] Fix | Delete
[26] Fix | Delete
def funcall_style
[27] Fix | Delete
/\)\z/ =~ self ? dup : "#{self}()"
[28] Fix | Delete
end
[29] Fix | Delete
[30] Fix | Delete
def sans_arguments
[31] Fix | Delete
self[/\A[^()]+/]
[32] Fix | Delete
end
[33] Fix | Delete
[34] Fix | Delete
# :startdoc:
[35] Fix | Delete
end
[36] Fix | Delete
[37] Fix | Delete
class Array
[38] Fix | Delete
# :stopdoc:
[39] Fix | Delete
[40] Fix | Delete
# Wraps all strings in escaped quotes if they contain whitespace.
[41] Fix | Delete
def quote
[42] Fix | Delete
map {|s| s.quote}
[43] Fix | Delete
end
[44] Fix | Delete
[45] Fix | Delete
# :startdoc:
[46] Fix | Delete
end
[47] Fix | Delete
[48] Fix | Delete
##
[49] Fix | Delete
# mkmf.rb is used by Ruby C extensions to generate a Makefile which will
[50] Fix | Delete
# correctly compile and link the C extension to Ruby and a third-party
[51] Fix | Delete
# library.
[52] Fix | Delete
module MakeMakefile
[53] Fix | Delete
#### defer until this module become global-state free.
[54] Fix | Delete
# def self.extended(obj)
[55] Fix | Delete
# obj.init_mkmf
[56] Fix | Delete
# super
[57] Fix | Delete
# end
[58] Fix | Delete
#
[59] Fix | Delete
# def initialize(*args, rbconfig: RbConfig, **rest)
[60] Fix | Delete
# init_mkmf(rbconfig::MAKEFILE_CONFIG, rbconfig::CONFIG)
[61] Fix | Delete
# super(*args, **rest)
[62] Fix | Delete
# end
[63] Fix | Delete
[64] Fix | Delete
##
[65] Fix | Delete
# The makefile configuration using the defaults from when Ruby was built.
[66] Fix | Delete
[67] Fix | Delete
CONFIG = RbConfig::MAKEFILE_CONFIG
[68] Fix | Delete
ORIG_LIBPATH = ENV['LIB']
[69] Fix | Delete
[70] Fix | Delete
##
[71] Fix | Delete
# Extensions for files compiled with a C compiler
[72] Fix | Delete
[73] Fix | Delete
C_EXT = %w[c m]
[74] Fix | Delete
[75] Fix | Delete
##
[76] Fix | Delete
# Extensions for files complied with a C++ compiler
[77] Fix | Delete
[78] Fix | Delete
CXX_EXT = %w[cc mm cxx cpp]
[79] Fix | Delete
unless File.exist?(File.join(*File.split(__FILE__).tap {|d, b| b.swapcase}))
[80] Fix | Delete
CXX_EXT.concat(%w[C])
[81] Fix | Delete
end
[82] Fix | Delete
[83] Fix | Delete
##
[84] Fix | Delete
# Extensions for source files
[85] Fix | Delete
[86] Fix | Delete
SRC_EXT = C_EXT + CXX_EXT
[87] Fix | Delete
[88] Fix | Delete
##
[89] Fix | Delete
# Extensions for header files
[90] Fix | Delete
[91] Fix | Delete
HDR_EXT = %w[h hpp]
[92] Fix | Delete
$static = nil
[93] Fix | Delete
$config_h = '$(arch_hdrdir)/ruby/config.h'
[94] Fix | Delete
$default_static = $static
[95] Fix | Delete
[96] Fix | Delete
unless defined? $configure_args
[97] Fix | Delete
$configure_args = {}
[98] Fix | Delete
args = CONFIG["configure_args"]
[99] Fix | Delete
if ENV["CONFIGURE_ARGS"]
[100] Fix | Delete
args << " " << ENV["CONFIGURE_ARGS"]
[101] Fix | Delete
end
[102] Fix | Delete
for arg in Shellwords::shellwords(args)
[103] Fix | Delete
arg, val = arg.split('=', 2)
[104] Fix | Delete
next unless arg
[105] Fix | Delete
arg.tr!('_', '-')
[106] Fix | Delete
if arg.sub!(/^(?!--)/, '--')
[107] Fix | Delete
val or next
[108] Fix | Delete
arg.downcase!
[109] Fix | Delete
end
[110] Fix | Delete
next if /^--(?:top|topsrc|src|cur)dir$/ =~ arg
[111] Fix | Delete
$configure_args[arg] = val || true
[112] Fix | Delete
end
[113] Fix | Delete
for arg in ARGV
[114] Fix | Delete
arg, val = arg.split('=', 2)
[115] Fix | Delete
next unless arg
[116] Fix | Delete
arg.tr!('_', '-')
[117] Fix | Delete
if arg.sub!(/^(?!--)/, '--')
[118] Fix | Delete
val or next
[119] Fix | Delete
arg.downcase!
[120] Fix | Delete
end
[121] Fix | Delete
$configure_args[arg] = val || true
[122] Fix | Delete
end
[123] Fix | Delete
end
[124] Fix | Delete
[125] Fix | Delete
$libdir = CONFIG["libdir"]
[126] Fix | Delete
$rubylibdir = CONFIG["rubylibdir"]
[127] Fix | Delete
$archdir = CONFIG["archdir"]
[128] Fix | Delete
$sitedir = CONFIG["sitedir"]
[129] Fix | Delete
$sitelibdir = CONFIG["sitelibdir"]
[130] Fix | Delete
$sitearchdir = CONFIG["sitearchdir"]
[131] Fix | Delete
$vendordir = CONFIG["vendordir"]
[132] Fix | Delete
$vendorlibdir = CONFIG["vendorlibdir"]
[133] Fix | Delete
$vendorarchdir = CONFIG["vendorarchdir"]
[134] Fix | Delete
[135] Fix | Delete
$mswin = /mswin/ =~ RUBY_PLATFORM
[136] Fix | Delete
$mingw = /mingw/ =~ RUBY_PLATFORM
[137] Fix | Delete
$cygwin = /cygwin/ =~ RUBY_PLATFORM
[138] Fix | Delete
$netbsd = /netbsd/ =~ RUBY_PLATFORM
[139] Fix | Delete
$haiku = /haiku/ =~ RUBY_PLATFORM
[140] Fix | Delete
$solaris = /solaris/ =~ RUBY_PLATFORM
[141] Fix | Delete
$universal = /universal/ =~ RUBY_PLATFORM
[142] Fix | Delete
$dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
[143] Fix | Delete
[144] Fix | Delete
# :stopdoc:
[145] Fix | Delete
[146] Fix | Delete
def config_string(key, config = CONFIG)
[147] Fix | Delete
s = config[key] and !s.empty? and block_given? ? yield(s) : s
[148] Fix | Delete
end
[149] Fix | Delete
module_function :config_string
[150] Fix | Delete
[151] Fix | Delete
def dir_re(dir)
[152] Fix | Delete
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
[153] Fix | Delete
end
[154] Fix | Delete
module_function :dir_re
[155] Fix | Delete
[156] Fix | Delete
def relative_from(path, base)
[157] Fix | Delete
dir = File.join(path, "")
[158] Fix | Delete
if File.expand_path(dir) == File.expand_path(dir, base)
[159] Fix | Delete
path
[160] Fix | Delete
else
[161] Fix | Delete
File.join(base, path)
[162] Fix | Delete
end
[163] Fix | Delete
end
[164] Fix | Delete
[165] Fix | Delete
INSTALL_DIRS = [
[166] Fix | Delete
[dir_re('commondir'), "$(RUBYCOMMONDIR)"],
[167] Fix | Delete
[dir_re('sitedir'), "$(RUBYCOMMONDIR)"],
[168] Fix | Delete
[dir_re('vendordir'), "$(RUBYCOMMONDIR)"],
[169] Fix | Delete
[dir_re('rubylibdir'), "$(RUBYLIBDIR)"],
[170] Fix | Delete
[dir_re('archdir'), "$(RUBYARCHDIR)"],
[171] Fix | Delete
[dir_re('sitelibdir'), "$(RUBYLIBDIR)"],
[172] Fix | Delete
[dir_re('vendorlibdir'), "$(RUBYLIBDIR)"],
[173] Fix | Delete
[dir_re('sitearchdir'), "$(RUBYARCHDIR)"],
[174] Fix | Delete
[dir_re('vendorarchdir'), "$(RUBYARCHDIR)"],
[175] Fix | Delete
[dir_re('rubyhdrdir'), "$(RUBYHDRDIR)"],
[176] Fix | Delete
[dir_re('sitehdrdir'), "$(SITEHDRDIR)"],
[177] Fix | Delete
[dir_re('vendorhdrdir'), "$(VENDORHDRDIR)"],
[178] Fix | Delete
[dir_re('bindir'), "$(BINDIR)"],
[179] Fix | Delete
]
[180] Fix | Delete
[181] Fix | Delete
def install_dirs(target_prefix = nil)
[182] Fix | Delete
if $extout and $extmk
[183] Fix | Delete
dirs = [
[184] Fix | Delete
['BINDIR', '$(extout)/bin'],
[185] Fix | Delete
['RUBYCOMMONDIR', '$(extout)/common'],
[186] Fix | Delete
['RUBYLIBDIR', '$(RUBYCOMMONDIR)$(target_prefix)'],
[187] Fix | Delete
['RUBYARCHDIR', '$(extout)/$(arch)$(target_prefix)'],
[188] Fix | Delete
['HDRDIR', '$(extout)/include/ruby$(target_prefix)'],
[189] Fix | Delete
['ARCHHDRDIR', '$(extout)/include/$(arch)/ruby$(target_prefix)'],
[190] Fix | Delete
['extout', "#$extout"],
[191] Fix | Delete
['extout_prefix', "#$extout_prefix"],
[192] Fix | Delete
]
[193] Fix | Delete
elsif $extmk
[194] Fix | Delete
dirs = [
[195] Fix | Delete
['BINDIR', '$(bindir)'],
[196] Fix | Delete
['RUBYCOMMONDIR', '$(rubylibdir)'],
[197] Fix | Delete
['RUBYLIBDIR', '$(rubylibdir)$(target_prefix)'],
[198] Fix | Delete
['RUBYARCHDIR', '$(archdir)$(target_prefix)'],
[199] Fix | Delete
['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
[200] Fix | Delete
['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
[201] Fix | Delete
]
[202] Fix | Delete
elsif $configure_args.has_key?('--vendor')
[203] Fix | Delete
dirs = [
[204] Fix | Delete
['BINDIR', '$(bindir)'],
[205] Fix | Delete
['RUBYCOMMONDIR', '$(vendordir)$(target_prefix)'],
[206] Fix | Delete
['RUBYLIBDIR', '$(vendorlibdir)$(target_prefix)'],
[207] Fix | Delete
['RUBYARCHDIR', '$(vendorarchdir)$(target_prefix)'],
[208] Fix | Delete
['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
[209] Fix | Delete
['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
[210] Fix | Delete
]
[211] Fix | Delete
else
[212] Fix | Delete
dirs = [
[213] Fix | Delete
['BINDIR', '$(bindir)'],
[214] Fix | Delete
['RUBYCOMMONDIR', '$(sitedir)$(target_prefix)'],
[215] Fix | Delete
['RUBYLIBDIR', '$(sitelibdir)$(target_prefix)'],
[216] Fix | Delete
['RUBYARCHDIR', '$(sitearchdir)$(target_prefix)'],
[217] Fix | Delete
['HDRDIR', '$(rubyhdrdir)/ruby$(target_prefix)'],
[218] Fix | Delete
['ARCHHDRDIR', '$(rubyhdrdir)/$(arch)/ruby$(target_prefix)'],
[219] Fix | Delete
]
[220] Fix | Delete
end
[221] Fix | Delete
dirs << ['target_prefix', (target_prefix ? "/#{target_prefix}" : "")]
[222] Fix | Delete
dirs
[223] Fix | Delete
end
[224] Fix | Delete
[225] Fix | Delete
def map_dir(dir, map = nil)
[226] Fix | Delete
map ||= INSTALL_DIRS
[227] Fix | Delete
map.inject(dir) {|d, (orig, new)| d.gsub(orig, new)}
[228] Fix | Delete
end
[229] Fix | Delete
[230] Fix | Delete
topdir = File.dirname(File.dirname(__FILE__))
[231] Fix | Delete
path = File.expand_path($0)
[232] Fix | Delete
until (dir = File.dirname(path)) == path
[233] Fix | Delete
if File.identical?(dir, topdir)
[234] Fix | Delete
$extmk = true if %r"\A(?:ext|enc|tool|test)\z" =~ File.basename(path)
[235] Fix | Delete
break
[236] Fix | Delete
end
[237] Fix | Delete
path = dir
[238] Fix | Delete
end
[239] Fix | Delete
$extmk ||= false
[240] Fix | Delete
if not $extmk and File.exist?(($hdrdir = RbConfig::CONFIG["rubyhdrdir"]) + "/ruby/ruby.h")
[241] Fix | Delete
$topdir = $hdrdir
[242] Fix | Delete
$top_srcdir = $hdrdir
[243] Fix | Delete
$arch_hdrdir = RbConfig::CONFIG["rubyarchhdrdir"]
[244] Fix | Delete
elsif File.exist?(($hdrdir = ($top_srcdir ||= topdir) + "/include") + "/ruby.h")
[245] Fix | Delete
$topdir ||= RbConfig::CONFIG["topdir"]
[246] Fix | Delete
$arch_hdrdir = "$(extout)/include/$(arch)"
[247] Fix | Delete
else
[248] Fix | Delete
abort <<MESSAGE
[249] Fix | Delete
mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h
[250] Fix | Delete
[251] Fix | Delete
You might have to install separate package for the ruby development
[252] Fix | Delete
environment, ruby-dev or ruby-devel for example.
[253] Fix | Delete
MESSAGE
[254] Fix | Delete
end
[255] Fix | Delete
[256] Fix | Delete
CONFTEST = "conftest".freeze
[257] Fix | Delete
CONFTEST_C = "#{CONFTEST}.c"
[258] Fix | Delete
[259] Fix | Delete
OUTFLAG = CONFIG['OUTFLAG']
[260] Fix | Delete
COUTFLAG = CONFIG['COUTFLAG']
[261] Fix | Delete
CSRCFLAG = CONFIG['CSRCFLAG']
[262] Fix | Delete
CPPOUTFILE = config_string('CPPOUTFILE') {|str| str.sub(/\bconftest\b/, CONFTEST)}
[263] Fix | Delete
[264] Fix | Delete
def rm_f(*files)
[265] Fix | Delete
opt = (Hash === files.last ? [files.pop] : [])
[266] Fix | Delete
FileUtils.rm_f(Dir[*files.flatten], *opt)
[267] Fix | Delete
end
[268] Fix | Delete
module_function :rm_f
[269] Fix | Delete
[270] Fix | Delete
def rm_rf(*files)
[271] Fix | Delete
opt = (Hash === files.last ? [files.pop] : [])
[272] Fix | Delete
FileUtils.rm_rf(Dir[*files.flatten], *opt)
[273] Fix | Delete
end
[274] Fix | Delete
module_function :rm_rf
[275] Fix | Delete
[276] Fix | Delete
# Returns time stamp of the +target+ file if it exists and is newer than or
[277] Fix | Delete
# equal to all of +times+.
[278] Fix | Delete
def modified?(target, times)
[279] Fix | Delete
(t = File.mtime(target)) rescue return nil
[280] Fix | Delete
Array === times or times = [times]
[281] Fix | Delete
t if times.all? {|n| n <= t}
[282] Fix | Delete
end
[283] Fix | Delete
[284] Fix | Delete
def split_libs(*strs)
[285] Fix | Delete
strs.map {|s| s.split(/\s+(?=-|\z)/)}.flatten
[286] Fix | Delete
end
[287] Fix | Delete
[288] Fix | Delete
def merge_libs(*libs)
[289] Fix | Delete
libs.inject([]) do |x, y|
[290] Fix | Delete
y = y.inject([]) {|ary, e| ary.last == e ? ary : ary << e}
[291] Fix | Delete
y.each_with_index do |v, yi|
[292] Fix | Delete
if xi = x.rindex(v)
[293] Fix | Delete
x[(xi+1)..-1] = merge_libs(y[(yi+1)..-1], x[(xi+1)..-1])
[294] Fix | Delete
x[xi, 0] = y[0...yi]
[295] Fix | Delete
break
[296] Fix | Delete
end
[297] Fix | Delete
end and x.concat(y)
[298] Fix | Delete
x
[299] Fix | Delete
end
[300] Fix | Delete
end
[301] Fix | Delete
[302] Fix | Delete
# This is a custom logging module. It generates an mkmf.log file when you
[303] Fix | Delete
# run your extconf.rb script. This can be useful for debugging unexpected
[304] Fix | Delete
# failures.
[305] Fix | Delete
#
[306] Fix | Delete
# This module and its associated methods are meant for internal use only.
[307] Fix | Delete
#
[308] Fix | Delete
module Logging
[309] Fix | Delete
@log = nil
[310] Fix | Delete
@logfile = 'mkmf.log'
[311] Fix | Delete
@orgerr = $stderr.dup
[312] Fix | Delete
@orgout = $stdout.dup
[313] Fix | Delete
@postpone = 0
[314] Fix | Delete
@quiet = $extmk
[315] Fix | Delete
[316] Fix | Delete
def self::log_open
[317] Fix | Delete
@log ||= File::open(@logfile, 'wb')
[318] Fix | Delete
@log.sync = true
[319] Fix | Delete
end
[320] Fix | Delete
[321] Fix | Delete
def self::log_opened?
[322] Fix | Delete
@log and not @log.closed?
[323] Fix | Delete
end
[324] Fix | Delete
[325] Fix | Delete
def self::open
[326] Fix | Delete
log_open
[327] Fix | Delete
$stderr.reopen(@log)
[328] Fix | Delete
$stdout.reopen(@log)
[329] Fix | Delete
yield
[330] Fix | Delete
ensure
[331] Fix | Delete
$stderr.reopen(@orgerr)
[332] Fix | Delete
$stdout.reopen(@orgout)
[333] Fix | Delete
end
[334] Fix | Delete
[335] Fix | Delete
def self::message(*s)
[336] Fix | Delete
log_open
[337] Fix | Delete
@log.printf(*s)
[338] Fix | Delete
end
[339] Fix | Delete
[340] Fix | Delete
def self::logfile file
[341] Fix | Delete
@logfile = file
[342] Fix | Delete
log_close
[343] Fix | Delete
end
[344] Fix | Delete
[345] Fix | Delete
def self::log_close
[346] Fix | Delete
if @log and not @log.closed?
[347] Fix | Delete
@log.flush
[348] Fix | Delete
@log.close
[349] Fix | Delete
@log = nil
[350] Fix | Delete
end
[351] Fix | Delete
end
[352] Fix | Delete
[353] Fix | Delete
def self::postpone
[354] Fix | Delete
tmplog = "mkmftmp#{@postpone += 1}.log"
[355] Fix | Delete
open do
[356] Fix | Delete
log, *save = @log, @logfile, @orgout, @orgerr
[357] Fix | Delete
@log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
[358] Fix | Delete
begin
[359] Fix | Delete
log.print(open {yield @log})
[360] Fix | Delete
ensure
[361] Fix | Delete
@log.close if @log and not @log.closed?
[362] Fix | Delete
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)} if File.exist?(tmplog)
[363] Fix | Delete
@log, @logfile, @orgout, @orgerr = log, *save
[364] Fix | Delete
@postpone -= 1
[365] Fix | Delete
MakeMakefile.rm_f tmplog
[366] Fix | Delete
end
[367] Fix | Delete
end
[368] Fix | Delete
end
[369] Fix | Delete
[370] Fix | Delete
class << self
[371] Fix | Delete
attr_accessor :quiet
[372] Fix | Delete
end
[373] Fix | Delete
end
[374] Fix | Delete
[375] Fix | Delete
def libpath_env
[376] Fix | Delete
# used only if native compiling
[377] Fix | Delete
if libpathenv = config_string("LIBPATHENV")
[378] Fix | Delete
pathenv = ENV[libpathenv]
[379] Fix | Delete
libpath = RbConfig.expand($DEFLIBPATH.join(File::PATH_SEPARATOR))
[380] Fix | Delete
{libpathenv => [libpath, pathenv].compact.join(File::PATH_SEPARATOR)}
[381] Fix | Delete
else
[382] Fix | Delete
{}
[383] Fix | Delete
end
[384] Fix | Delete
end
[385] Fix | Delete
[386] Fix | Delete
def xsystem command, opts = nil
[387] Fix | Delete
varpat = /\$\((\w+)\)|\$\{(\w+)\}/
[388] Fix | Delete
if varpat =~ command
[389] Fix | Delete
vars = Hash.new {|h, k| h[k] = ENV[k]}
[390] Fix | Delete
command = command.dup
[391] Fix | Delete
nil while command.gsub!(varpat) {vars[$1||$2]}
[392] Fix | Delete
end
[393] Fix | Delete
Logging::open do
[394] Fix | Delete
puts command.quote
[395] Fix | Delete
if opts and opts[:werror]
[396] Fix | Delete
result = nil
[397] Fix | Delete
Logging.postpone do |log|
[398] Fix | Delete
output = IO.popen(libpath_env, command, &:read)
[399] Fix | Delete
result = ($?.success? and File.zero?(log.path))
[400] Fix | Delete
output
[401] Fix | Delete
end
[402] Fix | Delete
result
[403] Fix | Delete
else
[404] Fix | Delete
system(libpath_env, command)
[405] Fix | Delete
end
[406] Fix | Delete
end
[407] Fix | Delete
end
[408] Fix | Delete
[409] Fix | Delete
def xpopen command, *mode, &block
[410] Fix | Delete
Logging::open do
[411] Fix | Delete
case mode[0]
[412] Fix | Delete
when nil, /^r/
[413] Fix | Delete
puts "#{command} |"
[414] Fix | Delete
else
[415] Fix | Delete
puts "| #{command}"
[416] Fix | Delete
end
[417] Fix | Delete
IO.popen(libpath_env, command, *mode, &block)
[418] Fix | Delete
end
[419] Fix | Delete
end
[420] Fix | Delete
[421] Fix | Delete
def log_src(src, heading="checked program was")
[422] Fix | Delete
src = src.split(/^/)
[423] Fix | Delete
fmt = "%#{src.size.to_s.size}d: %s"
[424] Fix | Delete
Logging::message <<"EOM"
[425] Fix | Delete
#{heading}:
[426] Fix | Delete
/* begin */
[427] Fix | Delete
EOM
[428] Fix | Delete
src.each_with_index {|line, no| Logging::message fmt, no+1, line}
[429] Fix | Delete
Logging::message <<"EOM"
[430] Fix | Delete
/* end */
[431] Fix | Delete
[432] Fix | Delete
EOM
[433] Fix | Delete
end
[434] Fix | Delete
[435] Fix | Delete
def conftest_source
[436] Fix | Delete
CONFTEST_C
[437] Fix | Delete
end
[438] Fix | Delete
[439] Fix | Delete
def create_tmpsrc(src)
[440] Fix | Delete
src = "#{COMMON_HEADERS}\n#{src}"
[441] Fix | Delete
src = yield(src) if block_given?
[442] Fix | Delete
src.gsub!(/[ \t]+$/, '')
[443] Fix | Delete
src.gsub!(/\A\n+|^\n+$/, '')
[444] Fix | Delete
src.sub!(/[^\n]\z/, "\\&\n")
[445] Fix | Delete
count = 0
[446] Fix | Delete
begin
[447] Fix | Delete
open(conftest_source, "wb") do |cfile|
[448] Fix | Delete
cfile.print src
[449] Fix | Delete
end
[450] Fix | Delete
rescue Errno::EACCES
[451] Fix | Delete
if (count += 1) < 5
[452] Fix | Delete
sleep 0.2
[453] Fix | Delete
retry
[454] Fix | Delete
end
[455] Fix | Delete
end
[456] Fix | Delete
src
[457] Fix | Delete
end
[458] Fix | Delete
[459] Fix | Delete
def have_devel?
[460] Fix | Delete
unless defined? $have_devel
[461] Fix | Delete
$have_devel = true
[462] Fix | Delete
$have_devel = try_link(MAIN_DOES_NOTHING)
[463] Fix | Delete
end
[464] Fix | Delete
$have_devel
[465] Fix | Delete
end
[466] Fix | Delete
[467] Fix | Delete
def try_do(src, command, *opts, &b)
[468] Fix | Delete
unless have_devel?
[469] Fix | Delete
raise <<MSG
[470] Fix | Delete
The compiler failed to generate an executable file.
[471] Fix | Delete
You have to install development tools first.
[472] Fix | Delete
MSG
[473] Fix | Delete
end
[474] Fix | Delete
begin
[475] Fix | Delete
src = create_tmpsrc(src, &b)
[476] Fix | Delete
xsystem(command, *opts)
[477] Fix | Delete
ensure
[478] Fix | Delete
log_src(src)
[479] Fix | Delete
end
[480] Fix | Delete
end
[481] Fix | Delete
[482] Fix | Delete
def link_config(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
[483] Fix | Delete
librubyarg = $extmk ? $LIBRUBYARG_STATIC : "$(LIBRUBYARG)"
[484] Fix | Delete
conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote,
[485] Fix | Delete
'src' => "#{conftest_source}",
[486] Fix | Delete
'arch_hdrdir' => $arch_hdrdir.quote,
[487] Fix | Delete
'top_srcdir' => $top_srcdir.quote,
[488] Fix | Delete
'INCFLAGS' => "#$INCFLAGS",
[489] Fix | Delete
'CPPFLAGS' => "#$CPPFLAGS",
[490] Fix | Delete
'CFLAGS' => "#$CFLAGS",
[491] Fix | Delete
'ARCH_FLAG' => "#$ARCH_FLAG",
[492] Fix | Delete
'LDFLAGS' => "#$LDFLAGS #{ldflags}",
[493] Fix | Delete
'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
[494] Fix | Delete
'LIBS' => "#{librubyarg} #{opt} #$LIBS")
[495] Fix | Delete
conf['LIBPATH'] = libpathflag(libpath.map {|s| RbConfig::expand(s.dup, conf)})
[496] Fix | Delete
conf
[497] Fix | Delete
end
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function