1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/tk/lib/extconf.rb: bug fix and ignore invalid Tcl/Tk libraries.

* ext/tk/lib/config_list.in: bug fix and add a new option.
* ext/tk/lib/README.tcltklib: update for a new option.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2009-07-27 19:40:43 +00:00
parent 2b2a9a23d0
commit 8e7e28f15c
4 changed files with 328 additions and 171 deletions

View file

@ -1,3 +1,11 @@
Tue Jul 28 04:34:05 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/extconf.rb: bug fix and ignore invalid Tcl/Tk libraries.
* ext/tk/lib/config_list.in: bug fix and add a new option.
* ext/tk/lib/README.tcltklib: update for a new option.
Mon Jul 27 19:03:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Mon Jul 27 19:03:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/intern.h (rb_*str_new_cstr, rb_str_buf_new_cstr), * include/ruby/intern.h (rb_*str_new_cstr, rb_str_buf_new_cstr),

View file

@ -113,6 +113,7 @@ options may be useful.
--enable-tcl-thread/--disable-tcl-thread --enable-tcl-thread/--disable-tcl-thread
--with-tclConfig-file=<path of 'tclConfig.sh'> --with-tclConfig-file=<path of 'tclConfig.sh'>
--with-tkConfig-file=<path of 'tkConfig.sh'>
It is not need that 'tclConfig.sh' is a normal Tcl/Tk's tclConfig.sh. It is not need that 'tclConfig.sh' is a normal Tcl/Tk's tclConfig.sh.
But the file is expected to include the line "TCL_THREADS=0" or "...=1". But the file is expected to include the line "TCL_THREADS=0" or "...=1".

View file

@ -1,22 +1,24 @@
############################################## ##############################################
# configure options for Ruby/Tk # configure options for Ruby/Tk
# release date: 2009-07-15 # release date: 2009-07-28
############################################## ##############################################
with tk-old-extconf with tk-old-extconf
with ActiveTcl with ActiveTcl
with tk-shlib-search-path with tk-shlib-search-path
enable tcltk-stubs
with tcltkversion with tcltkversion
with tcl-config with tcl-config
with tk-config with tk-config
with tclConfig-dir with tclConfig-dir
with tkConfig-dir with tkConfig-dir
with tclConfig-file
with tkConfig-file
with tcllib with tcllib
with tklib with tklib
enable tcltk-stubs
with tcl-dir with tcl-dir
with tk-dir with tk-dir
with tcl-include with tcl-include
with tcl-lib with tk-include
with tcl-lib with tcl-lib
with tk-lib with tk-lib
enable mac-tcltk-framework enable mac-tcltk-framework
@ -32,5 +34,4 @@ with X11-include
with X11-lib with X11-lib
enable pthread enable pthread
enable tcl-thread enable tcl-thread
with tclConfig-file
enable space-on-tk-libpath enable space-on-tk-libpath

View file

@ -1,6 +1,6 @@
############################################################## ##############################################################
# extconf.rb for tcltklib # extconf.rb for tcltklib
# release date: 2009-07-23 # release date: 2009-07-28
############################################################## ##############################################################
require 'mkmf' require 'mkmf'
@ -369,23 +369,9 @@ def get_libpath(lib_flag, lib_spec)
libpath = lib_spec.gsub(/(#{lib_flag}|-L)/, "").strip libpath = lib_spec.gsub(/(#{lib_flag}|-L)/, "").strip
end end
def search_tclConfig(*paths) # list of lib-dir or [tcl-libdir, tk-libdir] def get_tclConfig_dirs
TkLib_Config["tclConfig_paths"] = []
config_dir = [] config_dir = []
paths.compact!
fixed_tclConfig = ! paths.empty?
paths.each{|path|
if path.kind_of?(Array)
config_dir << path
else
dirs = Dir.glob(path)
config_dir.concat(dirs.zip(dirs))
end
}
if is_win32? if is_win32?
if TkLib_Config["ActiveTcl"] if TkLib_Config["ActiveTcl"]
dirs = [] dirs = []
@ -477,20 +463,43 @@ def search_tclConfig(*paths) # list of lib-dir or [tcl-libdir, tk-libdir]
"/Network/Library/Frameworks", "/System/Library/Frameworks" "/Network/Library/Frameworks", "/System/Library/Frameworks"
].each{|framework| ].each{|framework|
config_dir << [File.expand_path(File.join(framework, 'Tcl.framework')), config_dir << [File.expand_path(File.join(framework, 'Tcl.framework')),
File.expand_path(File.join(framework, 'Tk.framework'))] File.expand_path(File.join(framework, 'Tk.framework'))]
}
end
config_dir
end
def search_tclConfig(*paths) # libdir list or [tcl-libdir|file, tk-libdir|file]
TkLib_Config["tclConfig_paths"] = []
paths.compact!
if paths.empty?
config_dir = get_tclConfig_dirs
else
# fixed tclConfig
config_dir = []
paths.each{|path|
if path.kind_of?(Array)
config_dir << path
else
dirs = Dir.glob(path)
config_dir.concat(dirs.zip(dirs))
end
} }
end end
tclver, tkver = TkLib_Config['tcltkversion'] tclver, tkver = TkLib_Config['tcltkversion']
conf = nil conf = nil
config_dir.map{|dir| (config_dir | config_dir).map{|dir|
if dir.kind_of? Array if dir.kind_of? Array
[dir[0].strip.chomp('/'), dir[1].strip.chomp('/')] [dir[0].strip.chomp('/'), dir[1].strip.chomp('/')]
else else
dir.strip.chomp('/') dir.strip.chomp('/')
end end
}.each{|dir| }.each{|dir|
print(".") # progress
# print("check #{dir} ==>"); # print("check #{dir} ==>");
if dir.kind_of? Array if dir.kind_of? Array
tcldir, tkdir = dir tcldir, tkdir = dir
@ -498,9 +507,21 @@ def search_tclConfig(*paths) # list of lib-dir or [tcl-libdir, tk-libdir]
tcldir = tkdir = dir tcldir = tkdir = dir
end end
['Config-shared.sh','config-shared.sh','Config.sh','config.sh'].each{|f| tails = ['Config-shared.sh', 'config-shared.sh', 'Config.sh', 'config.sh']
tclpath = File.join(tcldir, 'tcl' << f)
tkpath = File.join(tkdir, 'tk' << f) if File.file?(tcldir)
tclcfg_files = [tcldir] * tails.length
else
tclcfg_files = tails.map{|f| File.join(tcldir, 'tcl' << f)}
end
if File.file?(tkdir)
tkcfg_files = [tkdir] * tails.length
else
tkcfg_files = tails.map{|f| File.join(tcldir, 'tk' << f)}
end
tclcfg_files.zip(tkcfg_files).uniq.each{|tclpath, tkpath|
next if !File.exist?(tclpath) || !File.exist?(tkpath) next if !File.exist?(tclpath) || !File.exist?(tkpath)
# parse tclConfig.sh/tkConfig.sh # parse tclConfig.sh/tkConfig.sh
@ -520,8 +541,50 @@ def search_tclConfig(*paths) # list of lib-dir or [tcl-libdir, tk-libdir]
next next
end end
# check Tcl library
if TkLib_Config["tcltk-stubs"]
stub = "stub"
tclfunc = "Tcl_InitStubs"
tkfunc = "Tk_InitStubs"
else
stub = ""
tclfunc = "Tcl_FindExecutable"
tkfunc = "Tk_Init"
end
dir = File.dirname(tclpath)
libpath = $LIBPATH
tcllibs = nil
begin
tcllib_ok = Dir.glob(File.join(dir, "*tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}{.,}#{tclconf['TCL_MINOR_VERSION']}*.*")).find{|file|
if file =~ /^.*(tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}(\.|)#{tclconf['TCL_MINOR_VERSION']}.*)\.[^.]*$/
#puts "check #{file} #{$1} #{tclfunc} #{dir}"
#find_library($1, tclfunc, dir)
tcllibs = append_library($libs, $1)
$LIBPATH = libpath | [dir]
try_func(tclfunc, tcllibs)
end
}
tklib_ok = Dir.glob(File.join(dir, "*tk#{stub}#{tkconf['TK_MAJOR_VERSION']}{.,}#{tkconf['TK_MINOR_VERSION']}*.*")).find{|file|
if file =~ /^.*(tk#{stub}#{tkconf['TK_MAJOR_VERSION']}(\.|)#{tkconf['TK_MINOR_VERSION']}.*)\.[^.]*$/
#puts "check #{file} #{$1} #{tkfunc} #{dir}"
# find_library($1, tkfunc, dir)
tklibs = append_library(tcllibs, $1)
$LIBPATH = libpath | [dir]
try_func(tkfunc, tklibs)
end
}
ensure
$LIBPATH = libpath
end
unless tcllib_ok && tklib_ok
puts "WARNIG: find #{tclpath.inspect}, but cannot find valid Tcl/Tk libraries on the same directory. So, ignore it."
TkLib_Config["tcltk-NG-path"] << File.dirname(tclpath)
next
end
#return [tclpath, tkpath] #return [tclpath, tkpath]
# print(" #{[tclpath, tkpath]}"); # print(" #{[tclpath, tkpath].inspect}");
TkLib_Config["tclConfig_paths"] << [tclpath, tkpath] TkLib_Config["tclConfig_paths"] << [tclpath, tkpath]
} }
@ -537,11 +600,17 @@ def search_tclConfig(*paths) # list of lib-dir or [tcl-libdir, tk-libdir]
end end
end end
def get_tclConfig(tclConfig_file, tclConfig_dir, tkConfig_dir) def get_tclConfig(tclConfig_file, tkConfig_file, tclConfig_dir, tkConfig_dir)
use_tclConfig = (tclConfig_file != false) && use_tclConfig = (tclConfig_file != false) && (tkConfig_file != false) &&
(tclConfig_dir != false) && (tkConfig_dir != false) (tclConfig_dir != false) && (tkConfig_dir != false)
unless use_tclConfig
puts("Don't use [tclConfig.sh, tkConfig.sh]")
return [nil, nil]
end
tclConfig_file = nil unless tclConfig_file.kind_of? String tclConfig_file = nil unless tclConfig_file.kind_of? String
tkConfig_file = nil unless tkConfig_file.kind_of? String
tclConfig_dir = nil unless tclConfig_dir.kind_of? String tclConfig_dir = nil unless tclConfig_dir.kind_of? String
tkConfig_dir = nil unless tkConfig_dir.kind_of? String tkConfig_dir = nil unless tkConfig_dir.kind_of? String
@ -552,34 +621,46 @@ def get_tclConfig(tclConfig_file, tclConfig_dir, tkConfig_dir)
tclConfig_dir = tkConfig_dir tclConfig_dir = tkConfig_dir
end end
end end
unless tkConfig_dir
if tkConfig_file
tkConfig_dir = File.dirname(tkConfig_file)
elsif tclConfig_dir
tkConfig_dir = tclConfig_dir
end
end
tkConfig_dir ||= tclConfig_dir tkConfig_dir ||= tclConfig_dir
TkLib_Config["tclConfig-file"] = tclConfig_file TkLib_Config["tclConfig-file"] = tclConfig_file
TkLib_Config["tkConfig-file"] = tkConfig_file
TkLib_Config["tclConfig-dir"] = tclConfig_dir TkLib_Config["tclConfig-dir"] = tclConfig_dir
TkLib_Config["tkConfig-dir"] = tkConfig_dir TkLib_Config["tkConfig-dir"] = tkConfig_dir
unless use_tclConfig print("Search tclConfig.sh and tkConfig.sh.")
puts("Don't use [tclConfig.sh, tkConfig.sh]") if tclConfig_dir
tclConfig, tkConfig =
search_tclConfig([ ((tclConfig_file)? tclConfig_file: tclConfig_dir),
((tkConfig_file)? tkConfig_file: tkConfig_dir) ])
else else
puts("Search tclConfig.sh and tkConfig.sh.") tclConfig, tkConfig = search_tclConfig()
if tclConfig_dir end
tclConfig, tkConfig = search_tclConfig([tclConfig_dir, tkConfig_dir]) print("\n")
else # TclConfig_Info = TkLib_Config["tclConfig_info"]
tclConfig, tkConfig = search_tclConfig() # TkConfig_Info = TkLib_Config["tkConfig_info"]
end
# TclConfig_Info = TkLib_Config["tclConfig_info"]
# TkConfig_Info = TkLib_Config["tkConfig_info"]
if tclConfig && tkConfig if tclConfig && tkConfig
puts("Use [tclConfig.sh,tkConfig.sh] == ['#{tclConfig}','#{tkConfig}']") dirs = TkLib_Config["tclConfig_paths"].map{|tclpath, tkpath|
$LIBPATH |= [File.dirname(tclConfig)] File.dirname(tclpath)
$LIBPATH |= [File.dirname(tkConfig)] }
#TkLib_Config["tclConfig_paths"].each{|tclcfg, tkcfg| dirs |= dirs
# $LIBPATH |= [File.dirname(tclcfg)] | [File.dirname(tkcfg)] puts("Valid tclConfig.sh and tkConfig.sh are found in #{dirs.inspect}")
#} puts("Use [tclConfig.sh,tkConfig.sh] == ['#{tclConfig}','#{tkConfig}']")
else $LIBPATH |= [File.dirname(tclConfig)]
puts("Fail to find [tclConfig.sh, tkConfig.sh]") $LIBPATH |= [File.dirname(tkConfig)]
end #TkLib_Config["tclConfig_paths"].each{|tclcfg, tkcfg|
# $LIBPATH |= [File.dirname(tclcfg)] | [File.dirname(tkcfg)]
#}
else
puts("Fail to find [tclConfig.sh, tkConfig.sh]")
end end
[tclConfig, tkConfig] [tclConfig, tkConfig]
@ -646,8 +727,28 @@ def check_shlib_search_path(paths)
end end
end end
def search_vers_on_path(vers, path, *heads)
files = Dir.glob(File.join(path, "*{#{heads.join(',')}}*.{#{CONFIG['LIBEXT']},#{CONFIG['DLEXT']}}"))
vers.find_all{|ver| files.find{|f| f =~ /(#{ver}|#{ver.delete('.')})/} }
end
def find_tcl(tcllib, stubs, version, *opt_paths) def find_tcl(tcllib, stubs, version, *opt_paths)
puts "Search Tcl library" print "Search Tcl library"
if stubs
func = "Tcl_InitStubs"
lib = "tclstub"
else
func = "Tcl_FindExecutable"
lib = "tcl"
end
if version && ! version.empty?
versions = [version]
else
versions = TkLib_Config['search_versions']
end
default_paths = [] default_paths = []
default_paths.concat [ default_paths.concat [
@ -667,72 +768,63 @@ def find_tcl(tcllib, stubs, version, *opt_paths)
end end
if (paths = opt_paths.compact).empty? if (paths = opt_paths.compact).empty?
if TclConfig_Info['config_file_path'] unless TclConfig_Info['config_file_path']
paths = check_NG_path(default_paths)
else
# use definisions on tclConfig.sh # use definisions on tclConfig.sh
TclConfig_Info['TCL_LIB_SPEC'].sub(TclConfig_Info['TCL_LIB_FLAG'],"").strip.sub("-L","") =~ /("|'|)([^"']+)\1/ TclConfig_Info['TCL_LIB_SPEC'].sub(TclConfig_Info['TCL_LIB_FLAG'],"").strip.sub("-L","") =~ /("|'|)([^"']+)\1/
$LIBPATH |= [$2] unless $2.empty? $LIBPATH |= [$2] unless $2.empty?
unless stubs if stubs
if TclConfig_Info['TCL_SUPPORTS_STUBS'] == '0' ||
TclConfig_Info['TCL_STUB_LIB_SPEC'].strip.empty?
print(".\n") # progress
puts "#{TclConfig_Info['config_file_path']} tells us that your Tcl/Tk library doesn't support stub."
return false
else
#*** Probably, TCL_LIBS is a subset of TK_LIBS. ***
unless is_win32? # ignore tclConfig on Windows
# $LDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
# $DLDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
$LDFLAGS << ' ' << TclConfig_Info['TCL_STUB_LIB_SPEC']
end
end
else
#*** Probably, TCL_LIBS is a subset of TK_LIBS. *** #*** Probably, TCL_LIBS is a subset of TK_LIBS. ***
unless is_win32? # ignore tclConfig on Windows unless is_win32? # ignore tclConfig on Windows
# $LDFLAGS << ' ' << TclConfig_Info['TCL_LIBS'] # $LDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
# $DLDFLAGS << ' ' << TclConfig_Info['TCL_LIBS'] # $DLDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
$LDFLAGS << ' ' << TclConfig_Info['TCL_LIB_SPEC'] $LDFLAGS << ' ' << TclConfig_Info['TCL_LIB_SPEC']
end end
return true
end end
if TclConfig_Info['TCL_SUPPORTS_STUBS'] == '0' || paths = [File.dirname(TclConfig_Info['config_file_path'])]
TclConfig_Info['TCL_STUB_LIB_SPEC'].strip.empty? versions = [TclConfig_Info['TCL_VERSION']]
puts "#{TclConfig_Info['config_file_path']} tells us that your Tcl/Tk library doesn't support stub."
return false
else
#*** Probably, TCL_LIBS is a subset of TK_LIBS. ***
unless is_win32? # ignore tclConfig on Windows
# $LDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
# $DLDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
$LDFLAGS << ' ' << TclConfig_Info['TCL_STUB_LIB_SPEC']
end
return true
end
end end
paths = check_NG_path(default_paths)
end end
if stubs ret = paths.map{|path|
func = "Tcl_InitStubs" if tcllib
lib = "tclstub" print(".")
else [path, find_library(tcllib, func, path)]
func = "Tcl_FindExecutable" else
lib = "tcl" st = search_vers_on_path(versions, path, lib, 'tcl').find{|ver|
end (print(".");find_library("#{lib}#{ver}", func, path)) or
(print(".");find_library("#{lib}#{ver.delete('.')}", func, path)) or
(print(".");find_library("#{lib}#{ver}g", func, path)) or
(print(".");find_library("#{lib}#{ver.delete('.')}g", func, path)) or
(print(".");find_library("tcl#{ver}", func, path)) or
(print(".");find_library("tcl#{ver.delete('.')}", func, path)) or
(print(".");find_library("tcl#{ver}g", func, path)) or
(print(".");find_library("tcl#{ver.delete('.')}g", func, path))
} || (!version && (print(".");find_library(lib, func, path)))
[path, st]
end
}
if version && ! version.empty? print("\n") # progress
versions = [version] ret
else
versions = TkLib_Config['search_versions']
end
if tcllib
st = find_library(tcllib, func, *paths)
else
st = versions.find { |ver|
find_library("#{lib}#{ver}", func, *paths) or
find_library("#{lib}#{ver.delete('.')}", func, *paths) or
find_library("#{lib}#{ver}g", func, *paths) or
find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
find_library("tcl#{ver}", func, *paths) or
find_library("tcl#{ver.delete('.')}", func, *paths) or
find_library("tcl#{ver}g", func, *paths) or
find_library("tcl#{ver.delete('.')}g", func, *paths)
} || (!version && find_library(lib, func, *paths))
end
unless st
puts("Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
end
st
end end
def parse_TK_LIBS(tklibs) def parse_TK_LIBS(tklibs)
@ -751,7 +843,22 @@ def parse_TK_LIBS(tklibs)
end end
def find_tk(tklib, stubs, version, *opt_paths) def find_tk(tklib, stubs, version, *opt_paths)
puts "Search Tk library" print "Search Tk library"
if stubs
func = "Tk_InitStubs"
lib = "tkstub"
else
func = "Tk_Init"
lib = "tk"
end
if version && ! version.empty?
versions = [version]
else
versions = TkLib_Config['search_versions']
end
default_paths = [] default_paths = []
default_paths.concat [ default_paths.concat [
@ -771,71 +878,79 @@ def find_tk(tklib, stubs, version, *opt_paths)
end end
if (paths = opt_paths.compact).empty? if (paths = opt_paths.compact).empty?
if TkConfig_Info['config_file_path'] unless TkConfig_Info['config_file_path']
paths = check_NG_path(default_paths)
else
# use definisions on tkConfig.sh # use definisions on tkConfig.sh
TkConfig_Info['TK_LIB_SPEC'].sub(TkConfig_Info['TK_LIB_FLAG'],"").strip.sub("-L","") =~ /("|'|)([^"']+)\1/ TkConfig_Info['TK_LIB_SPEC'].sub(TkConfig_Info['TK_LIB_FLAG'],"").strip.sub("-L","") =~ /("|'|)([^"']+)\1/
$LIBPATH |= [$2] unless $2.empty? $LIBPATH |= [$2] unless $2.empty?
unless stubs if stubs
if TkConfig_Info['TK_STUB_LIB_SPEC'].strip.empty?
print(".\n") # progress
puts "#{TkConfig_Info['config_file_path']} tells us that your Tcl/Tk library doesn't support stub."
return false
else
unless is_win32? # ignore tclConfig on Windows
# $LDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
$LDFLAGS << ' ' << TkConfig_Info['TK_LIBS']
# $DLDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
$LDFLAGS << ' ' << TkConfig_Info['TK_STUB_LIB_SPEC']
end
end
else
unless is_win32? # ignore tclConfig on Windows unless is_win32? # ignore tclConfig on Windows
# $LDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS']) # $LDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
$LDFLAGS << ' ' << TkConfig_Info['TK_LIBS'] unless is_win32? $LDFLAGS << ' ' << TkConfig_Info['TK_LIBS'] unless is_win32?
# $DLDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS']) # $DLDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
$LDFLAGS << ' ' << TkConfig_Info['TK_LIB_SPEC'] unless is_win32? $LDFLAGS << ' ' << TkConfig_Info['TK_LIB_SPEC'] unless is_win32?
end end
return true
end end
if TkConfig_Info['TK_STUB_LIB_SPEC'].strip.empty? paths = [File.dirname(TkConfig_Info['config_file_path'])]
puts "#{TkConfig_Info['config_file_path']} tells us that your Tcl/Tk library doesn't support stub." versions = [TkConfig_Info['TK_VERSION']]
return false
else
unless is_win32? # ignore tclConfig on Windows
# $LDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
$LDFLAGS << ' ' << TkConfig_Info['TK_LIBS']
# $DLDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
$LDFLAGS << ' ' << TkConfig_Info['TK_STUB_LIB_SPEC']
end
return true
end
end end
paths = check_NG_path(default_paths)
end end
if stubs ret = paths.map{|path|
func = "Tk_InitStubs" if tklib
lib = "tkstub" print(".")
else [path, find_library(tklib, func, path)]
func = "Tk_Init" else
lib = "tk" st = search_vers_on_path(versions, path, lib, 'tk').find{|ver|
(print(".");find_library("#{lib}#{ver}", func, path)) or
(print(".");find_library("#{lib}#{ver.delete('.')}", func, path)) or
(print(".");find_library("#{lib}#{ver}g", func, path)) or
(print(".");find_library("#{lib}#{ver.delete('.')}g", func, path)) or
(print(".");find_library("tk#{ver}", func, path)) or
(print(".");find_library("tk#{ver.delete('.')}", func, path)) or
(print(".");find_library("tk#{ver}g", func, path)) or
(print(".");find_library("tk#{ver.delete('.')}g", func, path))
} || (!version && (print(".");find_library(lib, func, path)))
[path, st]
end
}
print("\n") # progress
ret
end
def find_tcltk_library(tcllib, tklib, stubs, tclversion, tkversion,
tcl_opt_paths, tk_opt_paths)
ret = find_tcl(tcllib, stubs, tclversion, *tcl_opt_paths)
unless ret && ret.find{|path, val| val}
puts("Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
return false
end end
if version && ! version.empty? ret = find_tk(tklib, stubs, tkversion, *tk_opt_paths)
versions = [version] unless ret && ret.find{|path, val| val}
else
versions = TkLib_Config['search_versions']
end
if tklib
st = find_library(tklib, func, *paths)
else
st = versions.find { |ver|
find_library("#{lib}#{ver}", func, *paths) or
find_library("#{lib}#{ver.delete('.')}", func, *paths) or
find_library("#{lib}#{ver}g", func, *paths) or
find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
find_library("tk#{ver}", func, *paths) or
find_library("tk#{ver.delete('.')}", func, *paths) or
find_library("tk#{ver}g", func, *paths) or
find_library("tk#{ver.delete('.')}g", func, *paths)
} || (!version && find_library(lib, func, *paths))
end
unless st
puts("Warning:: cannot find Tk library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.") puts("Warning:: cannot find Tk library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
return false
end end
st
true
end end
def find_tcltk_header(tclver, tkver) def find_tcltk_header(tclver, tkver)
@ -943,20 +1058,25 @@ def search_X_libraries
if TkConfig_Info['TK_XINCLUDES'] && TkConfig_Info['TK_XLIBSW'] && if TkConfig_Info['TK_XINCLUDES'] && TkConfig_Info['TK_XLIBSW'] &&
!TkConfig_Info['TK_XINCLUDES'].strip.empty? && !TkConfig_Info['TK_XINCLUDES'].strip.empty? &&
!TkConfig_Info['TK_XLIBSW'].strip.empty? !TkConfig_Info['TK_XLIBSW'].strip.empty?
use_X = true && with_config("X11", (! is_win32?)) #use_X = true && with_config("X11", ! is_win32?)
use_X = with_config("X11", true)
else else
use_X = false || with_config("X11", false) #use_X = false || with_config("X11", false)
use_X = with_config("X11", false)
end end
else else
# depend on configure options # depend on configure options
use_X = with_config("X11", (! is_win32?)) use_X = with_config("X11", !(is_win32? || TkLib_Config["tcltk-framework"]))
end end
if use_X if use_X
puts("Use X11 libraries.") puts("Use X11 libraries.")
x11_idir, x11_ldir = dir_config("X11") x11_idir, x11_ldir = dir_config("X11")
x11_ldir2 = with_config("X11-lib") x11_ldir2 = with_config("X11-lib")
exit unless find_X11(x11_ldir2, x11_ldir) unless find_X11(x11_ldir2, x11_ldir)
puts("Can't find X11 libraries. So, can't make tcltklib.so which is required by Ruby/Tk.")
exit
end
end end
use_X use_X
@ -1120,25 +1240,42 @@ end
############################################################## ##############################################################
# main # main
############################################################## ##############################################################
# check header files # check header file
print("check functions.")
have_func("ruby_native_thread_p", "ruby.h") have_func("ruby_native_thread_p", "ruby.h")
print(".") # progress
have_func("rb_errinfo", "ruby.h") have_func("rb_errinfo", "ruby.h")
print(".") # progress
have_func("rb_safe_level", "ruby.h") have_func("rb_safe_level", "ruby.h")
print(".") # progress
have_func("rb_hash_lookup", "ruby.h") have_func("rb_hash_lookup", "ruby.h")
print(".") # progress
have_func("rb_proc_new", "ruby.h") have_func("rb_proc_new", "ruby.h")
print(".") # progress
have_func("rb_obj_untrust", "ruby.h") have_func("rb_obj_untrust", "ruby.h")
print(".") # progress
have_func("rb_obj_taint", "ruby.h") have_func("rb_obj_taint", "ruby.h")
print(".") # progress
have_func("rb_set_safe_level_force", "ruby.h") have_func("rb_set_safe_level_force", "ruby.h")
print("\n") # progress
print("check struct members.")
have_struct_member("struct RArray", "ptr", "ruby.h") have_struct_member("struct RArray", "ptr", "ruby.h")
print(".") # progress
have_struct_member("struct RArray", "len", "ruby.h") have_struct_member("struct RArray", "len", "ruby.h")
print("\n") # progress
# check libraries # check libraries
unless is_win32? unless is_win32?
print("check libraries.")
have_library("nsl", "t_open") have_library("nsl", "t_open")
print(".") # progress
have_library("socket", "socket") have_library("socket", "socket")
print(".") # progress
have_library("dl", "dlopen") have_library("dl", "dlopen")
print(".") # progress
have_library("m", "log") have_library("m", "log")
print("\n") # progress
end end
$CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM $CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
@ -1146,12 +1283,13 @@ $CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
TkLib_Config["ruby_with_thread"] = TkLib_Config["ruby_with_thread"] =
macro_defined?('HAVE_NATIVETHREAD', '#include "ruby.h"') macro_defined?('HAVE_NATIVETHREAD', '#include "ruby.h"')
#--------------------------------------------------- #---------------------------------------------------
# check requirement of Tcl/tk version # check requirement of Tcl/tk version
tcltk_version = with_config("tcltkversion") tcltk_version = with_config("tcltkversion")
tclver, tkver = tclver, tkver =
TkLib_Config["tcltkversion"] = check_tcltk_version(tcltk_version) TkLib_Config["tcltkversion"] = check_tcltk_version(tcltk_version)
puts("Specified Tcl/Tk version is #{[tclver, tkver]}") if tclver && tkver puts("Specified Tcl/Tk version is #{[tclver, tkver].inspect}") if tclver&&tkver
# use ActiveTcl ? # use ActiveTcl ?
#if activeTcl = with_config("ActiveTcl") #if activeTcl = with_config("ActiveTcl")
@ -1187,22 +1325,39 @@ if (TkLib_Config["tcltk-stubs"] = stubs)
$CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS' $CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS'
end end
# directory configuration of Tcl/Tk libraries
tk_idir, tk_ldir = dir_config("tk")
tcl_idir, tcl_ldir = dir_config("tcl")
tcl_idir = tk_idir unless tcl_idir
tcl_ldir = tk_ldir unless tcl_ldir
tk_idir = tcl_idir unless tk_idir
tk_ldir = tcl_ldir unless tk_ldir
# get tclConfig.sh/tkConfig.sh # get tclConfig.sh/tkConfig.sh
TkLib_Config["tcltk-NG-path"] = [] TkLib_Config["tcltk-NG-path"] = []
tclcfg, tkcfg = get_tclConfig(with_config("tclConfig-file", true), tclcfg, tkcfg = get_tclConfig(with_config("tclConfig-file", true),
with_config("tclConfig-dir", true), with_config("tkConfig-file", true),
with_config("tkConfig-dir", true)) with_config("tclConfig-dir", tcl_ldir || true),
with_config("tkConfig-dir", tk_ldir || true))
TclConfig_Info = TkLib_Config["tclConfig_info"] || {} TclConfig_Info = TkLib_Config["tclConfig_info"] || {}
TkConfig_Info = TkLib_Config["tkConfig_info"] || {} TkConfig_Info = TkLib_Config["tkConfig_info"] || {}
TclConfig_Info['config_file_path'] = tclcfg TclConfig_Info['config_file_path'] = tclcfg
TkConfig_Info['config_file_path'] = tkcfg TkConfig_Info['config_file_path'] = tkcfg
TclConfig_Info['TCL_INCLUDE_SPEC'] = "-I#{tcl_idir.quote}" if tcl_idir
TkConfig_Info['TK_INCLUDE_SPEC'] = "-I#{tk_idir.quote}" if tk_idir
tk_cfg_dir = File.dirname(TkConfig_Info['config_file_path']) rescue nil
tcl_cfg_dir = File.dirname(TclConfig_Info['config_file_path']) rescue nil
tk_ldir_list = [tk_ldir, tk_cfg_dir]
tcl_ldir_list = [tcl_ldir, tcl_cfg_dir]
# check tk_shlib_search_path # check tk_shlib_search_path
check_shlib_search_path(with_config('tk-shlib-search-path')) check_shlib_search_path(with_config('tk-shlib-search-path'))
# search X libraries
use_X = search_X_libraries
# set TCL_DEFS and TK_DEFS # set TCL_DEFS and TK_DEFS
# $CPPFLAGS += " #{TclConfig_Info['TCL_DEFS']}" # $CPPFLAGS += " #{TclConfig_Info['TCL_DEFS']}"
# $CPPFLAGS += " #{TkConfig_Info['TK_DEFS']}" # $CPPFLAGS += " #{TkConfig_Info['TK_DEFS']}"
@ -1214,28 +1369,20 @@ if TkLib_Config["tcltk-framework"]
setup_for_macosx_framework setup_for_macosx_framework
end end
# search Tcl/Tk libraries # name of Tcl/Tk libraries
tk_idir, tk_ldir = dir_config("tk")
tcl_idir, tcl_ldir = dir_config("tcl")
tk_ldir2 = with_config("tk-lib")
tcl_ldir2 = with_config("tcl-lib")
tk_ldir_list = [tk_ldir2, tk_ldir]
tcl_ldir_list = [tcl_ldir2, tcl_ldir]
tklib = with_config("tklib") tklib = with_config("tklib")
tcllib = with_config("tcllib") tcllib = with_config("tcllib")
TclConfig_Info['TCL_INCLUDE_SPEC'] = "-I#{tcl_idir.quote}" if tcl_idir # search X libraries
TkConfig_Info['TK_INCLUDE_SPEC'] = "-I#{tk_idir.quote}" if tk_idir use_X = search_X_libraries
#--------------------------------------------------- #---------------------------------------------------
if (TkLib_Config["tcltk-framework"] || if (TkLib_Config["tcltk-framework"] ||
( find_tcltk_header(tclver, tkver) && ( find_tcltk_header(tclver, tkver) &&
find_tcl(tcllib, stubs, tclver, *tcl_ldir_list) && find_tcltk_library(tcllib, tklib, stubs, tclver, tkver,
find_tk(tklib, stubs, tkver, *tk_ldir_list) ) ) && tcl_ldir_list, tk_ldir_list) ) ) &&
(stubs || pthread_check()) (stubs || pthread_check())
# create Makefile # create Makefile