зеркало из https://github.com/github/ruby.git
* ext/extmk.rb (extract_makefile): extract previously collected
informations from existing Makefile. * ext/socket/extconf.rb: check if getaddrinfo() works fine only when wide-getaddrinfo option is not given. fixed: [ruby-dev:25422] * ext/tk/extconf.rb: separate tkutil configuration. * lib/mkmf.rb ($extmk): check if under ext directory. * lib/mkmf.rb (Logging.postpone): allow recursive operation. * lib/mkmf.rb (try_constant): make sure if really a constant, reduce the number of times of compile. * lib/mkmf.rb (have_macro, have_var, byte_order): new functions. * lib/mkmf.rb (find_library): allow directory list with separators. * lib/mkmf.rb (arg_config): manage provided configuration options. * lib/mkmf.rb (dir_config): accept arrays of directory names as default values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
983de47edc
Коммит
7a07ffe479
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
||||||
|
Sun Feb 6 23:51:30 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/extmk.rb (extract_makefile): extract previously collected
|
||||||
|
informations from existing Makefile.
|
||||||
|
|
||||||
|
* ext/socket/extconf.rb: check if getaddrinfo() works fine only when
|
||||||
|
wide-getaddrinfo option is not given. fixed: [ruby-dev:25422]
|
||||||
|
|
||||||
|
* ext/tk/extconf.rb: separate tkutil configuration.
|
||||||
|
|
||||||
|
* lib/mkmf.rb ($extmk): check if under ext directory.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (Logging.postpone): allow recursive operation.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (try_constant): make sure if really a constant, reduce
|
||||||
|
the number of times of compile.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (have_macro, have_var, byte_order): new functions.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (find_library): allow directory list with separators.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (arg_config): manage provided configuration options.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (dir_config): accept arrays of directory names as
|
||||||
|
default values.
|
||||||
|
|
||||||
Sun Feb 6 19:20:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
|
Sun Feb 6 19:20:05 2005 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (stack_extend): add prototype because VC++8 doesn't
|
* eval.c (stack_extend): add prototype because VC++8 doesn't
|
||||||
|
|
124
ext/extmk.rb
124
ext/extmk.rb
|
@ -17,6 +17,7 @@ alias $0 $progname
|
||||||
|
|
||||||
$extlist = []
|
$extlist = []
|
||||||
$extupdate = false
|
$extupdate = false
|
||||||
|
$compiled = {}
|
||||||
|
|
||||||
$:.replace ["."]
|
$:.replace ["."]
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
@ -44,6 +45,36 @@ def relative_from(path, base)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def extract_makefile(makefile, force = false)
|
||||||
|
m = File.read(makefile)
|
||||||
|
if !(target = m[/^TARGET[ \t]*=[ \t]*(\S*)/, 1])
|
||||||
|
return force
|
||||||
|
end
|
||||||
|
installrb = {}
|
||||||
|
m.scan(/^install-rb-default:[ \t]*(\S+)\n\1:[ \t]*(\S+)/) {installrb[$2] = $1}
|
||||||
|
oldrb = installrb.keys.sort
|
||||||
|
newrb = install_rb(nil, "").collect {|d, *f| f}.flatten.sort
|
||||||
|
unless (oldrb -= newrb).empty?
|
||||||
|
FileUtils.rm_f(oldrb.collect {|old| Config.expand(installrb[old])}, :verbose => true)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if target_prefix = m[/^target_prefix[ \t]*=[ \t]*\/(.*)/, 1]
|
||||||
|
target = "#{target_prefix}/#{target}"
|
||||||
|
end
|
||||||
|
$target = target
|
||||||
|
/^STATIC_LIB[ \t]*=[ \t]*\S+/ =~ m or $static = nil
|
||||||
|
$preload = Shellwords.shellwords(m[/^preload[ \t]*=[ \t]*(.*)/, 1] || "")
|
||||||
|
$DLDFLAGS += " " + (m[/^DLDFLAGS[ \t]*=[ \t]*(.*)/, 1] || "")
|
||||||
|
if s = m[/^LIBS[ \t]*=[ \t]*(.*)/, 1]
|
||||||
|
s.sub!(/^#{Regexp.quote($LIBRUBYARG)} */, "")
|
||||||
|
s.sub!(/ *#{Regexp.quote($LIBS)}$/, "")
|
||||||
|
$libs = s
|
||||||
|
end
|
||||||
|
$LOCAL_LIBS = m[/^LOCAL_LIBS[ \t]*=[ \t]*(.*)/, 1] || ""
|
||||||
|
$LIBPATH = Shellwords.shellwords(m[/^libpath[ \t]*=[ \t]*(.*)/, 1] || "") - %w[$(libdir) $(topdir)]
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def extmake(target)
|
def extmake(target)
|
||||||
print "#{$message} #{target}\n"
|
print "#{$message} #{target}\n"
|
||||||
$stdout.flush
|
$stdout.flush
|
||||||
|
@ -57,8 +88,6 @@ def extmake(target)
|
||||||
return true if $nodynamic and not $static
|
return true if $nodynamic and not $static
|
||||||
end
|
end
|
||||||
|
|
||||||
init_mkmf
|
|
||||||
|
|
||||||
FileUtils.mkpath target unless File.directory?(target)
|
FileUtils.mkpath target unless File.directory?(target)
|
||||||
begin
|
begin
|
||||||
dir = Dir.pwd
|
dir = Dir.pwd
|
||||||
|
@ -73,18 +102,20 @@ def extmake(target)
|
||||||
$mdir = target
|
$mdir = target
|
||||||
$srcdir = File.join($top_srcdir, "ext", $mdir)
|
$srcdir = File.join($top_srcdir, "ext", $mdir)
|
||||||
$preload = nil
|
$preload = nil
|
||||||
|
$compiled[target] = false
|
||||||
makefile = "./Makefile"
|
makefile = "./Makefile"
|
||||||
|
ok = File.exist?(makefile)
|
||||||
unless $ignore
|
unless $ignore
|
||||||
if !(t = modified?(makefile, MTIMES)) ||
|
Config::CONFIG["srcdir"] = $srcdir
|
||||||
%W<#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb
|
Config::CONFIG["topdir"] = $topdir
|
||||||
#{$srcdir}/depend>.any? {|f| modified?(f, [t])}
|
begin
|
||||||
then
|
if (!(ok &&= extract_makefile(makefile)) ||
|
||||||
$defs = []
|
!(t = modified?(makefile, MTIMES)) ||
|
||||||
Logging::logfile 'mkmf.log'
|
%W"#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb #{$srcdir}/depend".any? {|f| modified?(f, [t])})
|
||||||
Config::CONFIG["srcdir"] = $srcdir
|
then
|
||||||
Config::CONFIG["topdir"] = $topdir
|
init_mkmf
|
||||||
rm_f makefile
|
Logging::logfile 'mkmf.log'
|
||||||
begin
|
rm_f makefile
|
||||||
if File.exist?($0 = "#{$srcdir}/makefile.rb")
|
if File.exist?($0 = "#{$srcdir}/makefile.rb")
|
||||||
load $0
|
load $0
|
||||||
elsif File.exist?($0 = "#{$srcdir}/extconf.rb")
|
elsif File.exist?($0 = "#{$srcdir}/extconf.rb")
|
||||||
|
@ -93,40 +124,23 @@ def extmake(target)
|
||||||
create_makefile(target)
|
create_makefile(target)
|
||||||
end
|
end
|
||||||
$extupdate = true
|
$extupdate = true
|
||||||
File.exist?(makefile)
|
ok = File.exist?(makefile)
|
||||||
rescue SystemExit
|
|
||||||
# ignore
|
|
||||||
ensure
|
|
||||||
rm_f "conftest*"
|
|
||||||
$0 = $PROGRAM_NAME
|
|
||||||
Config::CONFIG["srcdir"] = $top_srcdir
|
|
||||||
end
|
end
|
||||||
else
|
rescue SystemExit
|
||||||
if $static
|
# ignore
|
||||||
m = File.read(makefile)
|
ensure
|
||||||
if !($target = m[/^TARGET[ \t]*=[ \t]*(\S*)/, 1])
|
rm_f "conftest*"
|
||||||
$static = nil
|
config = $0
|
||||||
elsif target_prefix = m[/^target_prefix[ \t]*=[ \t]*\/(.*)/, 1]
|
$0 = $PROGRAM_NAME
|
||||||
$target = "#{target_prefix}/#{$target}"
|
Config::CONFIG["srcdir"] = $top_srcdir
|
||||||
end
|
Config::CONFIG["topdir"] = topdir
|
||||||
/^STATIC_LIB[ \t]*=[ \t]*\S+/ =~ m or $static = nil
|
end
|
||||||
$preload = Shellwords.shellwords(m[/^preload[ \t]*=[ \t]*(.*)/, 1] || "")
|
end
|
||||||
$DLDFLAGS += " " + (m[/^DLDFLAGS[ \t]*=[ \t]*(.*)/, 1] || "")
|
ok = yield(ok) if block_given?
|
||||||
if s = m[/^LIBS[ \t]*=[ \t]*(.*)/, 1]
|
unless ok
|
||||||
s.sub!(/^#{Regexp.quote($LIBRUBYARG)} */, "")
|
open(makefile, "w") do |f|
|
||||||
s.sub!(/ *#{Regexp.quote($LIBS)}$/, "")
|
f.print dummy_makefile($srcdir)
|
||||||
$libs = s
|
|
||||||
end
|
|
||||||
$LOCAL_LIBS = m[/^LOCAL_LIBS[ \t]*=[ \t]*(.*)/, 1] || ""
|
|
||||||
$LIBPATH = Shellwords.shellwords(m[/^libpath[ \t]*=[ \t]*(.*)/, 1] || "") -
|
|
||||||
%w[$(libdir) $(topdir)]
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
File.exist?(makefile)
|
|
||||||
end or open(makefile, "w") do |f|
|
|
||||||
f.print dummy_makefile($srcdir)
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
args = sysquote($mflags)
|
args = sysquote($mflags)
|
||||||
|
@ -137,6 +151,7 @@ def extmake(target)
|
||||||
unless system($make, *args)
|
unless system($make, *args)
|
||||||
$ignore or $continue or return false
|
$ignore or $continue or return false
|
||||||
end
|
end
|
||||||
|
$compiled[target] = true
|
||||||
if $clean and $clean != true
|
if $clean and $clean != true
|
||||||
File.unlink(makefile) rescue nil
|
File.unlink(makefile) rescue nil
|
||||||
end
|
end
|
||||||
|
@ -164,11 +179,15 @@ def extmake(target)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def compiled?(target)
|
||||||
|
$compiled[target]
|
||||||
|
end
|
||||||
|
|
||||||
def parse_args()
|
def parse_args()
|
||||||
$mflags = []
|
$mflags = []
|
||||||
|
|
||||||
opts = nil
|
opts = nil
|
||||||
ARGV.options do |opts|
|
$optparser ||= OptionParser.new do |opts|
|
||||||
opts.on('-n') {$dryrun = true}
|
opts.on('-n') {$dryrun = true}
|
||||||
opts.on('--[no-]extension [EXTS]', Array) do |v|
|
opts.on('--[no-]extension [EXTS]', Array) do |v|
|
||||||
$extension = (v == false ? [] : v)
|
$extension = (v == false ? [] : v)
|
||||||
|
@ -200,13 +219,14 @@ def parse_args()
|
||||||
opts.on('--message [MESSAGE]', String) do |v|
|
opts.on('--message [MESSAGE]', String) do |v|
|
||||||
$message = v
|
$message = v
|
||||||
end
|
end
|
||||||
begin
|
end
|
||||||
opts.parse!
|
begin
|
||||||
rescue OptionParser::InvalidOption => e
|
$optparser.parse!(ARGV)
|
||||||
retry if /^--/ =~ e.args[0]
|
rescue OptionParser::InvalidOption => e
|
||||||
raise
|
retry if /^--/ =~ e.args[0]
|
||||||
end
|
$optparser.warn(e)
|
||||||
end or abort opts.to_s
|
abort opts.to_s
|
||||||
|
end
|
||||||
|
|
||||||
$destdir ||= ''
|
$destdir ||= ''
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,18 @@ else
|
||||||
have_library("socket", "socket")
|
have_library("socket", "socket")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless $mswin or $bccwin or $mingw
|
||||||
|
headers = %w<sys/types.h netdb.h string.h sys/socket.h netinet/in.h>
|
||||||
|
end
|
||||||
|
if /solaris/ =~ RUBY_PLATFORM and !try_compile("")
|
||||||
|
# bug of gcc 3.0 on Solaris 8 ?
|
||||||
|
headers << "sys/feature_tests.h"
|
||||||
|
end
|
||||||
|
|
||||||
$ipv6 = false
|
$ipv6 = false
|
||||||
default_ipv6 = /cygwin/ !~ RUBY_PLATFORM
|
default_ipv6 = /cygwin/ !~ RUBY_PLATFORM
|
||||||
if enable_config("ipv6", default_ipv6)
|
if enable_config("ipv6", default_ipv6)
|
||||||
if try_link(<<EOF)
|
if checking_for("ipv6") {try_link(<<EOF)}
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
main()
|
main()
|
||||||
|
@ -45,14 +53,10 @@ $ipv6lib = nil
|
||||||
$ipv6libdir = nil
|
$ipv6libdir = nil
|
||||||
$ipv6trylibc = nil
|
$ipv6trylibc = nil
|
||||||
if $ipv6
|
if $ipv6
|
||||||
if macro_defined?("IPV6_INRIA_VERSION", <<EOF)
|
if have_macro("IPV6_INRIA_VERSION", "netinet/in.h")
|
||||||
#include <netinet/in.h>
|
|
||||||
EOF
|
|
||||||
$ipv6type = "inria"
|
$ipv6type = "inria"
|
||||||
$CPPFLAGS="-DINET6 "+$CPPFLAGS
|
$CPPFLAGS="-DINET6 "+$CPPFLAGS
|
||||||
elsif macro_defined?("__KAME__", <<EOF)
|
elsif have_macro("__KAME__", "netinet/in.h")
|
||||||
#include <netinet/in.h>
|
|
||||||
EOF
|
|
||||||
$ipv6type = "kame"
|
$ipv6type = "kame"
|
||||||
$ipv6lib="inet6"
|
$ipv6lib="inet6"
|
||||||
$ipv6libdir="/usr/local/v6/lib"
|
$ipv6libdir="/usr/local/v6/lib"
|
||||||
|
@ -63,24 +67,18 @@ EOF
|
||||||
$ipv6lib="inet6"
|
$ipv6lib="inet6"
|
||||||
$ipv6libdir="/usr/inet6/lib"
|
$ipv6libdir="/usr/inet6/lib"
|
||||||
$CPPFLAGS="-DINET6 -I/usr/inet6/include "+$CPPFLAGS
|
$CPPFLAGS="-DINET6 -I/usr/inet6/include "+$CPPFLAGS
|
||||||
elsif macro_defined?("_TOSHIBA_INET6", <<EOF)
|
elsif have_macro("_TOSHIBA_INET6", "sys/param.h")
|
||||||
#include <sys/param.h>
|
|
||||||
EOF
|
|
||||||
$ipv6type = "toshiba"
|
$ipv6type = "toshiba"
|
||||||
$ipv6lib="inet6"
|
$ipv6lib="inet6"
|
||||||
$ipv6libdir="/usr/local/v6/lib"
|
$ipv6libdir="/usr/local/v6/lib"
|
||||||
$CPPFLAGS="-DINET6 "+$CPPFLAGS
|
$CPPFLAGS="-DINET6 "+$CPPFLAGS
|
||||||
elsif macro_defined?("__V6D__", <<EOF)
|
elsif have_macro("__V6D__", "/usr/local/v6/include/sys/v6config.h")
|
||||||
#include </usr/local/v6/include/sys/v6config.h>
|
|
||||||
EOF
|
|
||||||
$ipv6type = "v6d"
|
$ipv6type = "v6d"
|
||||||
$ipv6lib="v6"
|
$ipv6lib="v6"
|
||||||
$ipv6libdir="/usr/local/v6/lib"
|
$ipv6libdir="/usr/local/v6/lib"
|
||||||
$CFLAGS="-I/usr/local/v6/include "+$CFLAGS
|
$CFLAGS="-I/usr/local/v6/include "+$CFLAGS
|
||||||
$CPPFLAGS="-DINET6 "+$CPPFLAGS
|
$CPPFLAGS="-DINET6 "+$CPPFLAGS
|
||||||
elsif macro_defined?("_ZETA_MINAMI_INET6", <<EOF)
|
elsif have_macro("_ZETA_MINAMI_INET6", "sys/param.h")
|
||||||
#include <sys/param.h>
|
|
||||||
EOF
|
|
||||||
$ipv6type = "zeta"
|
$ipv6type = "zeta"
|
||||||
$ipv6lib="inet6"
|
$ipv6lib="inet6"
|
||||||
$ipv6libdir="/usr/local/v6/lib"
|
$ipv6libdir="/usr/local/v6/lib"
|
||||||
|
@ -95,101 +93,28 @@ EOF
|
||||||
if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a"
|
if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a"
|
||||||
$LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib"
|
$LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib"
|
||||||
elsif !$ipv6trylibc
|
elsif !$ipv6trylibc
|
||||||
print <<EOS
|
abort <<EOS
|
||||||
|
|
||||||
Fatal: no #$ipv6lib library found. cannot continue.
|
Fatal: no #$ipv6lib library found. cannot continue.
|
||||||
You need to fetch lib#{$ipv6lib}.a from appropriate
|
You need to fetch lib#{$ipv6lib}.a from appropriate
|
||||||
ipv6 kit and compile beforehand.
|
ipv6 kit and compile beforehand.
|
||||||
EOS
|
EOS
|
||||||
exit
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if try_link(<<EOF)
|
if have_struct_member("struct sockaddr_in", "sin_len", headers)
|
||||||
#ifdef _WIN32
|
$defs[-1] = "-DHAVE_SIN_LEN"
|
||||||
# include <windows.h>
|
|
||||||
# include <winsock.h>
|
|
||||||
#else
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <netdb.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <sys/socket.h>
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
struct sockaddr_in sin;
|
|
||||||
|
|
||||||
sin.sin_len;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$CFLAGS="-DHAVE_SIN_LEN "+$CFLAGS
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if try_link(<<EOF)
|
# doug's fix, NOW add -Dss_family... only if required!
|
||||||
#ifdef _WIN32
|
doug = proc {have_struct_member("struct sockaddr_storage", "ss_family", headers)}
|
||||||
# include <windows.h>
|
if doug[] or
|
||||||
# include <winsock.h>
|
with_cppflags($CPPFLAGS + " -Dss_family=__ss_family -Dss_len=__ss_len", &doug)
|
||||||
#else
|
$defs[-1] = "-DHAVE_SOCKADDR_STORAGE"
|
||||||
# include <sys/types.h>
|
|
||||||
# include <netdb.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
struct sockaddr_storage ss;
|
|
||||||
|
|
||||||
ss.ss_family;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$CPPFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CPPFLAGS
|
|
||||||
else # doug's fix, NOW add -Dss_family... only if required!
|
|
||||||
$CPPFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len"
|
|
||||||
if try_link(<<EOF)
|
|
||||||
#ifdef _WIN32
|
|
||||||
# include <windows.h>
|
|
||||||
# include <winsock.h>
|
|
||||||
#else
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <netdb.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
struct sockaddr_storage ss;
|
|
||||||
|
|
||||||
ss.ss_family;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$CFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CFLAGS
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if try_link(<<EOF)
|
if have_struct_member("struct sockaddr", "sa_len", headers)
|
||||||
#include <sys/types.h>
|
$defs[-1] = "-DHAVE_SA_LEN "
|
||||||
#include <netdb.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
struct sockaddr sa;
|
|
||||||
|
|
||||||
sa.sa_len;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$CFLAGS="-DHAVE_SA_LEN "+$CFLAGS
|
|
||||||
end
|
end
|
||||||
|
|
||||||
have_header("netinet/tcp.h") if not /cygwin/ =~ RUBY_PLATFORM # for cygwin 1.1.5
|
have_header("netinet/tcp.h") if not /cygwin/ =~ RUBY_PLATFORM # for cygwin 1.1.5
|
||||||
|
@ -200,13 +125,17 @@ if have_func("sendmsg") | have_func("recvmsg")
|
||||||
have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
|
have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
|
||||||
end
|
end
|
||||||
|
|
||||||
$getaddr_info_ok = false
|
getaddr_info_ok = enable_config("wide-getaddrinfo") do
|
||||||
if !enable_config("wide-getaddrinfo", false) and try_run(<<EOF)
|
checking_for("wide getaddrinfo") {try_run(<<EOF)}
|
||||||
#include <sys/types.h>
|
#{cpp_include(headers)}
|
||||||
#include <netdb.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <sys/socket.h>
|
#ifndef EXIT_SUCCESS
|
||||||
#include <netinet/in.h>
|
#define EXIT_SUCCESS 0
|
||||||
|
#endif
|
||||||
|
#ifndef EXIT_FAILURE
|
||||||
|
#define EXIT_FAILURE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef AF_LOCAL
|
#ifndef AF_LOCAL
|
||||||
#define AF_LOCAL AF_UNIX
|
#define AF_LOCAL AF_UNIX
|
||||||
|
@ -282,79 +211,46 @@ main()
|
||||||
|
|
||||||
if (aitop)
|
if (aitop)
|
||||||
freeaddrinfo(aitop);
|
freeaddrinfo(aitop);
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
if (aitop)
|
if (aitop)
|
||||||
freeaddrinfo(aitop);
|
freeaddrinfo(aitop);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
$getaddr_info_ok = true
|
|
||||||
end
|
end
|
||||||
if $ipv6 and not $getaddr_info_ok
|
if $ipv6 and not getaddr_info_ok
|
||||||
print <<EOS
|
abort <<EOS
|
||||||
|
|
||||||
Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
|
Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
|
||||||
But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
|
But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
|
||||||
you cannot compile IPv6 socket classes with broken these functions.
|
you cannot compile IPv6 socket classes with broken these functions.
|
||||||
You can try --enable-wide-getaddrinfo.
|
You can try --enable-wide-getaddrinfo.
|
||||||
EOS
|
EOS
|
||||||
exit
|
|
||||||
end
|
end
|
||||||
|
|
||||||
case with_config("lookup-order-hack", "UNSPEC")
|
case with_config("lookup-order-hack", "UNSPEC")
|
||||||
when "INET"
|
when "INET"
|
||||||
$CPPFLAGS="-DLOOKUP_ORDER_HACK_INET "+$CPPFLAGS
|
$defs << "-DLOOKUP_ORDER_HACK_INET"
|
||||||
when "INET6"
|
when "INET6"
|
||||||
$CPPFLAGS="-DLOOKUP_ORDER_HACK_INET6 "+$CPPFLAGS
|
$defs << "-DLOOKUP_ORDER_HACK_INET6"
|
||||||
when "UNSPEC"
|
when "UNSPEC"
|
||||||
# nothing special
|
# nothing special
|
||||||
else
|
else
|
||||||
print <<EOS
|
abort <<EOS
|
||||||
|
|
||||||
Fatal: invalid value for --with-lookup-order-hack (expected INET, INET6 or UNSPEC)
|
Fatal: invalid value for --with-lookup-order-hack (expected INET, INET6 or UNSPEC)
|
||||||
EOS
|
EOS
|
||||||
exit
|
|
||||||
end
|
end
|
||||||
|
|
||||||
$objs = ["socket.#{$OBJEXT}"]
|
$objs = ["socket.#{$OBJEXT}"]
|
||||||
|
|
||||||
if $getaddr_info_ok and have_func("getaddrinfo", "netdb.h") and have_func("getnameinfo", "netdb.h")
|
|
||||||
have_getaddrinfo = true
|
|
||||||
else
|
|
||||||
if try_link(<<EOF)
|
|
||||||
#ifndef _WIN32
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <netdb.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <sys/socket.h>
|
|
||||||
# include <netinet/in.h>
|
|
||||||
#else
|
|
||||||
# include <windows.h>
|
|
||||||
# ifdef _WIN32_WCE
|
|
||||||
# include <winsock.h>
|
|
||||||
# else
|
|
||||||
# include <winsock.h>
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
struct in6_addr addr;
|
|
||||||
unsigned char c;
|
|
||||||
c = addr.s6_addr8;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$CFLAGS="-DHAVE_ADDR8 "+$CFLAGS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if have_getaddrinfo
|
unless getaddr_info_ok and have_func("getnameinfo", "netdb.h") and have_func("getaddrinfo", "netdb.h")
|
||||||
$CPPFLAGS="-DHAVE_GETADDRINFO "+$CPPFLAGS
|
if have_struct_member("struct in6_addr", "s6_addr8", headers)
|
||||||
else
|
$defs[-1] = "-DHAVE_ADDR8"
|
||||||
$CFLAGS="-I. "+$CFLAGS
|
end
|
||||||
|
$CPPFLAGS="-I. "+$CPPFLAGS
|
||||||
$objs += ["getaddrinfo.#{$OBJEXT}"]
|
$objs += ["getaddrinfo.#{$OBJEXT}"]
|
||||||
$objs += ["getnameinfo.#{$OBJEXT}"]
|
$objs += ["getnameinfo.#{$OBJEXT}"]
|
||||||
have_func("inet_ntop") or have_func("inet_ntoa")
|
have_func("inet_ntop") or have_func("inet_ntoa")
|
||||||
|
@ -365,20 +261,8 @@ else
|
||||||
have_header("resolv.h")
|
have_header("resolv.h")
|
||||||
end
|
end
|
||||||
|
|
||||||
if !try_link(<<EOF)
|
unless have_type("socklen_t", headers)
|
||||||
#include <sys/types.h>
|
$defs << "-Dsocklen_t=int"
|
||||||
#include <netdb.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
socklen_t len;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$CFLAGS="-Dsocklen_t=int "+$CFLAGS
|
|
||||||
end
|
end
|
||||||
|
|
||||||
have_header("sys/un.h")
|
have_header("sys/un.h")
|
||||||
|
@ -387,14 +271,15 @@ have_header("sys/uio.h")
|
||||||
if have_func(test_func)
|
if have_func(test_func)
|
||||||
have_func("hsterror")
|
have_func("hsterror")
|
||||||
have_func("getipnodebyname") or have_func("gethostbyname2")
|
have_func("getipnodebyname") or have_func("gethostbyname2")
|
||||||
|
have_func("socketpair")
|
||||||
unless have_func("gethostname")
|
unless have_func("gethostname")
|
||||||
have_func("uname")
|
have_func("uname")
|
||||||
end
|
end
|
||||||
if enable_config("socks", ENV["SOCKS_SERVER"])
|
if enable_config("socks", ENV["SOCKS_SERVER"])
|
||||||
if have_library("socks5", "SOCKSinit")
|
if have_library("socks5", "SOCKSinit")
|
||||||
$CFLAGS+=" -DSOCKS5 -DSOCKS"
|
$defs << "-DSOCKS5" << "-DSOCKS"
|
||||||
elsif have_library("socks", "Rconnect")
|
elsif have_library("socks", "Rconnect")
|
||||||
$CFLAGS+=" -DSOCKS"
|
$defs << "-DSOCKS"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
create_makefile("socket")
|
create_makefile("socket")
|
||||||
|
|
|
@ -265,52 +265,14 @@ if mac_need_framework ||
|
||||||
$LDFLAGS += ' -framework Tk -framework Tcl'
|
$LDFLAGS += ' -framework Tk -framework Tcl'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if stubs or pthread_check
|
if stubs or pthread_check
|
||||||
# create Makefile
|
# create Makefile
|
||||||
|
|
||||||
# backup
|
|
||||||
if $INSTALLFILES
|
|
||||||
installfiles_bup = $INSTALLFILES.dup
|
|
||||||
else
|
|
||||||
installfiles_bup = nil
|
|
||||||
$INSTALLFILES = []
|
|
||||||
end
|
|
||||||
|
|
||||||
# for SUPPORT_STATUS
|
# for SUPPORT_STATUS
|
||||||
|
$INSTALLFILES ||= []
|
||||||
$INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
|
$INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
|
||||||
|
|
||||||
# create
|
# create
|
||||||
create_makefile("tcltklib")
|
create_makefile("tcltklib")
|
||||||
|
|
||||||
# reset
|
|
||||||
$INSTALLFILES = installfiles_bup
|
|
||||||
|
|
||||||
# add rules for tkutil
|
|
||||||
File::open('Makefile', 'a'){|mfile|
|
|
||||||
File::open('make-tkutil', 'r'){|dfile|
|
|
||||||
mfile.print "\n###\n"
|
|
||||||
while line = dfile.gets()
|
|
||||||
mfile.print line
|
|
||||||
end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# create tkutil/Makefile
|
|
||||||
Dir.chdir 'tkutil'
|
|
||||||
if $extout || $extmk
|
|
||||||
$srcdir = '../' << $srcdir << '/tkutil'
|
|
||||||
$topdir = '../' << $topdir
|
|
||||||
$hdrdir = '../' << $hdrdir
|
|
||||||
$objs = nil
|
|
||||||
$defs = []
|
|
||||||
Config::CONFIG["srcdir"] = $srcdir
|
|
||||||
else
|
|
||||||
puts "entering directory `tkutil'"
|
|
||||||
end
|
|
||||||
rm_f './Makefile'
|
|
||||||
init_mkmf
|
|
||||||
load 'subconf.rb'
|
|
||||||
Dir.chdir '..'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
199
lib/mkmf.rb
199
lib/mkmf.rb
|
@ -79,11 +79,12 @@ def map_dir(dir, map = nil)
|
||||||
map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)}
|
map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)}
|
||||||
end
|
end
|
||||||
|
|
||||||
libdir = File.dirname(__FILE__)
|
topdir = File.dirname(libdir = File.dirname(__FILE__))
|
||||||
$extmk = libdir != Config::CONFIG["rubylibdir"]
|
extdir = File.expand_path("ext", topdir)
|
||||||
|
$extmk = File.expand_path($0)[0, extdir.size+1] == extdir+"/"
|
||||||
if not $extmk and File.exist?(Config::CONFIG["archdir"] + "/ruby.h")
|
if not $extmk and File.exist?(Config::CONFIG["archdir"] + "/ruby.h")
|
||||||
$hdrdir = $topdir = Config::CONFIG["archdir"]
|
$hdrdir = $topdir = Config::CONFIG["archdir"]
|
||||||
elsif File.exist?(($top_srcdir ||= File.dirname(libdir)) + "/ruby.h") and
|
elsif File.exist?(($top_srcdir ||= topdir) + "/ruby.h") and
|
||||||
File.exist?(($topdir ||= Config::CONFIG["topdir"]) + "/config.h")
|
File.exist?(($topdir ||= Config::CONFIG["topdir"]) + "/config.h")
|
||||||
$hdrdir = $top_srcdir
|
$hdrdir = $top_srcdir
|
||||||
else
|
else
|
||||||
|
@ -137,6 +138,7 @@ module Logging
|
||||||
@logfile = 'mkmf.log'
|
@logfile = 'mkmf.log'
|
||||||
@orgerr = $stderr.dup
|
@orgerr = $stderr.dup
|
||||||
@orgout = $stdout.dup
|
@orgout = $stdout.dup
|
||||||
|
@postpone = 0
|
||||||
|
|
||||||
def self::open
|
def self::open
|
||||||
@log ||= File::open(@logfile, 'w')
|
@log ||= File::open(@logfile, 'w')
|
||||||
|
@ -165,7 +167,7 @@ module Logging
|
||||||
end
|
end
|
||||||
|
|
||||||
def self::postpone
|
def self::postpone
|
||||||
tmplog = "mkmftmp.log"
|
tmplog = "mkmftmp#{@postpone += 1}.log"
|
||||||
open do
|
open do
|
||||||
log, *save = @log, @logfile, @orgout, @orgerr
|
log, *save = @log, @logfile, @orgout, @orgerr
|
||||||
@log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
|
@log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
|
||||||
|
@ -175,6 +177,7 @@ module Logging
|
||||||
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)}
|
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)}
|
||||||
ensure
|
ensure
|
||||||
@log, @logfile, @orgout, @orgerr = log, *save
|
@log, @logfile, @orgout, @orgerr = log, *save
|
||||||
|
@postpone -= 1
|
||||||
rm_f tmplog
|
rm_f tmplog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -288,54 +291,82 @@ def cpp_include(header)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def with_cppflags(flags)
|
||||||
|
cppflags = $CPPFLAGS
|
||||||
|
$CPPFLAGS = flags
|
||||||
|
return yield
|
||||||
|
ensure
|
||||||
|
$CPPFLAGS = cppflags
|
||||||
|
end
|
||||||
|
|
||||||
|
def with_cflags(flags)
|
||||||
|
cflags = $CFLAGS
|
||||||
|
$CFLAGS = flags
|
||||||
|
return yield
|
||||||
|
ensure
|
||||||
|
$CFLAGS = cflags
|
||||||
|
end
|
||||||
|
|
||||||
|
def with_ldflags(flags)
|
||||||
|
ldflags = $LDFLAGS
|
||||||
|
$LDFLAGS = flags
|
||||||
|
return yield
|
||||||
|
ensure
|
||||||
|
$LDFLAGS = ldflags
|
||||||
|
end
|
||||||
|
|
||||||
def try_static_assert(expr, headers = nil, opt = "", &b)
|
def try_static_assert(expr, headers = nil, opt = "", &b)
|
||||||
headers = cpp_include(headers)
|
headers = cpp_include(headers)
|
||||||
try_compile(<<SRC, opt, &b)
|
try_compile(<<SRC, opt, &b)
|
||||||
#{COMMON_HEADERS}
|
#{COMMON_HEADERS}
|
||||||
#{headers}
|
#{headers}
|
||||||
/*top*/
|
/*top*/
|
||||||
int tmp[(#{expr}) ? 1 : -1];
|
int conftest_const[(#{expr}) ? 1 : -1];
|
||||||
SRC
|
SRC
|
||||||
end
|
end
|
||||||
|
|
||||||
def try_constant(const, headers = nil, opt = "", &b)
|
def try_constant(const, headers = nil, opt = "", &b)
|
||||||
headers = cpp_include(headers)
|
includes = cpp_include(headers)
|
||||||
if CROSS_COMPILING
|
if CROSS_COMPILING
|
||||||
unless try_compile(<<"SRC", opt, &b)
|
if try_static_assert("#{const} > 0", headers, opt)
|
||||||
#{COMMON_HEADERS}
|
# positive constant
|
||||||
#{headers}
|
elsif try_static_assert("#{const} < 0", headers, opt)
|
||||||
/*top*/
|
|
||||||
int tmp = #{const};
|
|
||||||
SRC
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
if try_static_assert("#{const} < 0", headers, opt)
|
|
||||||
neg = true
|
neg = true
|
||||||
const = "-(#{const})"
|
const = "-(#{const})"
|
||||||
elsif try_static_assert("#{const} == 0", headers, opt)
|
elsif try_static_assert("#{const} == 0", headers, opt)
|
||||||
return 0
|
return 0
|
||||||
|
else
|
||||||
|
# not a constant
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
upper = 1
|
upper = 1
|
||||||
until try_static_assert("#{const} < #{upper}", headers, opt)
|
until try_static_assert("#{const} <= #{upper}", headers, opt)
|
||||||
lower = upper
|
lower = upper
|
||||||
upper <<= 1
|
upper <<= 1
|
||||||
end
|
end
|
||||||
return nil unless lower
|
return nil unless lower
|
||||||
until try_static_assert("#{const} == #{upper}", headers, opt)
|
while upper > lower + 1
|
||||||
if try_static_assert("#{const} > #{(upper+lower)/2}", headers, opt)
|
mid = (upper + lower) / 2
|
||||||
lower = (upper+lower)/2
|
if try_static_assert("#{const} > #{mid}", headers, opt)
|
||||||
|
lower = mid
|
||||||
else
|
else
|
||||||
upper = (upper+lower)/2
|
upper = mid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
unless upper == lower
|
||||||
|
if try_static_assert("#{const} == #{lower}", headers, opt)
|
||||||
|
upper = lower
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
upper = -upper if neg
|
upper = -upper if neg
|
||||||
return upper
|
return upper
|
||||||
else
|
else
|
||||||
src = %{#{COMMON_HEADERS}
|
src = %{#{COMMON_HEADERS}
|
||||||
#{headers}
|
#{includes}
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
/*top*/
|
/*top*/
|
||||||
int main() {printf("%d\\n", (int)(#{const})); return 0;}
|
int conftest_const = (int)(#{const});
|
||||||
|
int main() {printf("%d\\n", conftest_const); return 0;}
|
||||||
}
|
}
|
||||||
if try_link0(src, opt, &b)
|
if try_link0(src, opt, &b)
|
||||||
xpopen("./conftest") do |f|
|
xpopen("./conftest") do |f|
|
||||||
|
@ -362,6 +393,17 @@ int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
|
||||||
SRC
|
SRC
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def try_var(var, headers = nil, &b)
|
||||||
|
headers = cpp_include(headers)
|
||||||
|
try_compile(<<"SRC", &b)
|
||||||
|
#{COMMON_HEADERS}
|
||||||
|
#{headers}
|
||||||
|
/*top*/
|
||||||
|
int main() { return 0; }
|
||||||
|
int t() { void *volatile p; p = (void *)&#{var}; return 0; }
|
||||||
|
SRC
|
||||||
|
end
|
||||||
|
|
||||||
def egrep_cpp(pat, src, opt = "", &b)
|
def egrep_cpp(pat, src, opt = "", &b)
|
||||||
src = create_tmpsrc(src, &b)
|
src = create_tmpsrc(src, &b)
|
||||||
xpopen(cpp_command('', opt)) do |f|
|
xpopen(cpp_command('', opt)) do |f|
|
||||||
|
@ -460,14 +502,14 @@ def message(*s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def checking_for(m)
|
def checking_for(m, fmt = nil)
|
||||||
f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
|
f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
|
||||||
m = "checking for #{m}... "
|
m = "checking for #{m}... "
|
||||||
message "%s", m
|
message "%s", m
|
||||||
a = r = nil
|
a = r = nil
|
||||||
Logging::postpone do
|
Logging::postpone do
|
||||||
r = yield
|
r = yield
|
||||||
a = r ? "yes\n" : "no\n"
|
a = (fmt ? fmt % r : r ? "yes" : "no") << "\n"
|
||||||
"#{f}#{m}-------------------- #{a}\n"
|
"#{f}#{m}-------------------- #{a}\n"
|
||||||
end
|
end
|
||||||
message(a)
|
message(a)
|
||||||
|
@ -475,6 +517,14 @@ def checking_for(m)
|
||||||
r
|
r
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def have_macro(macro, headers = nil, opt = "", &b)
|
||||||
|
m = "#{macro}"
|
||||||
|
m << " in #{headers.inspect}" if headers
|
||||||
|
checking_for m do
|
||||||
|
macro_defined?(macro, cpp_include(headers), opt, &b)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def have_library(lib, func = nil, header=nil, &b)
|
def have_library(lib, func = nil, header=nil, &b)
|
||||||
func = "main" if !func or func.empty?
|
func = "main" if !func or func.empty?
|
||||||
lib = with_config(lib+'lib', lib)
|
lib = with_config(lib+'lib', lib)
|
||||||
|
@ -496,6 +546,7 @@ end
|
||||||
def find_library(lib, func, *paths, &b)
|
def find_library(lib, func, *paths, &b)
|
||||||
func = "main" if !func or func.empty?
|
func = "main" if !func or func.empty?
|
||||||
lib = with_config(lib+'lib', lib)
|
lib = with_config(lib+'lib', lib)
|
||||||
|
paths = paths.collect {|path| path.split(File::PATH_SEPARATOR)}.flatten
|
||||||
checking_for "#{func}() in #{LIBARG%lib}" do
|
checking_for "#{func}() in #{LIBARG%lib}" do
|
||||||
libpath = $LIBPATH
|
libpath = $LIBPATH
|
||||||
libs = append_library($libs, lib)
|
libs = append_library($libs, lib)
|
||||||
|
@ -525,6 +576,19 @@ def have_func(func, headers = nil, &b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def have_var(var, headers = nil, &b)
|
||||||
|
checking_for "#{var}" do
|
||||||
|
libs = append_library($libs, libs)
|
||||||
|
if try_var(var, headers, &b)
|
||||||
|
$libs = libs
|
||||||
|
$defs.push(format("-DHAVE_%s", var.upcase))
|
||||||
|
true
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def have_header(header, &b)
|
def have_header(header, &b)
|
||||||
checking_for header do
|
checking_for header do
|
||||||
if try_cpp(cpp_include(header), &b)
|
if try_cpp(cpp_include(header), &b)
|
||||||
|
@ -624,24 +688,28 @@ def find_executable(bin, path = nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def arg_config(config, default=nil)
|
def arg_config(config, *defaults, &block)
|
||||||
$configure_args.fetch(config.tr('_', '-'), default)
|
$arg_config << [config, *defaults]
|
||||||
|
defaults << nil if !block and defaults.empty?
|
||||||
|
$configure_args.fetch(config.tr('_', '-'), *defaults, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_config(config, default=nil)
|
def with_config(config, *defaults, &block)
|
||||||
unless /^--with[-_]/ =~ config
|
unless /^--with[-_]/ =~ config
|
||||||
config = '--with-' + config
|
config = '--with-' + config
|
||||||
end
|
end
|
||||||
arg_config(config, default)
|
arg_config(config, *defaults, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enable_config(config, default=nil)
|
def enable_config(config, *defaults)
|
||||||
if arg_config("--enable-"+config)
|
if arg_config("--enable-"+config)
|
||||||
true
|
true
|
||||||
elsif arg_config("--disable-"+config)
|
elsif arg_config("--disable-"+config)
|
||||||
false
|
false
|
||||||
|
elsif block_given?
|
||||||
|
yield(config, *defaults)
|
||||||
else
|
else
|
||||||
default
|
return *defaults
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -666,15 +734,16 @@ end
|
||||||
|
|
||||||
def dir_config(target, idefault=nil, ldefault=nil)
|
def dir_config(target, idefault=nil, ldefault=nil)
|
||||||
if dir = with_config(target + "-dir", (idefault unless ldefault))
|
if dir = with_config(target + "-dir", (idefault unless ldefault))
|
||||||
defaults = dir.split(File::PATH_SEPARATOR)
|
defaults = Array === dir ? dir : dir.split(File::PATH_SEPARATOR)
|
||||||
idefault = ldefault = nil
|
idefault = ldefault = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
idir = with_config(target + "-include", idefault)
|
idir = with_config(target + "-include", idefault)
|
||||||
|
$arg_config.last[1] ||= "${#{target}-dir}/include"
|
||||||
ldir = with_config(target + "-lib", ldefault)
|
ldir = with_config(target + "-lib", ldefault)
|
||||||
|
$arg_config.last[1] ||= "${#{target}-dir}/lib"
|
||||||
|
|
||||||
# idirs = idir ? idir.split(File::PATH_SEPARATOR) : []
|
idirs = idir ? Array === idir ? idir : idir.split(File::PATH_SEPARATOR) : []
|
||||||
idirs = idir.split(File::PATH_SEPARATOR) rescue []
|
|
||||||
if defaults
|
if defaults
|
||||||
idirs.concat(defaults.collect {|dir| dir + "/include"})
|
idirs.concat(defaults.collect {|dir| dir + "/include"})
|
||||||
idir = ([idir] + idirs).compact.join(File::PATH_SEPARATOR)
|
idir = ([idir] + idirs).compact.join(File::PATH_SEPARATOR)
|
||||||
|
@ -687,7 +756,7 @@ def dir_config(target, idefault=nil, ldefault=nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ldirs = ldir ? ldir.split(File::PATH_SEPARATOR) : []
|
ldirs = ldir ? Array === ldir ? ldir : ldir.split(File::PATH_SEPARATOR) : []
|
||||||
if defaults
|
if defaults
|
||||||
ldirs.concat(defaults.collect {|dir| dir + "/lib"})
|
ldirs.concat(defaults.collect {|dir| dir + "/lib"})
|
||||||
ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR)
|
ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR)
|
||||||
|
@ -789,6 +858,7 @@ COPY = $(RUBY) -run -e cp -- -v
|
||||||
|
|
||||||
#### End of system configuration section. ####
|
#### End of system configuration section. ####
|
||||||
|
|
||||||
|
preload = #{$preload.join(" ") if $preload}
|
||||||
}
|
}
|
||||||
if $nmake == ?b
|
if $nmake == ?b
|
||||||
mk.each do |x|
|
mk.each do |x|
|
||||||
|
@ -834,16 +904,18 @@ def create_makefile(target, srcprefix = nil)
|
||||||
srcprefix ||= '$(srcdir)'
|
srcprefix ||= '$(srcdir)'
|
||||||
Config::expand(srcdir = srcprefix.dup)
|
Config::expand(srcdir = srcprefix.dup)
|
||||||
|
|
||||||
unless $objs then
|
if not $objs
|
||||||
$objs = []
|
$objs = []
|
||||||
for f in Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
|
srcs = Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
|
||||||
obj = File.basename(f, ".*") << "." << $OBJEXT
|
for f in srcs
|
||||||
|
obj = File.basename(f, ".*") << ".o"
|
||||||
$objs.push(obj) unless $objs.index(obj)
|
$objs.push(obj) unless $objs.index(obj)
|
||||||
end
|
end
|
||||||
else
|
elsif !(srcs = $srcs)
|
||||||
for i in $objs
|
srcs = $objs.collect {|obj| obj.sub(/\.o\z/, '.c')}
|
||||||
i.sub!(/\.o\z/, ".#{$OBJEXT}")
|
end
|
||||||
end
|
for i in $objs
|
||||||
|
i.sub!(/\.o\z/, ".#{$OBJEXT}")
|
||||||
end
|
end
|
||||||
$objs = $objs.join(" ")
|
$objs = $objs.join(" ")
|
||||||
|
|
||||||
|
@ -872,7 +944,6 @@ def create_makefile(target, srcprefix = nil)
|
||||||
mfile = open("Makefile", "wb")
|
mfile = open("Makefile", "wb")
|
||||||
mfile.print configuration(srcdir)
|
mfile.print configuration(srcdir)
|
||||||
mfile.print %{
|
mfile.print %{
|
||||||
preload = #{$preload.join(" ") if $preload}
|
|
||||||
libpath = #{$LIBPATH.join(" ")}
|
libpath = #{$LIBPATH.join(" ")}
|
||||||
LIBPATH = #{libpath}
|
LIBPATH = #{libpath}
|
||||||
DEFFILE = #{deffile}
|
DEFFILE = #{deffile}
|
||||||
|
@ -885,6 +956,7 @@ extout_prefix = #{$extout_prefix}
|
||||||
target_prefix = #{target_prefix}
|
target_prefix = #{target_prefix}
|
||||||
LOCAL_LIBS = #{$LOCAL_LIBS}
|
LOCAL_LIBS = #{$LOCAL_LIBS}
|
||||||
LIBS = #{$LIBRUBYARG} #{$libs} #{$LIBS}
|
LIBS = #{$LIBRUBYARG} #{$libs} #{$LIBS}
|
||||||
|
SRCS = #{srcs.collect(&File.method(:basename)).join(' ')}
|
||||||
OBJS = #{$objs}
|
OBJS = #{$objs}
|
||||||
TARGET = #{target}
|
TARGET = #{target}
|
||||||
DLLIB = #{dllib}
|
DLLIB = #{dllib}
|
||||||
|
@ -911,6 +983,7 @@ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
||||||
end
|
end
|
||||||
n = ($extout ? '$(RUBYARCHDIR)/' : '') + '$(TARGET).'
|
n = ($extout ? '$(RUBYARCHDIR)/' : '') + '$(TARGET).'
|
||||||
mfile.print %{
|
mfile.print %{
|
||||||
|
TARGET_SO = #{($extout ? '$(RUBYARCHDIR)/' : '')}$(DLLIB)
|
||||||
CLEANLIBS = #{n}#{CONFIG['DLEXT']} #{n}il? #{n}tds #{n}map
|
CLEANLIBS = #{n}#{CONFIG['DLEXT']} #{n}il? #{n}tds #{n}map
|
||||||
CLEANOBJS = *.#{$OBJEXT} *.#{$LIBEXT} *.s[ol] *.pdb *.exp *.bak
|
CLEANOBJS = *.#{$OBJEXT} *.#{$LIBEXT} *.s[ol] *.pdb *.exp *.bak
|
||||||
|
|
||||||
|
@ -931,17 +1004,18 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
dirs << (dir = "$(RUBYLIBDIR)")
|
dirs << (dir = "$(RUBYLIBDIR)")
|
||||||
mfile.print("install-rb: #{dir}\n")
|
mfile.print("install-rb: install-rb-default\n")
|
||||||
for i in [[["lib/**/*.rb", "$(RUBYLIBDIR)", "lib"]], $INSTALLFILES]
|
mfile.print("install-rb-default: #{dir}\n")
|
||||||
|
for sfx, i in [["-default", [["lib/**/*.rb", "$(RUBYLIBDIR)", "lib"]]], ["", $INSTALLFILES]]
|
||||||
files = install_files(mfile, i, nil, srcprefix) or next
|
files = install_files(mfile, i, nil, srcprefix) or next
|
||||||
for dir, *files in files
|
for dir, *files in files
|
||||||
unless dirs.include?(dir)
|
unless dirs.include?(dir)
|
||||||
dirs << dir
|
dirs << dir
|
||||||
mfile.print "install-rb: #{dir}\n"
|
mfile.print "install-rb#{sfx}: #{dir}\n"
|
||||||
end
|
end
|
||||||
files.each do |f|
|
files.each do |f|
|
||||||
dest = "#{dir}/#{File.basename(f)}"
|
dest = "#{dir}/#{File.basename(f)}"
|
||||||
mfile.print("install-rb: #{dest}\n")
|
mfile.print("install-rb#{sfx}: #{dest}\n")
|
||||||
mfile.print("#{dest}: #{f}\n\t@$(#{$extout ? 'COPY' : 'INSTALL_DATA'}) #{f} #{dir}\n")
|
mfile.print("#{dest}: #{f}\n\t@$(#{$extout ? 'COPY' : 'INSTALL_DATA'}) #{f} #{dir}\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -978,7 +1052,7 @@ site-install-rb: install-rb
|
||||||
mfile.print "$(RUBYARCHDIR)/" if $extout
|
mfile.print "$(RUBYARCHDIR)/" if $extout
|
||||||
mfile.print "$(DLLIB): ", (makedef ? "$(DEFFILE) " : ""), "$(OBJS)\n\t"
|
mfile.print "$(DLLIB): ", (makedef ? "$(DEFFILE) " : ""), "$(OBJS)\n\t"
|
||||||
mfile.print "@-$(RM) $@\n\t"
|
mfile.print "@-$(RM) $@\n\t"
|
||||||
mfile.print "@-$(MAKEDIRS) $(@D)\n\t"
|
mfile.print "@-$(MAKEDIRS) $(@D)\n\t" if $extout
|
||||||
mfile.print LINK_SO, "\n\n"
|
mfile.print LINK_SO, "\n\n"
|
||||||
unless $static.nil?
|
unless $static.nil?
|
||||||
mfile.print "$(STATIC_LIB): $(OBJS)\n\t"
|
mfile.print "$(STATIC_LIB): $(OBJS)\n\t"
|
||||||
|
@ -1008,11 +1082,15 @@ site-install-rb: install-rb
|
||||||
vpath = ($nmake ? "{$(hdrdir)}" : "")
|
vpath = ($nmake ? "{$(hdrdir)}" : "")
|
||||||
mfile.print "$(OBJS): #{vpath}ruby.h #{vpath}defines.h #{$config_h}\n"
|
mfile.print "$(OBJS): #{vpath}ruby.h #{vpath}defines.h #{$config_h}\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
$makefile_created = true
|
||||||
ensure
|
ensure
|
||||||
mfile.close if mfile
|
mfile.close if mfile
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_mkmf(config = CONFIG)
|
def init_mkmf(config = CONFIG)
|
||||||
|
$makefile_created = false
|
||||||
|
$arg_config = []
|
||||||
$enable_shared = config['ENABLE_SHARED'] == 'yes'
|
$enable_shared = config['ENABLE_SHARED'] == 'yes'
|
||||||
$defs = []
|
$defs = []
|
||||||
$CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup
|
$CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup
|
||||||
|
@ -1044,9 +1122,25 @@ def init_mkmf(config = CONFIG)
|
||||||
$extout ||= nil
|
$extout ||= nil
|
||||||
$extout_prefix ||= nil
|
$extout_prefix ||= nil
|
||||||
|
|
||||||
|
$arg_config.clear
|
||||||
dir_config("opt")
|
dir_config("opt")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
FailedMassage = <<MESSAGE
|
||||||
|
Could not create Makefile due to some reason, probably lack of
|
||||||
|
necessary libraries and/or headers. Check the mkmf.log file for more
|
||||||
|
details. You may need configuration options.
|
||||||
|
|
||||||
|
Provided configuration options:
|
||||||
|
MESSAGE
|
||||||
|
|
||||||
|
def mkmf_failed(path)
|
||||||
|
unless $makefile_created
|
||||||
|
opts = $arg_config.collect {|t, n| "\t#{t}#{"=#{n}" if n}\n"}
|
||||||
|
abort "*** #{path} failed ***\n" + FailedMassage + opts.join
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
init_mkmf
|
init_mkmf
|
||||||
|
|
||||||
$make = with_config("make-prog", ENV["MAKE"] || "make")
|
$make = with_config("make-prog", ENV["MAKE"] || "make")
|
||||||
|
@ -1105,13 +1199,18 @@ LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
|
||||||
RPATHFLAG = config_string('RPATHFLAG') || ''
|
RPATHFLAG = config_string('RPATHFLAG') || ''
|
||||||
LIBARG = config_string('LIBARG') || '-l%s'
|
LIBARG = config_string('LIBARG') || '-l%s'
|
||||||
|
|
||||||
|
sep = File::ALT_SEPARATOR ? ":/=#{File::ALT_SEPARATOR}" : ''
|
||||||
CLEANINGS = "
|
CLEANINGS = "
|
||||||
clean:
|
clean:
|
||||||
@$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
@-$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep})
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
@$(RM) Makefile extconf.h conftest.* mkmf.log
|
@-$(RM) Makefile extconf.h conftest.* mkmf.log
|
||||||
@$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep})
|
||||||
|
|
||||||
realclean: distclean
|
realclean: distclean
|
||||||
"
|
"
|
||||||
|
|
||||||
|
if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0)
|
||||||
|
END {mkmf_failed($0)}
|
||||||
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче