Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: mkmf.rb
# module to create Makefile for extension modules
[0] Fix | Delete
# invoke like: ruby -r mkmf extconf.rb
[1] Fix | Delete
[2] Fix | Delete
require 'rbconfig'
[3] Fix | Delete
require 'fileutils'
[4] Fix | Delete
require 'shellwords'
[5] Fix | Delete
[6] Fix | Delete
CONFIG = Config::MAKEFILE_CONFIG
[7] Fix | Delete
ORIG_LIBPATH = ENV['LIB']
[8] Fix | Delete
[9] Fix | Delete
CXX_EXT = %w[cc cxx cpp]
[10] Fix | Delete
if /mswin|bccwin|mingw|msdosdjgpp|human|os2/ !~ CONFIG['build_os']
[11] Fix | Delete
CXX_EXT.concat(%w[C])
[12] Fix | Delete
end
[13] Fix | Delete
SRC_EXT = %w[c m].concat(CXX_EXT)
[14] Fix | Delete
$static = $config_h = nil
[15] Fix | Delete
$default_static = $static
[16] Fix | Delete
[17] Fix | Delete
unless defined? $configure_args
[18] Fix | Delete
$configure_args = {}
[19] Fix | Delete
args = CONFIG["configure_args"]
[20] Fix | Delete
if ENV["CONFIGURE_ARGS"]
[21] Fix | Delete
args << " " << ENV["CONFIGURE_ARGS"]
[22] Fix | Delete
end
[23] Fix | Delete
for arg in Shellwords::shellwords(args)
[24] Fix | Delete
arg, val = arg.split('=', 2)
[25] Fix | Delete
next unless arg
[26] Fix | Delete
arg.tr!('_', '-')
[27] Fix | Delete
if arg.sub!(/^(?!--)/, '--')
[28] Fix | Delete
val or next
[29] Fix | Delete
arg.downcase!
[30] Fix | Delete
end
[31] Fix | Delete
next if /^--(?:top|topsrc|src|cur)dir$/ =~ arg
[32] Fix | Delete
$configure_args[arg] = val || true
[33] Fix | Delete
end
[34] Fix | Delete
for arg in ARGV
[35] Fix | Delete
arg, val = arg.split('=', 2)
[36] Fix | Delete
next unless arg
[37] Fix | Delete
arg.tr!('_', '-')
[38] Fix | Delete
if arg.sub!(/^(?!--)/, '--')
[39] Fix | Delete
val or next
[40] Fix | Delete
arg.downcase!
[41] Fix | Delete
end
[42] Fix | Delete
$configure_args[arg] = val || true
[43] Fix | Delete
end
[44] Fix | Delete
end
[45] Fix | Delete
[46] Fix | Delete
$libdir = CONFIG["libdir"]
[47] Fix | Delete
$rubylibdir = CONFIG["rubylibdir"]
[48] Fix | Delete
$archdir = CONFIG["archdir"]
[49] Fix | Delete
$sitedir = CONFIG["sitedir"]
[50] Fix | Delete
$sitelibdir = CONFIG["sitelibdir"]
[51] Fix | Delete
$sitearchdir = CONFIG["sitearchdir"]
[52] Fix | Delete
$vendordir = CONFIG["vendordir"]
[53] Fix | Delete
$vendorlibdir = CONFIG["vendorlibdir"]
[54] Fix | Delete
$vendorarchdir = CONFIG["vendorarchdir"]
[55] Fix | Delete
[56] Fix | Delete
$mswin = /mswin/ =~ RUBY_PLATFORM
[57] Fix | Delete
$bccwin = /bccwin/ =~ RUBY_PLATFORM
[58] Fix | Delete
$mingw = /mingw/ =~ RUBY_PLATFORM
[59] Fix | Delete
$cygwin = /cygwin/ =~ RUBY_PLATFORM
[60] Fix | Delete
$human = /human/ =~ RUBY_PLATFORM
[61] Fix | Delete
$netbsd = /netbsd/ =~ RUBY_PLATFORM
[62] Fix | Delete
$os2 = /os2/ =~ RUBY_PLATFORM
[63] Fix | Delete
$beos = /beos/ =~ RUBY_PLATFORM
[64] Fix | Delete
$solaris = /solaris/ =~ RUBY_PLATFORM
[65] Fix | Delete
$dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
[66] Fix | Delete
[67] Fix | Delete
# :stopdoc:
[68] Fix | Delete
[69] Fix | Delete
def config_string(key, config = CONFIG)
[70] Fix | Delete
s = config[key] and !s.empty? and block_given? ? yield(s) : s
[71] Fix | Delete
end
[72] Fix | Delete
[73] Fix | Delete
def dir_re(dir)
[74] Fix | Delete
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?')
[75] Fix | Delete
end
[76] Fix | Delete
[77] Fix | Delete
INSTALL_DIRS = [
[78] Fix | Delete
[dir_re('commondir'), "$(RUBYCOMMONDIR)"],
[79] Fix | Delete
[dir_re('sitedir'), "$(RUBYCOMMONDIR)"],
[80] Fix | Delete
[dir_re('vendordir'), "$(RUBYCOMMONDIR)"],
[81] Fix | Delete
[dir_re('rubylibdir'), "$(RUBYLIBDIR)"],
[82] Fix | Delete
[dir_re('archdir'), "$(RUBYARCHDIR)"],
[83] Fix | Delete
[dir_re('sitelibdir'), "$(RUBYLIBDIR)"],
[84] Fix | Delete
[dir_re('vendorlibdir'), "$(RUBYLIBDIR)"],
[85] Fix | Delete
[dir_re('sitearchdir'), "$(RUBYARCHDIR)"],
[86] Fix | Delete
[dir_re('bindir'), "$(BINDIR)"],
[87] Fix | Delete
[dir_re('vendorarchdir'), "$(RUBYARCHDIR)"],
[88] Fix | Delete
]
[89] Fix | Delete
[90] Fix | Delete
def install_dirs(target_prefix = nil)
[91] Fix | Delete
if $extout
[92] Fix | Delete
dirs = [
[93] Fix | Delete
['BINDIR', '$(extout)/bin'],
[94] Fix | Delete
['RUBYCOMMONDIR', '$(extout)/common'],
[95] Fix | Delete
['RUBYLIBDIR', '$(RUBYCOMMONDIR)$(target_prefix)'],
[96] Fix | Delete
['RUBYARCHDIR', '$(extout)/$(arch)$(target_prefix)'],
[97] Fix | Delete
['extout', "#$extout"],
[98] Fix | Delete
['extout_prefix', "#$extout_prefix"],
[99] Fix | Delete
]
[100] Fix | Delete
elsif $extmk
[101] Fix | Delete
dirs = [
[102] Fix | Delete
['BINDIR', '$(bindir)'],
[103] Fix | Delete
['RUBYCOMMONDIR', '$(rubylibdir)'],
[104] Fix | Delete
['RUBYLIBDIR', '$(rubylibdir)$(target_prefix)'],
[105] Fix | Delete
['RUBYARCHDIR', '$(archdir)$(target_prefix)'],
[106] Fix | Delete
]
[107] Fix | Delete
elsif $configure_args.has_key?('--vendor')
[108] Fix | Delete
dirs = [
[109] Fix | Delete
['BINDIR', '$(bindir)'],
[110] Fix | Delete
['RUBYCOMMONDIR', '$(vendordir)$(target_prefix)'],
[111] Fix | Delete
['RUBYLIBDIR', '$(vendorlibdir)$(target_prefix)'],
[112] Fix | Delete
['RUBYARCHDIR', '$(vendorarchdir)$(target_prefix)'],
[113] Fix | Delete
]
[114] Fix | Delete
else
[115] Fix | Delete
dirs = [
[116] Fix | Delete
['BINDIR', '$(bindir)'],
[117] Fix | Delete
['RUBYCOMMONDIR', '$(sitedir)$(target_prefix)'],
[118] Fix | Delete
['RUBYLIBDIR', '$(sitelibdir)$(target_prefix)'],
[119] Fix | Delete
['RUBYARCHDIR', '$(sitearchdir)$(target_prefix)'],
[120] Fix | Delete
]
[121] Fix | Delete
end
[122] Fix | Delete
dirs << ['target_prefix', (target_prefix ? "/#{target_prefix}" : "")]
[123] Fix | Delete
dirs
[124] Fix | Delete
end
[125] Fix | Delete
[126] Fix | Delete
def map_dir(dir, map = nil)
[127] Fix | Delete
map ||= INSTALL_DIRS
[128] Fix | Delete
map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)}
[129] Fix | Delete
end
[130] Fix | Delete
[131] Fix | Delete
topdir = File.dirname(libdir = File.dirname(__FILE__))
[132] Fix | Delete
extdir = File.expand_path("ext", topdir)
[133] Fix | Delete
$extmk = File.expand_path($0)[0, extdir.size+1] == extdir+"/"
[134] Fix | Delete
if not $extmk and File.exist?(($hdrdir = Config::CONFIG["archdir"]) + "/ruby.h")
[135] Fix | Delete
$topdir = $hdrdir
[136] Fix | Delete
elsif File.exist?(($hdrdir = ($top_srcdir ||= topdir)) + "/ruby.h") and
[137] Fix | Delete
File.exist?(($topdir ||= Config::CONFIG["topdir"]) + "/config.h")
[138] Fix | Delete
else
[139] Fix | Delete
abort "mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h"
[140] Fix | Delete
end
[141] Fix | Delete
[142] Fix | Delete
OUTFLAG = CONFIG['OUTFLAG']
[143] Fix | Delete
CPPOUTFILE = CONFIG['CPPOUTFILE']
[144] Fix | Delete
[145] Fix | Delete
CONFTEST_C = "conftest.c"
[146] Fix | Delete
[147] Fix | Delete
class String
[148] Fix | Delete
# Wraps a string in escaped quotes if it contains whitespace.
[149] Fix | Delete
def quote
[150] Fix | Delete
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
[151] Fix | Delete
end
[152] Fix | Delete
[153] Fix | Delete
# Generates a string used as cpp macro name.
[154] Fix | Delete
def tr_cpp
[155] Fix | Delete
strip.upcase.tr_s("^A-Z0-9_", "_")
[156] Fix | Delete
end
[157] Fix | Delete
end
[158] Fix | Delete
class Array
[159] Fix | Delete
# Wraps all strings in escaped quotes if they contain whitespace.
[160] Fix | Delete
def quote
[161] Fix | Delete
map {|s| s.quote}
[162] Fix | Delete
end
[163] Fix | Delete
end
[164] Fix | Delete
[165] Fix | Delete
def rm_f(*files)
[166] Fix | Delete
FileUtils.rm_f(Dir[files.join("\0")])
[167] Fix | Delete
end
[168] Fix | Delete
[169] Fix | Delete
# Returns time stamp of the +target+ file if it exists and is newer
[170] Fix | Delete
# than or equal to all of +times+.
[171] Fix | Delete
def modified?(target, times)
[172] Fix | Delete
(t = File.mtime(target)) rescue return nil
[173] Fix | Delete
Array === times or times = [times]
[174] Fix | Delete
t if times.all? {|n| n <= t}
[175] Fix | Delete
end
[176] Fix | Delete
[177] Fix | Delete
def merge_libs(*libs)
[178] Fix | Delete
libs.inject([]) do |x, y|
[179] Fix | Delete
xy = x & y
[180] Fix | Delete
xn = yn = 0
[181] Fix | Delete
y = y.inject([]) {|ary, e| ary.last == e ? ary : ary << e}
[182] Fix | Delete
y.each_with_index do |v, yi|
[183] Fix | Delete
if xy.include?(v)
[184] Fix | Delete
xi = [x.index(v), xn].max()
[185] Fix | Delete
x[xi, 1] = y[yn..yi]
[186] Fix | Delete
xn, yn = xi + (yi - yn + 1), yi + 1
[187] Fix | Delete
end
[188] Fix | Delete
end
[189] Fix | Delete
x.concat(y[yn..-1] || [])
[190] Fix | Delete
end
[191] Fix | Delete
end
[192] Fix | Delete
[193] Fix | Delete
# This is a custom logging module. It generates an mkmf.log file when you
[194] Fix | Delete
# run your extconf.rb script. This can be useful for debugging unexpected
[195] Fix | Delete
# failures.
[196] Fix | Delete
#
[197] Fix | Delete
# This module and its associated methods are meant for internal use only.
[198] Fix | Delete
#
[199] Fix | Delete
module Logging
[200] Fix | Delete
@log = nil
[201] Fix | Delete
@logfile = 'mkmf.log'
[202] Fix | Delete
@orgerr = $stderr.dup
[203] Fix | Delete
@orgout = $stdout.dup
[204] Fix | Delete
@postpone = 0
[205] Fix | Delete
@quiet = $extmk
[206] Fix | Delete
[207] Fix | Delete
def self::open
[208] Fix | Delete
@log ||= File::open(@logfile, 'w')
[209] Fix | Delete
@log.sync = true
[210] Fix | Delete
$stderr.reopen(@log)
[211] Fix | Delete
$stdout.reopen(@log)
[212] Fix | Delete
yield
[213] Fix | Delete
ensure
[214] Fix | Delete
$stderr.reopen(@orgerr)
[215] Fix | Delete
$stdout.reopen(@orgout)
[216] Fix | Delete
end
[217] Fix | Delete
[218] Fix | Delete
def self::message(*s)
[219] Fix | Delete
@log ||= File::open(@logfile, 'w')
[220] Fix | Delete
@log.sync = true
[221] Fix | Delete
@log.printf(*s)
[222] Fix | Delete
end
[223] Fix | Delete
[224] Fix | Delete
def self::logfile file
[225] Fix | Delete
@logfile = file
[226] Fix | Delete
if @log and not @log.closed?
[227] Fix | Delete
@log.flush
[228] Fix | Delete
@log.close
[229] Fix | Delete
@log = nil
[230] Fix | Delete
end
[231] Fix | Delete
end
[232] Fix | Delete
[233] Fix | Delete
def self::postpone
[234] Fix | Delete
tmplog = "mkmftmp#{@postpone += 1}.log"
[235] Fix | Delete
open do
[236] Fix | Delete
log, *save = @log, @logfile, @orgout, @orgerr
[237] Fix | Delete
@log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
[238] Fix | Delete
begin
[239] Fix | Delete
log.print(open {yield})
[240] Fix | Delete
@log.close
[241] Fix | Delete
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)}
[242] Fix | Delete
ensure
[243] Fix | Delete
@log, @logfile, @orgout, @orgerr = log, *save
[244] Fix | Delete
@postpone -= 1
[245] Fix | Delete
rm_f tmplog
[246] Fix | Delete
end
[247] Fix | Delete
end
[248] Fix | Delete
end
[249] Fix | Delete
[250] Fix | Delete
class << self
[251] Fix | Delete
attr_accessor :quiet
[252] Fix | Delete
end
[253] Fix | Delete
end
[254] Fix | Delete
[255] Fix | Delete
def xsystem command
[256] Fix | Delete
varpat = /\$\((\w+)\)|\$\{(\w+)\}/
[257] Fix | Delete
if varpat =~ command
[258] Fix | Delete
vars = Hash.new {|h, k| h[k] = ''; ENV[k]}
[259] Fix | Delete
command = command.dup
[260] Fix | Delete
nil while command.gsub!(varpat) {vars[$1||$2]}
[261] Fix | Delete
end
[262] Fix | Delete
Logging::open do
[263] Fix | Delete
puts command.quote
[264] Fix | Delete
system(command)
[265] Fix | Delete
end
[266] Fix | Delete
end
[267] Fix | Delete
[268] Fix | Delete
def xpopen command, *mode, &block
[269] Fix | Delete
Logging::open do
[270] Fix | Delete
case mode[0]
[271] Fix | Delete
when nil, /^r/
[272] Fix | Delete
puts "#{command} |"
[273] Fix | Delete
else
[274] Fix | Delete
puts "| #{command}"
[275] Fix | Delete
end
[276] Fix | Delete
IO.popen(command, *mode, &block)
[277] Fix | Delete
end
[278] Fix | Delete
end
[279] Fix | Delete
[280] Fix | Delete
def log_src(src)
[281] Fix | Delete
src = src.split(/^/)
[282] Fix | Delete
fmt = "%#{src.size.to_s.size}d: %s"
[283] Fix | Delete
Logging::message <<"EOM"
[284] Fix | Delete
checked program was:
[285] Fix | Delete
/* begin */
[286] Fix | Delete
EOM
[287] Fix | Delete
src.each_with_index {|line, no| Logging::message fmt, no+1, line}
[288] Fix | Delete
Logging::message <<"EOM"
[289] Fix | Delete
/* end */
[290] Fix | Delete
[291] Fix | Delete
EOM
[292] Fix | Delete
end
[293] Fix | Delete
[294] Fix | Delete
def create_tmpsrc(src)
[295] Fix | Delete
src = yield(src) if block_given?
[296] Fix | Delete
src = src.gsub(/[ \t]+$/, '').gsub(/\A\n+|^\n+$/, '').sub(/[^\n]\z/, "\\&\n")
[297] Fix | Delete
open(CONFTEST_C, "wb") do |cfile|
[298] Fix | Delete
cfile.print src
[299] Fix | Delete
end
[300] Fix | Delete
src
[301] Fix | Delete
end
[302] Fix | Delete
[303] Fix | Delete
def try_do(src, command, &b)
[304] Fix | Delete
src = create_tmpsrc(src, &b)
[305] Fix | Delete
xsystem(command)
[306] Fix | Delete
ensure
[307] Fix | Delete
log_src(src)
[308] Fix | Delete
end
[309] Fix | Delete
[310] Fix | Delete
def link_command(ldflags, opt="", libpath=$DEFLIBPATH|$LIBPATH)
[311] Fix | Delete
conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote,
[312] Fix | Delete
'src' => CONFTEST_C,
[313] Fix | Delete
'INCFLAGS' => $INCFLAGS,
[314] Fix | Delete
'CPPFLAGS' => $CPPFLAGS,
[315] Fix | Delete
'CFLAGS' => "#$CFLAGS",
[316] Fix | Delete
'ARCH_FLAG' => "#$ARCH_FLAG",
[317] Fix | Delete
'LDFLAGS' => "#$LDFLAGS #{ldflags}",
[318] Fix | Delete
'LIBPATH' => libpathflag(libpath),
[319] Fix | Delete
'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
[320] Fix | Delete
'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
[321] Fix | Delete
Config::expand(TRY_LINK.dup, conf)
[322] Fix | Delete
end
[323] Fix | Delete
[324] Fix | Delete
def cc_command(opt="")
[325] Fix | Delete
conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
[326] Fix | Delete
Config::expand("$(CC) #$INCFLAGS #$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} -c #{CONFTEST_C}",
[327] Fix | Delete
conf)
[328] Fix | Delete
end
[329] Fix | Delete
[330] Fix | Delete
def cpp_command(outfile, opt="")
[331] Fix | Delete
conf = Config::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote)
[332] Fix | Delete
Config::expand("$(CPP) #$INCFLAGS #$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}",
[333] Fix | Delete
conf)
[334] Fix | Delete
end
[335] Fix | Delete
[336] Fix | Delete
def libpathflag(libpath=$DEFLIBPATH|$LIBPATH)
[337] Fix | Delete
libpath.map{|x|
[338] Fix | Delete
case x
[339] Fix | Delete
when "$(topdir)", /\A\./
[340] Fix | Delete
LIBPATHFLAG
[341] Fix | Delete
else
[342] Fix | Delete
LIBPATHFLAG+RPATHFLAG
[343] Fix | Delete
end % x.quote
[344] Fix | Delete
}.join
[345] Fix | Delete
end
[346] Fix | Delete
[347] Fix | Delete
def try_link0(src, opt="", &b)
[348] Fix | Delete
try_do(src, link_command("", opt), &b)
[349] Fix | Delete
end
[350] Fix | Delete
[351] Fix | Delete
def try_link(src, opt="", &b)
[352] Fix | Delete
try_link0(src, opt, &b)
[353] Fix | Delete
ensure
[354] Fix | Delete
rm_f "conftest*", "c0x32*"
[355] Fix | Delete
end
[356] Fix | Delete
[357] Fix | Delete
def try_compile(src, opt="", &b)
[358] Fix | Delete
try_do(src, cc_command(opt), &b)
[359] Fix | Delete
ensure
[360] Fix | Delete
rm_f "conftest*"
[361] Fix | Delete
end
[362] Fix | Delete
[363] Fix | Delete
def try_cpp(src, opt="", &b)
[364] Fix | Delete
try_do(src, cpp_command(CPPOUTFILE, opt), &b)
[365] Fix | Delete
ensure
[366] Fix | Delete
rm_f "conftest*"
[367] Fix | Delete
end
[368] Fix | Delete
[369] Fix | Delete
def cpp_include(header)
[370] Fix | Delete
if header
[371] Fix | Delete
header = [header] unless header.kind_of? Array
[372] Fix | Delete
header.map {|h| "#include <#{h}>\n"}.join
[373] Fix | Delete
else
[374] Fix | Delete
""
[375] Fix | Delete
end
[376] Fix | Delete
end
[377] Fix | Delete
[378] Fix | Delete
def with_cppflags(flags)
[379] Fix | Delete
cppflags = $CPPFLAGS
[380] Fix | Delete
$CPPFLAGS = flags
[381] Fix | Delete
ret = yield
[382] Fix | Delete
ensure
[383] Fix | Delete
$CPPFLAGS = cppflags unless ret
[384] Fix | Delete
end
[385] Fix | Delete
[386] Fix | Delete
def with_cflags(flags)
[387] Fix | Delete
cflags = $CFLAGS
[388] Fix | Delete
$CFLAGS = flags
[389] Fix | Delete
ret = yield
[390] Fix | Delete
ensure
[391] Fix | Delete
$CFLAGS = cflags unless ret
[392] Fix | Delete
end
[393] Fix | Delete
[394] Fix | Delete
def with_ldflags(flags)
[395] Fix | Delete
ldflags = $LDFLAGS
[396] Fix | Delete
$LDFLAGS = flags
[397] Fix | Delete
ret = yield
[398] Fix | Delete
ensure
[399] Fix | Delete
$LDFLAGS = ldflags unless ret
[400] Fix | Delete
end
[401] Fix | Delete
[402] Fix | Delete
def try_static_assert(expr, headers = nil, opt = "", &b)
[403] Fix | Delete
headers = cpp_include(headers)
[404] Fix | Delete
try_compile(<<SRC, opt, &b)
[405] Fix | Delete
#{COMMON_HEADERS}
[406] Fix | Delete
#{headers}
[407] Fix | Delete
/*top*/
[408] Fix | Delete
int conftest_const[(#{expr}) ? 1 : -1];
[409] Fix | Delete
SRC
[410] Fix | Delete
end
[411] Fix | Delete
[412] Fix | Delete
def try_constant(const, headers = nil, opt = "", &b)
[413] Fix | Delete
includes = cpp_include(headers)
[414] Fix | Delete
if CROSS_COMPILING
[415] Fix | Delete
if try_static_assert("#{const} > 0", headers, opt)
[416] Fix | Delete
# positive constant
[417] Fix | Delete
elsif try_static_assert("#{const} < 0", headers, opt)
[418] Fix | Delete
neg = true
[419] Fix | Delete
const = "-(#{const})"
[420] Fix | Delete
elsif try_static_assert("#{const} == 0", headers, opt)
[421] Fix | Delete
return 0
[422] Fix | Delete
else
[423] Fix | Delete
# not a constant
[424] Fix | Delete
return nil
[425] Fix | Delete
end
[426] Fix | Delete
upper = 1
[427] Fix | Delete
lower = 0
[428] Fix | Delete
until try_static_assert("#{const} <= #{upper}", headers, opt)
[429] Fix | Delete
lower = upper
[430] Fix | Delete
upper <<= 1
[431] Fix | Delete
end
[432] Fix | Delete
return nil unless lower
[433] Fix | Delete
while upper > lower + 1
[434] Fix | Delete
mid = (upper + lower) / 2
[435] Fix | Delete
if try_static_assert("#{const} > #{mid}", headers, opt)
[436] Fix | Delete
lower = mid
[437] Fix | Delete
else
[438] Fix | Delete
upper = mid
[439] Fix | Delete
end
[440] Fix | Delete
end
[441] Fix | Delete
upper = -upper if neg
[442] Fix | Delete
return upper
[443] Fix | Delete
else
[444] Fix | Delete
src = %{#{COMMON_HEADERS}
[445] Fix | Delete
#{includes}
[446] Fix | Delete
#include <stdio.h>
[447] Fix | Delete
/*top*/
[448] Fix | Delete
int conftest_const = (int)(#{const});
[449] Fix | Delete
int main() {printf("%d\\n", conftest_const); return 0;}
[450] Fix | Delete
}
[451] Fix | Delete
if try_link0(src, opt, &b)
[452] Fix | Delete
xpopen("./conftest") do |f|
[453] Fix | Delete
return Integer(f.gets)
[454] Fix | Delete
end
[455] Fix | Delete
end
[456] Fix | Delete
end
[457] Fix | Delete
nil
[458] Fix | Delete
end
[459] Fix | Delete
[460] Fix | Delete
def try_func(func, libs, headers = nil, &b)
[461] Fix | Delete
headers = cpp_include(headers)
[462] Fix | Delete
try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
[463] Fix | Delete
#{COMMON_HEADERS}
[464] Fix | Delete
#{headers}
[465] Fix | Delete
/*top*/
[466] Fix | Delete
int main() { return 0; }
[467] Fix | Delete
int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
[468] Fix | Delete
SRC
[469] Fix | Delete
#{headers}
[470] Fix | Delete
/*top*/
[471] Fix | Delete
int main() { return 0; }
[472] Fix | Delete
int t() { #{func}(); return 0; }
[473] Fix | Delete
SRC
[474] Fix | Delete
end
[475] Fix | Delete
[476] Fix | Delete
def try_var(var, headers = nil, &b)
[477] Fix | Delete
headers = cpp_include(headers)
[478] Fix | Delete
try_compile(<<"SRC", &b)
[479] Fix | Delete
#{COMMON_HEADERS}
[480] Fix | Delete
#{headers}
[481] Fix | Delete
/*top*/
[482] Fix | Delete
int main() { return 0; }
[483] Fix | Delete
int t() { const volatile void *volatile p; p = &(&#{var})[0]; return 0; }
[484] Fix | Delete
SRC
[485] Fix | Delete
end
[486] Fix | Delete
[487] Fix | Delete
def egrep_cpp(pat, src, opt = "", &b)
[488] Fix | Delete
src = create_tmpsrc(src, &b)
[489] Fix | Delete
xpopen(cpp_command('', opt)) do |f|
[490] Fix | Delete
if Regexp === pat
[491] Fix | Delete
puts(" ruby -ne 'print if #{pat.inspect}'")
[492] Fix | Delete
f.grep(pat) {|l|
[493] Fix | Delete
puts "#{f.lineno}: #{l}"
[494] Fix | Delete
return true
[495] Fix | Delete
}
[496] Fix | Delete
false
[497] Fix | Delete
else
[498] Fix | Delete
puts(" egrep '#{pat}'")
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function