187
194
if CROSS_COMPILING
189
196
if TkLib_Config["ActiveTcl"]
190
path_head.concat ["c:/ActiveTcl", "c:/Program Files/ActiveTcl"]
197
path_head.concat ["c:/ActiveTcl", "c:/Program Files/ActiveTcl",
198
"c:/Program Files (x86)/ActiveTcl"]
192
200
path_head.concat [
193
"c:/Tcl", "c:/Program Files/Tcl",
194
"/Tcl", "/Program Files/Tcl"
201
"c:/Tcl", "c:/Program Files/Tcl", "c:/Program Files (x86)/Tcl",
202
"/Tcl", "/Program Files/Tcl", "/Program Files (x86)/Tcl"
196
path_head.each{|dir| path_dirs << "#{dir}"}
205
#path_head.each{|dir| path_dirs << dir.dup if File.directory? dir}
206
path_head.each{|dir| path_dirs << File.expand_path(dir) if File.directory? dir}
209
["/usr/local/lib64", "/usr/lib64", "/usr/local/lib", "/usr/lib"].each{|dir|
210
#path_dirs << dir if File.directory? dir
211
path_dirs << File.expand_path(dir) if File.directory? dir
213
path_dirs |= ENV['LIBRARY_PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['LIBRARY_PATH']
214
path_dirs |= ENV['PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['PATH']
200
'/opt', '/pkg', '/share',
218
'/opt', '/pkg', '/share',
201
219
'/usr/local/opt', '/usr/local/pkg', '/usr/local/share', '/usr/local',
202
220
'/usr/opt', '/usr/pkg', '/usr/share', '/usr/contrib', '/usr'
204
222
next unless File.directory?(dir)
224
path_dirs << "#{dir}/lib64" if maybe_64bit?
206
225
path_dirs << "#{dir}/lib"
207
226
path_dirs << "#{dir}" unless Dir.glob("#{dir}/lib*.*", File::FNM_CASEFOLD).empty?
447
RbConfig::CONFIG['libdir'],
448
File.join(RbConfig::CONFIG['exec_prefix'], 'lib'),
449
File.join(RbConfig::CONFIG['prefix'], 'lib'),
450
"/usr/local/opt/lib", "/usr/local/pkg/lib", "/usr/local/share/lib",
451
"/usr/local/lib", "/usr/opt/lib", "/usr/pkg/lib",
452
"/usr/share/lib", "/usr/contrib/lib", "/usr/lib"
456
'/opt', '/pkg', '/share',
467
config_dir << RbConfig::CONFIG['libdir']
469
((maybe_64bit?)? ['lib64', 'lib']: ['lib']).each{|dir|
471
File.join(RbConfig::CONFIG['exec_prefix'], dir),
472
File.join(RbConfig::CONFIG['prefix'], dir),
473
"/usr/local/opt/#{dir}", "/usr/local/pkg/#{dir}",
474
"/usr/local/share/#{dir}", "/usr/local/#{dir}",
475
"/usr/opt/#{dir}", "/usr/pkg/#{dir}", "/usr/share/#{dir}",
476
"/usr/contrib/#{dir}", "/usr/#{dir}"
481
'/opt', '/pkg', '/share',
457
482
'/usr/local/opt', '/usr/local/pkg', '/usr/local/share', '/usr/local',
458
483
'/usr/opt', '/usr/pkg', '/usr/share', '/usr/contrib', '/usr'
460
Dir.glob(dir + '/{tcltk,tcl,tk}[87]*/lib', File::FNM_CASEFOLD)
461
Dir.glob(dir + '/{tcltk,tcl,tk}[87]*', File::FNM_CASEFOLD)
485
Dir.glob(dir + "/{tcltk,tcl,tk}[#{TkLib_Config['major_nums']}*/lib",
487
Dir.glob(dir + "/{tcltk,tcl,tk}[#{TkLib_Config['major_nums']}*",
462
489
Dir.glob(dir + '/{tcltk,tcl,tk}/lib', File::FNM_CASEFOLD)
463
490
Dir.glob(dir + '/{tcltk,tcl,tk}', File::FNM_CASEFOLD)
524
569
tkfunc = "Tk_Init"
572
incflags = ($INCFLAGS ||= "").dup
573
libpath = ($LIBPATH ||= []).dup
574
libs_param = ($libs ||= "").dup
531
tcllib_ok ||= Dir.glob(File.join(dir, "*tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}{.,}#{tclconf['TCL_MINOR_VERSION']}*.*"), File::FNM_CASEFOLD).find{|file|
532
if file =~ /^.*(tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}(\.|)#{tclconf['TCL_MINOR_VERSION']}.*)\.[^.]*$/
533
#puts "check #{file} #{$1} #{tclfunc} #{dir}"
534
#find_library($1, tclfunc, dir)
535
tcllibs = append_library($libs, $1)
536
$LIBPATH = libpath | [dir]
537
try_func(tclfunc, tcllibs)
540
tklib_ok ||= Dir.glob(File.join(dir, "*tk#{stub}#{tkconf['TK_MAJOR_VERSION']}{.,}#{tkconf['TK_MINOR_VERSION']}*.*"), File::FNM_CASEFOLD).find{|file|
541
if file =~ /^.*(tk#{stub}#{tkconf['TK_MAJOR_VERSION']}(\.|)#{tkconf['TK_MINOR_VERSION']}.*)\.[^.]*$/
542
#puts "check #{file} #{$1} #{tkfunc} #{dir}"
543
# find_library($1, tkfunc, dir)
544
tklibs = append_library(tcllibs, $1)
545
$LIBPATH = libpath | [dir]
546
try_func(tkfunc, tklibs)
578
tclver, tkver = TkLib_Config["tcltkversion"]
579
exts = "(" + get_ext_list.join('|') + ")"
582
tcl_glob = "*tcl#{stub}#{tclver}.*"
583
tcl_regexp = /^.*(tcl#{stub}#{tclver}.*)\.(#{exts}).*$/
585
tcl_glob = "*tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}{.,}#{tclconf['TCL_MINOR_VERSION']}*.*"
586
tcl_regexp = /^.*(tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}(?:\.|)#{tclconf['TCL_MINOR_VERSION']}.*)\.(#{exts}).*$/
589
tk_glob = "*tk#{stub}#{tkver}.*"
590
tk_regexp = /^.*(tk#{stub}#{tkver}.*)\.(#{exts}).*$/
592
tk_glob = "*tk#{stub}#{tkconf['TK_MAJOR_VERSION']}{.,}#{tkconf['TK_MINOR_VERSION']}*.*"
593
tk_regexp = /^.*(tk#{stub}#{tkconf['TK_MAJOR_VERSION']}(?:\.|)#{tkconf['TK_MINOR_VERSION']}.*)\.#{exts}.*$/
596
tcllib_ok ||= !tclconf || Dir.glob(File.join(tcldir, tcl_glob), File::FNM_CASEFOLD).find{|file|
597
if file =~ tcl_regexp
601
$INCFLAGS = incflags.dup << " " << tclconf["TCL_INCLUDE_SPEC"]
602
#puts "check #{file} #{$1} #{tclfunc} #{tcldir}"
603
#find_library($1, tclfunc, tcldir)
604
if (tclconf && tclconf["TCL_SHARED_BUILD"] == "0") ||
605
(ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) || ext == "a"
607
tcllibs = $libs + " -DSTATIC_BUILD " + file.quote
609
# FIX ME: avoid pathname trouble (fail to find) on MinGW.
610
# e.g. TCL_INCLUDE_SPEC describes "-I/usr/local/include",
611
# but compiler can find "-IC:/msys/1.0/local/include" only.
612
$INCFLAGS << " -I" << File.join(File.dirname(File.dirname(file)),"include") if is_win32?
614
tcllibs = append_library($libs, libname)
615
tcllibs = "-L#{tcldir.quote} " + tcllibs
617
# FIX ME: avoid pathname trouble (fail to find) on MinGW.
618
$INCFLAGS << " -I" << File.join(File.dirname(tcldir),"include") if is_win32?
621
$LIBPATH = libpath | [tcldir]
622
try_func(tclfunc, tcllibs, ["tcl.h"]) ||
623
( try_func(tclfunc, tcllibs << " " << tclconf['TCL_LIBS'], ["tcl.h"]) if tclconf['TCL_LIBS'] )
628
'LIBNAME' => libname,
629
'libs' => tcllibs.dup,
630
'INCFLAGS' => $INCFLAGS.dup,
631
'LIBPATH' => $LIBPATH.dup,
633
$LIBPATH = libpath.dup
634
$libs = libs_param.dup
638
tclconf['MKMF_PARAMS'] = mkmf_param if tclconf && tcllib_ok
640
tklib_ok ||= !tkconf || Dir.glob(File.join(tkdir, tk_glob), File::FNM_CASEFOLD).find{|file|
645
#puts "check #{file} #{$1} #{tkfunc} #{tkdir}"
646
# find_library($1, tkfunc, tkdir)
647
if (tkconf && tkconf["TCL_SHARED_BUILD"] == "0") ||
648
(ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) || ext == "a"
650
tklibs = " -DSTATIC_BUILD " + file.quote
652
# FIX ME: avoid pathname trouble (fail to find) on MinGW.
653
$INCFLAGS << " -I" << File.join(File.dirname(File.dirname(file)),"include") if is_win32?
655
tklibs = append_library("", libname)
656
#tklibs = append_library("", $1)
657
tklibs = "-L#{tkdir.quote} " + tklibs
659
# FIX ME: avoid pathname trouble (fail to find) on MinGW.
660
$INCFLAGS << " -I" << File.join(File.dirname(tcldir),"include") if is_win32?
663
tklibs << " " << tcllibs if tcllibs
664
tmp_tklibs = tklibs.dup
665
$LIBPATH = libpath | [tkdir]
666
try_func(tkfunc, tklibs, ["tcl.h", "tk.h"]) ||
667
( try_func(tkfunc, tklibs << " " << tkconf['TK_LIBS'], ["tcl.h", "tk.h"]) if tkconf['TK_LIBS'] ) ||
668
( try_func(tkfunc, (tklibs = tmp_tklibs.dup) << " " << tkconf['TK_XLIBSW'], ["tcl.h", "tk.h"]) if tkconf['TK_XLIBSW'] ) ||
669
( try_func(tkfunc, tklibs << " " << tkconf['TK_LIBS'], ["tcl.h", "tk.h"]) if tkconf['TK_LIBS'] )
674
'LIBNAME' => libname,
675
'libs' => tklibs.dup,
676
'INCFLAGS' => $INCFLAGS.dup,
677
'LIBPATH' => $LIBPATH.dup,
679
$LIBPATH = libpath.dup
680
$libs = libs_param.dup
685
$INCFLAGS = incflags.dup
686
tkconf['MKMF_PARAMS'] = mkmf_param if tkconf && tklib_ok
553
688
[tcllib_ok, tklib_ok]
594
755
tails = ['Config-shared.sh', 'config-shared.sh', 'Config.sh', 'config.sh']
596
if File.file?(tcldir)
597
tclcfg_files = [tcldir] * tails.length
599
tclcfg_files = tails.map{|f| File.join(tcldir, 'tcl' << f)}
603
tkcfg_files = [tkdir] * tails.length
605
tkcfg_files = tails.map{|f| File.join(tkdir, 'tk' << f)}
608
tclcfg_files.zip(tkcfg_files).uniq.each{|tclpath, tkpath|
609
next if !File.exist?(tclpath) || !File.exist?(tkpath)
758
if File.file?(tcldir)
759
tclcfg_files = [tcldir] * tails.length
761
tclcfg_files = tails.map{|f| File.join(tcldir, 'tcl' << f)}
764
tclcfg_files = [nil] * tails.length
769
tkcfg_files = [tkdir] * tails.length
771
tkcfg_files = tails.map{|f| File.join(tkdir, 'tk' << f)}
774
tkcfg_files = [nil] * tails.length
777
tclcfg_files.zip(tkcfg_files).map{|tclpath, tkpath|
778
[ (tclpath && File.exist?(tclpath))? File.expand_path(tclpath): tclpath,
779
(tkpath && File.exist?(tkpath))? File.expand_path(tkpath): tkpath ]
780
}.uniq.each{|tclpath, tkpath|
781
next if tclpath && !File.exist?(tclpath)
782
next if tkpath && !File.exist?(tkpath)
611
784
# parse tclConfig.sh/tkConfig.sh
612
tclconf = parse_tclConfig(tclpath)
613
next if tclver && tclver !~ /^#{tclconf['TCL_MAJOR_VERSION']}(\.?)#{tclconf['TCL_MINOR_VERSION']}/
614
tkconf = parse_tclConfig(tkpath)
615
next if tkver && tkver !~ /^#{tkconf['TK_MAJOR_VERSION']}(\.?)#{tkconf['TK_MINOR_VERSION']}/
785
tclconf = (tclpath)? parse_tclConfig(tclpath): nil
786
next if tclconf && tclver && ((tclver_major && tclver_major != tclconf['TCL_MAJOR_VERSION']) || (tclver_minor && tclver_minor != tclconf['TCL_MINOR_VERSION']))
788
tkconf = (tkpath)? parse_tclConfig(tkpath): nil
789
next if tkconf && tkver && ((tkver_major && tkver_major != tkconf['TK_MAJOR_VERSION']) || (tkver_minor && tkver_minor != tkconf['TK_MINOR_VERSION']))
617
791
# nativethread check
618
if !TkLib_Config["ruby_with_thread"] && tclconf['TCL_THREADS'] == '1'
619
puts "\nWARNING: found #{tclpath.inspect}, but it WITH nativethread-support under ruby WITHOUT nativethread-support. So, ignore it."
620
TkLib_Config["tcltk-NG-path"] << File.dirname(tclpath)
792
if !TkLib_Config["ruby_with_thread"]
794
if tclconf['TCL_THREADS'] == '1'
795
puts "\nWARNING: found #{tclpath.inspect}, but it WITH nativethread-support under ruby WITHOUT nativethread-support. So, ignore it."
796
TkLib_Config["tcl-NG-path"] << File.dirname(tclpath)
800
puts "\nWARNING: When not refer tclConfig.sh, cannot check native-thread support on Tcl/Tk libraries. Ruby, which is used now, does NOT support native-thread. So, if Tcl/Tk libraries support native-thread, it will NOT work properly."
624
804
# find tclConfig.sh & tkConfig.sh
629
809
# if use framework, not check (believe it is installed properly)
630
810
tcllib_ok = tklib_ok = true
632
tcllib_ok, tklib_ok = libcheck_for_tclConfig(File.dirname(tclpath),
635
tcllib_ok = tklib_ok = false
636
if TkLib_Config["tcltk-stubs"]
638
tclfunc = "Tcl_InitStubs"
639
tkfunc = "Tk_InitStubs"
642
tclfunc = "Tcl_FindExecutable"
645
dir = File.dirname(tclpath)
650
tcllib_ok ||= Dir.glob(File.join(dir, "*tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}{.,}#{tclconf['TCL_MINOR_VERSION']}*.*"), File::FNM_CASEFOLD).find{|file|
651
if file =~ /^.*(tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}(\.|)#{tclconf['TCL_MINOR_VERSION']}.*)\.[^.]*$/
652
#puts "check #{file} #{$1} #{tclfunc} #{dir}"
653
#find_library($1, tclfunc, dir)
654
tcllibs = append_library($libs, $1)
655
$LIBPATH = libpath | [dir]
656
try_func(tclfunc, tcllibs)
659
tklib_ok ||= Dir.glob(File.join(dir, "*tk#{stub}#{tkconf['TK_MAJOR_VERSION']}{.,}#{tkconf['TK_MINOR_VERSION']}*.*"), File::FNM_CASEFOLD).find{|file|
660
if file =~ /^.*(tk#{stub}#{tkconf['TK_MAJOR_VERSION']}(\.|)#{tkconf['TK_MINOR_VERSION']}.*)\.[^.]*$/
661
#puts "check #{file} #{$1} #{tkfunc} #{dir}"
662
# find_library($1, tkfunc, dir)
663
tklibs = append_library(tcllibs, $1)
664
$LIBPATH = libpath | [dir]
665
try_func(tkfunc, tklibs)
812
tcllib_ok, tklib_ok =
813
libcheck_for_tclConfig((tclpath)? File.dirname(tclpath): nil,
814
(tkpath)? File.dirname(tkpath): nil,
674
818
unless tcllib_ok && tklib_ok
675
puts "\nWARNING: found #{tclpath.inspect}, but cannot find valid Tcl/Tk libraries on the same directory. So, ignore it."
676
TkLib_Config["tcltk-NG-path"] << File.dirname(tclpath)
820
puts "\nWARNING: found #{tclpath.inspect}, but cannot find valid Tcl library for the tclConfig.sh. So, ignore it."
821
TkLib_Config["tcl-NG-path"] << File.dirname(tclpath)
824
puts "\nWARNING: found #{tkpath.inspect}, but cannot find valid Tk library for the tkConfig.sh. So, ignore it."
825
TkLib_Config["tk-NG-path"] << File.dirname(tkpath)
732
882
tkConfig_dir ||= tclConfig_dir
734
TkLib_Config["tclConfig-file"] = tclConfig_file
735
TkLib_Config["tkConfig-file"] = tkConfig_file
736
TkLib_Config["tclConfig-dir"] = tclConfig_dir
737
TkLib_Config["tkConfig-dir"] = tkConfig_dir
739
print("Search tclConfig.sh", (tclConfig_dir)? " (in #{tclConfig_dir})": "",
740
" and tkConfig.sh", (tkConfig_dir)? " (in #{tkConfig_dir})": "", ".")
742
tclConfig, tkConfig =
743
search_tclConfig([ ((tclConfig_file)? tclConfig_file: tclConfig_dir),
885
TkLib_Config["tclConfig-file"] = tclConfig_file
886
TkLib_Config["tclConfig-dir"] = tclConfig_dir
888
tclConfig_file = false
889
tclConfig_dir = false
892
TkLib_Config["tkConfig-file"] = tkConfig_file
893
TkLib_Config["tkConfig-dir"] = tkConfig_dir
895
tkConfig_file = false
899
print ("Don't use tclConfig.sh (specified by configure option).\n") unless use_tclConfig
900
print ("Don't use tkConfig.sh (specified by configure option).\n") unless use_tkConfig
902
print("tclConfig.sh", (tclConfig_dir)? " (in #{tclConfig_dir})": "") if use_tclConfig
903
print((use_tclConfig)? " and ": "", "tkConfig.sh", (tkConfig_dir)? " (in #{tkConfig_dir})": "") if use_tkConfig
906
if tclConfig_dir || tkConfig_dir || !use_tclConfig || !use_tkConfig
907
tclConfig, tkConfig =
908
search_tclConfig([ ((tclConfig_file)? tclConfig_file: tclConfig_dir),
744
909
((tkConfig_file)? tkConfig_file: tkConfig_dir) ])
746
911
tclConfig, tkConfig = search_tclConfig()
832
1010
# keep paths for searching dynamic libs
833
$LIBPATH |= path_list
1011
#$LIBPATH |= path_list
836
1015
def search_vers_on_path(vers, path, *heads)
837
if enable_config("shared") == false
838
exts = CONFIG['LIBEXT'] + ',' + CONFIG['DLEXT']
840
exts = CONFIG['DLEXT'] + ',' + CONFIG['LIBEXT']
842
exts << ",dll,lib" if is_win32?
843
exts << ",bundle,dylib" if is_macosx? || /nextstep|openstep|rhapsody/ =~ RUBY_PLATFORM
1016
exts = get_ext_list.join(',')
844
1017
files = Dir.glob(File.join(path, "*{#{heads.join(',')}}*.{#{exts}}"), File::FNM_CASEFOLD)
845
1018
vers.find_all{|ver| files.find{|f| f =~ /(#{ver}|#{ver.delete('.')})/} }
848
1021
def find_tcl(tcllib, stubs, version, *opt_paths)
1022
if TclConfig_Info['MKMF_PARAMS']
1023
# already checked existence of tcl library based on tclConfig.sh
1024
($INCFLAGS ||= "") << " " << TclConfig_Info['MKMF_PARAMS']['INCFLAGS']
1025
$LIBPATH ||= []; $LIBPATH |= TclConfig_Info['MKMF_PARAMS']['LIBPATH']
1026
($libs ||= "") << " " << TclConfig_Info['MKMF_PARAMS']['libs']
1027
return [true, nil, nil, nil]
1029
# else, no available tclConfig.sh on the system
849
1031
print "Search Tcl library"
878
1060
if !CROSS_COMPILING and is_win32?
879
1061
default_paths.concat [
880
"c:/Tcl/lib", "c:/Program Files/Tcl/lib",
881
"/Tcl/lib", "/Program Files/Tcl/lib"
882
].find_all{|dir| File.directory?(dir)}
1062
"c:/Tcl/lib","c:/Program Files/Tcl/lib","c:/Program Files (x86)/Tcl/lib",
1063
"/Tcl/lib","/Program Files/Tcl/lib","/Program Files (x86)/Tcl/lib"
1064
].find_all{|dir| File.directory?(dir)}.map{|dir| File.expand_path(dir)}
1067
["/usr/local/lib64", "/usr/lib64", "/usr/local/lib", "/usr/lib"].each{|dir|
1068
default_paths << File.expand_path(dir) if File.directory? dir
1071
default_paths |= ENV['LIBRARY_PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['LIBRARY_PATH']
1072
default_paths |= ENV['PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['PATH']
1075
default_paths |= TkLib_Config["checked_shlib_dirs"]
885
1077
unless TkLib_Config["space-on-tk-libpath"]
886
1078
default_paths.delete_if{|path| path =~ / /}
889
1081
if (paths = opt_paths.compact).empty?
890
unless TclConfig_Info['config_file_path']
891
paths = check_NG_path(default_paths)
894
# use definisions on tclConfig.sh
895
TclConfig_Info['TCL_LIB_SPEC'].sub(TclConfig_Info['TCL_LIB_FLAG'],"").strip.sub("-L","") =~ /("|'|)([^"']+)\1/
896
$LIBPATH |= [$2] unless $2.empty?
899
if TclConfig_Info['TCL_SUPPORTS_STUBS'] == '0' ||
900
TclConfig_Info['TCL_STUB_LIB_SPEC'].strip.empty?
901
print(".\n") # progress
902
puts "#{TclConfig_Info['config_file_path']} tells us that your Tcl/Tk library doesn't support stub."
905
#*** Probably, TCL_LIBS is a subset of TK_LIBS. ***
906
unless is_win32? # ignore tclConfig on Windows
907
# $LDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
908
# $DLDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
909
$LDFLAGS << ' ' << TclConfig_Info['TCL_STUB_LIB_SPEC']
1082
paths = check_tcl_NG_path(default_paths)
1085
incflags = ($INCFLAGS ||= "").dup
1086
libpath = ($LIBPATH ||= []).dup
1087
libs_param = ($libs ||= "").dup
1090
exts = "(" + get_ext_list.join('|') + ")"
1096
inc = [File.join(File.dirname(path),"include"), File.dirname(path)]
1097
inc.each{|f| $INCFLAGS << " -I" << f }
1101
if have_library(tcllib, func, ["tcl.h"])
1102
return [true, path, lib_w_sufx, nil, *inc]
913
#*** Probably, TCL_LIBS is a subset of TK_LIBS. ***
914
unless is_win32? # ignore tclConfig on Windows
915
# $LDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
916
# $DLDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
917
$LDFLAGS << ' ' << TclConfig_Info['TCL_LIB_SPEC']
1105
sufx_list = ['', 't', 'g', 's', 'x']
1106
search_vers_on_path(versions, path, lib, 'tcl').find{|ver|
1107
dir_enum = Dir.foreach(path)
1108
no_dot_ver = ver.delete('.')
1109
libnames = ["#{lib}#{ver}", "#{lib}#{no_dot_ver}"]
1110
libnames << "tcl#{ver}" << "tcl#{no_dot_ver}" if lib != "tcl"
1111
libnames.find{|libname|
1112
sufx_list.find{|sufx|
1114
dir_enum.map{|fname|
1115
if fname =~ /^.*(#{libname}.*#{sufx})\.(#{exts}).*$/
1118
}.compact.find{|fname, lib_w_sufx, ext|
1120
if (ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) ||
1123
tcllibs = libs_param + " -DSTATIC_BUILD " + fname.quote
1125
tcllibs = append_library($libs, lib_w_sufx)
1126
tcllibs = "-L#{path.quote} " + tcllibs
1128
if try_func(func, tcllibs, ["tcl.h"])
1129
return [true, path, nil, tcllibs, *inc]
1135
if (!version && (print(".");try_func(func, libs_param, ["tcl.h"])))
1136
return [true, path, lib_w_sufx, nil, *inc]
921
paths = [File.dirname(TclConfig_Info['config_file_path'])]
922
versions = [TclConfig_Info['TCL_VERSION']]
926
ret = paths.map{|path|
929
[path, find_library(tcllib, func, path)]
931
st = search_vers_on_path(versions, path, lib, 'tcl').find{|ver|
932
(print(".");find_library("#{lib}#{ver}", func, path)) or
933
(print(".");find_library("#{lib}#{ver.delete('.')}", func, path)) or
934
(print(".");find_library("#{lib}#{ver}g", func, path)) or
935
(print(".");find_library("#{lib}#{ver.delete('.')}g", func, path)) or
936
(print(".");find_library("tcl#{ver}", func, path)) or
937
(print(".");find_library("tcl#{ver.delete('.')}", func, path)) or
938
(print(".");find_library("tcl#{ver}g", func, path)) or
939
(print(".");find_library("tcl#{ver.delete('.')}g", func, path))
940
} || (!version && (print(".");find_library(lib, func, path)))
1140
$LIBPATH = libpath.dup
1141
$libs = libs_param.dup
1142
$INCFLAGS = incflags.dup
945
1146
print("\n") # progress
1147
[false, nil, nil, nil]
949
1150
def parse_TK_LIBS(tklibs)
990
1200
if !CROSS_COMPILING and is_win32?
991
1201
default_paths.concat [
992
"c:/Tcl/lib", "c:/Program Files/Tcl/lib",
993
"/Tcl/lib", "/Program Files/Tcl/lib"
1202
"c:/Tcl/lib","c:/Program Files/Tcl/lib","c:/Program Files (x86)/Tcl/lib",
1203
"/Tcl/lib","/Program Files/Tcl/lib","/Program Files (x86)/Tcl/lib"
994
1204
].find_all{|dir| File.directory?(dir)}
1207
["/usr/local/lib64", "/usr/lib64", "/usr/local/lib", "/usr/lib"].each{|dir|
1208
default_paths << File.expand_path(dir) if File.directory? dir
1211
default_paths |= ENV['LIBRARY_PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['LIBRARY_PATH']
1212
default_paths |= ENV['PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['PATH']
1215
default_paths |= TkLib_Config["checked_shlib_dirs"]
997
1217
unless TkLib_Config["space-on-tk-libpath"]
998
1218
default_paths.delete_if{|path| path =~ / /}
1001
1221
if (paths = opt_paths.compact).empty?
1002
unless TkConfig_Info['config_file_path']
1003
paths = check_NG_path(default_paths)
1006
# use definisions on tkConfig.sh
1007
TkConfig_Info['TK_LIB_SPEC'].sub(TkConfig_Info['TK_LIB_FLAG'],"").strip.sub("-L","") =~ /("|'|)([^"']+)\1/
1008
$LIBPATH |= [$2] unless $2.empty?
1011
if TkConfig_Info['TK_STUB_LIB_SPEC'].strip.empty?
1012
print(".\n") # progress
1013
puts "#{TkConfig_Info['config_file_path']} tells us that your Tcl/Tk library doesn't support stub."
1016
unless is_win32? # ignore tclConfig on Windows
1017
# $LDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
1018
$LDFLAGS << ' ' << TkConfig_Info['TK_LIBS']
1019
# $DLDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
1020
$LDFLAGS << ' ' << TkConfig_Info['TK_STUB_LIB_SPEC']
1222
paths = check_tk_NG_path(default_paths)
1225
incflags = ($INCFLAGS ||= "").dup
1226
libpath = ($LIBPATH ||= []).dup
1227
libs_param = ($libs ||= "").dup
1230
exts = "(" + get_ext_list.join('|') + ")"
1236
inc = [File.join(File.dirname(path),"include"), File.dirname(path)]
1237
inc.each{|f| $INCFLAGS << " -I" << f }
1241
if have_library(tklib, func, ["tcl.h", "tk.h"])
1242
return [true, path, lib_w_sufx, nil, *inc]
1024
unless is_win32? # ignore tclConfig on Windows
1025
# $LDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
1026
$LDFLAGS << ' ' << TkConfig_Info['TK_LIBS'] unless is_win32?
1027
# $DLDFLAGS << ' ' << parse_TK_LIBS(TkConfig_Info['TK_LIBS'])
1028
$LDFLAGS << ' ' << TkConfig_Info['TK_LIB_SPEC'] unless is_win32?
1245
sufx_list = ['', 't', 'g', 's', 'x']
1246
search_vers_on_path(versions, path, lib, 'tk').find{|ver|
1247
dir_enum = Dir.foreach(path)
1248
no_dot_ver = ver.delete('.')
1249
libnames = ["#{lib}#{ver}", "#{lib}#{no_dot_ver}"]
1250
libnames << "tk#{ver}" << "tk#{no_dot_ver}" if lib != "tk"
1251
libnames.find{|libname|
1252
sufx_list.find{|sufx|
1254
dir_enum.map{|fname|
1255
if fname =~ /^.*(#{libname}.*#{sufx})\.(#{exts}).*$/
1258
}.compact.find{|fname, lib_w_sufx, ext|
1259
if (ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) ||
1262
tklibs = libs_param + " -DSTATIC_BUILD " + fname.quote
1264
tklibs = append_library($libs, lib_w_sufx)
1265
tklibs = "-L#{path.quote} " + tklibs
1267
if try_func(func, tklibs, ["tcl.h", "tk.h"])
1268
return [true, path, nil, tklibs, *inc]
1274
if (!version && (print(".");try_func(func, libs_param, ["tcl.h", "tk.h"])))
1275
return [true, path, lib_w_sufx, nil, *inc]
1032
paths = [File.dirname(TkConfig_Info['config_file_path'])]
1033
versions = [TkConfig_Info['TK_VERSION']]
1037
ret = paths.map{|path|
1040
[path, find_library(tklib, func, path)]
1042
st = search_vers_on_path(versions, path, lib, 'tk').find{|ver|
1043
(print(".");find_library("#{lib}#{ver}", func, path)) or
1044
(print(".");find_library("#{lib}#{ver.delete('.')}", func, path)) or
1045
(print(".");find_library("#{lib}#{ver}g", func, path)) or
1046
(print(".");find_library("#{lib}#{ver.delete('.')}g", func, path)) or
1047
(print(".");find_library("tk#{ver}", func, path)) or
1048
(print(".");find_library("tk#{ver.delete('.')}", func, path)) or
1049
(print(".");find_library("tk#{ver}g", func, path)) or
1050
(print(".");find_library("tk#{ver.delete('.')}g", func, path))
1051
} || (!version && (print(".");find_library(lib, func, path)))
1281
$INCFLAGS = incflags.dup
1056
1285
print("\n") # progress
1286
[false, nil, nil, nil]
1060
def find_tcltk_library(tcllib, tklib, stubs, tclversion, tkversion,
1289
def find_tcltk_library(tcllib, tklib, stubs, tclversion, tkversion,
1061
1290
tcl_opt_paths, tk_opt_paths)
1062
ret = find_tcl(tcllib, stubs, tclversion, *tcl_opt_paths)
1063
unless ret && ret.find{|path, val| val}
1064
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.")
1291
st,path,lib,libs,*inc = find_tcl(tcllib, stubs, tclversion, *tcl_opt_paths)
1293
puts("Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options.")
1296
($LIBPATH ||= []; $LIBPATH |= [path]) if path
1297
$libs = append_library($libs, lib) if lib
1298
($libs ||= "") << " " << libs if libs
1300
inc.each{|f| $INCFLAGS << " -I" << f}
1068
ret = find_tk(tklib, stubs, tkversion, *tk_opt_paths)
1069
unless ret && ret.find{|path, val| val}
1070
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.")
1303
st,path,lib,libs,*inc = find_tk(tklib, stubs, tkversion, *tk_opt_paths)
1305
puts("Warning:: cannot find Tk library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options.")
1308
($LIBPATH ||= []; $LIBPATH |= [path]) if path
1309
$libs = append_library($libs, lib) if lib && !lib.empty?
1310
($libs ||= "") << " " << libs if libs
1312
inc.each{|f| $INCFLAGS << " -I" << f}
1081
1322
File.join(RbConfig::CONFIG['prefix'], 'include'),
1082
1323
"/usr/local/include", "/usr/pkg/include", "/usr/contrib/include",
1084
].find_all{|dir| File.directory?(dir)}
1325
].find_all{|dir| File.directory?(dir)}.map{|dir| File.expand_path(dir)}
1086
1327
if !CROSS_COMPILING && is_win32?
1087
1328
base_dir.concat [
1088
"c:/Tcl/include", "c:/Program Files/Tcl/include",
1089
"/Tcl/include", "/Program Files/Tcl/include"
1090
].find_all{|dir| File.directory?(dir)}
1329
"c:/Tcl/include","c:/Program Files/Tcl/include",
1330
"c:/Program Files (x86)/Tcl/include",
1331
"/Tcl/include","/Program Files/Tcl/include",
1332
"/Program Files (x86)/Tcl/include"
1333
].find_all{|dir| File.directory?(dir)}.map{|dir| File.expand_path(dir)}
1336
base_dir |= ENV['CPATH'].split(';').find_all{|dir| File.directory?(dir)}.map{|dir| File.expand_path(dir)}
1340
base_dir |= TkLib_Config["checked_shlib_dirs"]
1093
1342
unless TkLib_Config["space-on-tk-libpath"]
1094
1343
base_dir.delete_if{|path| path =~ / /}
1097
if TclConfig_Info['TCL_INCLUDE_SPEC'] &&
1098
have_tcl_h = try_cpp('#include <tcl.h>', TclConfig_Info['TCL_INCLUDE_SPEC'])
1099
$INCFLAGS << " " << TclConfig_Info['TCL_INCLUDE_SPEC']
1100
elsif have_tcl_h = have_header('tcl.h')
1103
if tclver && ! tclver.empty?
1106
versions = TkLib_Config['search_versions']
1108
paths = base_dir.dup
1110
paths.concat(base_dir.map{|dir|
1111
[dir + '/tcl' + ver, dir + '/tcl' + ver.delete('.')]
1114
have_tcl_h = find_header('tcl.h', *paths)
1117
if TkConfig_Info['TK_INCLUDE_SPEC'] &&
1118
have_tk_h = try_cpp('#include <tk.h>', TkConfig_Info['TK_INCLUDE_SPEC'])
1119
$INCFLAGS << " " << TkConfig_Info['TK_INCLUDE_SPEC']
1120
elsif have_tk_h = have_header('tk.h')
1123
if tkver && ! tkver.empty?
1126
versions = TkLib_Config['search_versions']
1128
paths = base_dir.dup
1130
paths.concat(base_dir.map{|dir|
1131
[dir + '/tk' + ver, dir + '/tk' + ver.delete('.')]
1134
have_tk_h = find_header('tk.h', *paths)
1347
if TclConfig_Info['MKMF_PARAMS']
1348
# already checked existence of tcl headers based on tclConfig.sh
1351
print "\nSearch tcl.h"
1352
if enable_config("tcl-h-ver-check", true) &&
1353
tclver && tclver =~ /^\D*(\d)\.?(\d)/
1354
major = $1; minor = $2
1358
print(".") # progress
1360
# version check on tcl.h
1361
have_tcl_h = try_cpp("#include <tcl.h>\n#if TCL_MAJOR_VERSION != #{major} || TCL_MINOR_VERSION != #{minor}\n#error VERSION does not match\n#endif")
1363
have_tcl_h = have_header('tcl.h')
1366
if tclver && ! tclver.empty?
1369
versions = TkLib_Config['search_versions']
1371
paths = base_dir.dup
1372
(versions + [""]).each{|ver|
1373
paths.concat(base_dir.map{|dir|
1376
dir + '/tcl' + ver + '/include',
1377
dir + '/tcl' + ver.delete('.'),
1378
dir + '/tcl' + ver.delete('.') + '/include'
1382
paths = paths.map{|dir|
1383
(File.directory?(dir))? File.expand_path(dir): nil
1386
code = "#include <tcl.h>\n"
1387
code << "#if TCL_MAJOR_VERSION != #{major}\n#error MAJOR_VERSION does not match\n#endif\n" if major
1388
code << "#if TCL_MINOR_VERSION != #{minor}\n#error MINOR_VERSION does not match\n#endif\n" if minor
1389
have_tcl_h = paths.find{|path|
1390
print(".") # progress
1391
inc_opt = " -I#{path.quote}"
1392
if try_cpp(code, inc_opt)
1393
($INCFLAGS ||= "") << inc_opt
1403
if TkConfig_Info['MKMF_PARAMS']
1404
# already checked existence of tk headers based on tkConfig.sh
1407
print "\nSearch tk.h"
1408
if enable_config("tk-h-ver-check", true) &&
1409
tkver && tkver =~ /^\D*(\d)\.?(\d)/
1410
major = $1; minor = $2
1414
print(".") # progress
1416
# version check on tk.h
1417
have_tk_h = try_cpp("#include <tk.h>\n#if TK_MAJOR_VERSION != #{major} || TK_MINOR_VERSION != #{minor}\n#error VERSION does not match\n#endif")
1419
have_tk_h = have_header('tk.h')
1422
if tkver && ! tkver.empty?
1425
versions = TkLib_Config['search_versions']
1427
paths = base_dir.dup
1428
(versions + [""]).each{|ver|
1429
paths.concat(base_dir.map{|dir|
1432
dir + '/tk' + ver + '/include',
1433
dir + '/tk' + ver.delete('.'),
1434
dir + '/tk' + ver.delete('.') + '/include'
1438
paths = paths.map{|dir|
1439
(File.directory?(dir))? File.expand_path(dir): nil
1442
code = "#include <tcl.h>\n#include <tk.h>\n"
1443
code << "#if TK_MAJOR_VERSION != #{major}\n#error MAJOR_VERSION does not match\n#endif\n" if major
1444
code << "#if TK_MINOR_VERSION != #{minor}\n#error MINOR_VERSION does not match\n#endif\n" if minor
1445
have_tk_h = paths.find{|path|
1446
print(".") # progress
1447
inc_opt = " -I#{path.quote}"
1448
if try_cpp(code, inc_opt)
1449
($INCFLAGS ||= "") << inc_opt
1458
puts "Can't find \"tcl.h\"." unless have_tcl_h
1459
puts "Can't find \"tk.h\"." unless have_tk_h
1137
1460
have_tcl_h && have_tk_h
1140
1463
def setup_for_macosx_framework(tclver, tkver)
1141
1464
# use framework, but no tclConfig.sh
1142
unless $LDFLAGS.include?('-framework')
1143
$LDFLAGS << ' -framework Tk -framework Tcl'
1465
unless $LDFLAGS && $LDFLAGS.include?('-framework')
1466
($LDFLAGS ||= "") << ' -framework Tk -framework Tcl'
1146
1469
if TkLib_Config["tcl-framework-header"]
1147
TclConfig_Info['TCL_INCLUDE_SPEC'] <<
1148
"-I#{TkLib_Config["tcl-framework-header"].quote} "
1470
TclConfig_Info['TCL_INCLUDE_SPEC'][0,0] =
1471
" -I#{TkLib_Config["tcl-framework-header"].quote} "
1150
TclConfig_Info['TCL_INCLUDE_SPEC'] = ""
1152
1473
tcl_base = File.join(TkLib_Config["tcltk-framework"], 'Tcl.framework')
1154
1475
TclConfig_Info['TCL_INCLUDE_SPEC'] <<
1155
"-I#{File.join(tcl_base, 'Versions', tclver, 'Headers').quote} "
1476
" -I#{File.join(tcl_base, 'Versions', tclver, 'Headers').quote} "
1158
1479
TclConfig_Info['TCL_INCLUDE_SPEC'] << File.join(tcl_base, 'Headers')
1161
dir = Dir.glob(File.join(tcl_base, 'Versions', '*', 'Headers'),
1482
dir = Dir.glob(File.join(tcl_base, 'Versions', '*', 'Headers'),
1162
1483
File::FNM_CASEFOLD).sort.reverse[0]
1163
1484
TclConfig_Info['TCL_INCLUDE_SPEC'] << "-I#{dir.quote} " if dir
1167
1488
if TkLib_Config["tk-framework-header"]
1168
TkConfig_Info['TK_INCLUDE_SPEC'] =
1169
"-I#{TkLib_Config["tk-framework-header"].quote} "
1489
TkConfig_Info['TK_INCLUDE_SPEC'][0,0] =
1490
" -I#{TkLib_Config["tk-framework-header"].quote} "
1171
TkConfig_Info['TK_INCLUDE_SPEC'] = ""
1173
1492
tk_base = File.join(TkLib_Config["tcltk-framework"], 'Tk.framework')
1175
1494
TkConfig_Info['TK_INCLUDE_SPEC'] <<
1176
"-I#{File.join(tk_base, 'Versions', tkver, 'Headers').quote} "
1495
" -I#{File.join(tk_base, 'Versions', tkver, 'Headers').quote} "
1179
1498
TkConfig_Info['TK_INCLUDE_SPEC'] << File.join(tk_base, 'Headers')
1182
dir = Dir.glob(File.join(tk_base, 'Versions', '*', 'Headers'),
1501
dir = Dir.glob(File.join(tk_base, 'Versions', '*', 'Headers'),
1183
1502
File::FNM_CASEFOLD).sort.reverse[0]
1184
1503
TkConfig_Info['TK_INCLUDE_SPEC'] << "-I#{dir.quote} " if dir
1431
1761
have_library("m", "log", "math.h")
1432
1762
print("\n") # progress
1434
1765
$CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
1436
1767
# Does ruby have nativethread ?
1437
TkLib_Config["ruby_with_thread"] =
1768
TkLib_Config["ruby_with_thread"] =
1438
1769
macro_defined?('HAVE_NATIVETHREAD', '#include "ruby.h"')
1441
1772
#---------------------------------------------------
1776
# use Tcl/Tk build dir? (has highest priority)
1777
TkLib_Config["tcl-build-dir"] = with_config("tcl-build-dir")
1778
TkLib_Config["tk-build-dir"] = with_config("tk-build-dir")
1779
if TkLib_Config["tcl-build-dir"]
1780
puts("use Tcl build (pre-install) dir \"#{TkLib_Config["tcl-build-dir"]}\"")
1781
TkLib_Config["tcl-build-dir"] = File.expand_path(TkLib_Config["tcl-build-dir"])
1782
base = File.dirname(TkLib_Config["tcl-build-dir"])
1783
($INCFLAGS ||= "") << " -I#{File.join(base, "generic").quote} -I#{TkLib_Config["tcl-build-dir"].quote}"
1784
$LIBPATH ||= []; $LIBPATH |= [TkLib_Config["tcl-build-dir"]]
1786
if TkLib_Config["tk-build-dir"]
1787
puts("use Tk build (pre-install) dir \"#{TkLib_Config["tk-build-dir"]}\"")
1788
TkLib_Config["tk-build-dir"] = File.expand_path(TkLib_Config["tk-build-dir"])
1789
base = File.dirname(TkLib_Config["tk-build-dir"])
1790
($INCFLAGS ||= "") << " -I#{File.join(base, "generic").quote} -I#{TkLib_Config["tk-build-dir"].quote}"
1791
$LIBPATH ||= []; $LIBPATH |= [TkLib_Config["tk-build-dir"]]
1442
1794
# check requirement of Tcl/tk version
1443
1795
tcltk_version = with_config("tcltkversion")
1445
TkLib_Config["tcltkversion"] = check_tcltk_version(tcltk_version)
1446
puts("Specified Tcl/Tk version is #{[tclver, tkver].inspect}") if tclver&&tkver
1796
TkLib_Config["tcltkversion"] = check_tcltk_version(tcltk_version)
1798
if TkLib_Config["tcl-build-dir"]
1799
if (cfgfile = with_config("tclConfig-file", Dir.glob(File.join(TkLib_Config["tcl-build-dir"], "tclConfig*.sh"), File::FNM_CASEFOLD)[0]))
1800
TclConfig_Info['config_file_path'] = cfgfile
1801
TkLib_Config["tclConfig_info"] = cfginfo = parse_tclConfig(cfgfile)
1802
if tclver = TkLib_Config["tcltkversion"][0]
1803
TkLib_Config["tcltkversion"][0].sub!(/\d(\.?)\d/, "#{cfginfo['TCL_MAJOR_VERSION']}\\1#{cfginfo['TCL_MINOR_VERSION']}")
1805
TkLib_Config["tcltkversion"][0] = "#{cfginfo['TCL_MAJOR_VERSION']}.#{cfginfo['TCL_MINOR_VERSION']}"
1809
if TkLib_Config["tk-build-dir"]
1810
if (cfgfile = with_config("tkConfig-file", Dir.glob(File.join(TkLib_Config["tk-build-dir"], "tkConfig*.sh"), File::FNM_CASEFOLD)[0]))
1811
TkConfig_Info['config_file_path'] = cfgfile
1812
TkLib_Config["tkConfig_info"] = cfginfo = parse_tclConfig(cfgfile)
1813
if TkLib_Config["tcltkversion"][1]
1814
TkLib_Config["tcltkversion"][1].sub!(/\d(\.?)\d/, "#{cfginfo['TK_MAJOR_VERSION']}\\1#{cfginfo['TK_MINOR_VERSION']}")
1816
TkLib_Config["tcltkversion"][1] = "#{cfginfo['TK_MAJOR_VERSION']}.#{cfginfo['TK_MINOR_VERSION']}"
1821
tclver, tkver = TkLib_Config["tcltkversion"]
1822
puts("Specified Tcl/Tk version is #{[tclver, tkver].inspect}") if tclver||tkver
1448
1824
# use ActiveTcl ?
1449
1825
#if activeTcl = with_config("ActiveTcl")
1450
if activeTcl = with_config("ActiveTcl", true)
1826
#if activeTcl = with_config("ActiveTcl", true)
1827
if activeTcl = with_config("ActiveTcl", !(TkLib_Config["tcl-build-dir"] && TkLib_Config["tk-build-dir"]))
1451
1828
puts("Use ActiveTcl libraries (if available).")
1452
1829
unless activeTcl.kind_of? String
1453
1830
# set default ActiveTcl path
1486
1863
stubs = enable_config("tcltk-stubs") || with_config("tcltk-stubs")
1487
1864
if (TkLib_Config["tcltk-stubs"] = stubs)
1488
1865
puts("Compile with Tcl/Tk stubs.")
1489
$CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS'
1866
$CPPFLAGS ||= ""; $CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS'
1492
1869
# directory configuration of Tcl/Tk libraries
1493
tk_idir, tk_ldir = dir_config("tk")
1494
tcl_idir, tcl_ldir = dir_config("tcl")
1870
if TkLib_Config["tcl-build-dir"]
1871
tcl_idir = File.join(File.dirname(TkLib_Config["tcl-build-dir"]),"generic")
1872
tcl_ldir = TkLib_Config["tcl-build-dir"]
1874
tcl_idir, tcl_ldir = dir_config("tcl")
1876
if TkLib_Config["tk-build-dir"]
1877
tk_idir = File.join(File.dirname(TkLib_Config["tk-build-dir"]),"generic")
1878
tk_ldir = TkLib_Config["tk-build-dir"]
1880
tk_idir, tk_ldir = dir_config("tk")
1496
1883
tcl_idir = tk_idir unless tcl_idir
1497
1884
tcl_ldir = tk_ldir unless tcl_ldir
1498
1885
tk_idir = tcl_idir unless tk_idir
1499
1886
tk_ldir = tcl_ldir unless tk_ldir
1888
TclConfig_Info['TCL_INCLUDE_SPEC'] ||= ""
1889
TkConfig_Info['TK_INCLUDE_SPEC'] ||= ""
1890
TclConfig_Info['TCL_INCLUDE_SPEC'][0,0] = "-I#{tcl_idir.quote} " if tcl_idir
1891
TkConfig_Info['TK_INCLUDE_SPEC'][0,0] = "-I#{tk_idir.quote} " if tk_idir
1501
1893
# get tclConfig.sh/tkConfig.sh
1502
TkLib_Config["tcltk-NG-path"] = []
1503
tclcfg, tkcfg = get_tclConfig(with_config("tclConfig-file", true),
1504
with_config("tkConfig-file", true),
1505
with_config("tclConfig-dir", tcl_ldir || true),
1506
with_config("tkConfig-dir", tk_ldir || true))
1507
TclConfig_Info = TkLib_Config["tclConfig_info"] || {}
1508
TkConfig_Info = TkLib_Config["tkConfig_info"] || {}
1509
TclConfig_Info['config_file_path'] = tclcfg
1510
TkConfig_Info['config_file_path'] = tkcfg
1512
TclConfig_Info['TCL_INCLUDE_SPEC'] = "-I#{tcl_idir.quote}" if tcl_idir
1513
TkConfig_Info['TK_INCLUDE_SPEC'] = "-I#{tk_idir.quote}" if tk_idir
1894
TkLib_Config["tcl-NG-path"] = []
1895
TkLib_Config["tk-NG-path"] = []
1898
TclConfig_Info['config_file_path'] || with_config("tclConfig-file", true),
1899
TkConfig_Info['config_file_path'] || with_config("tkConfig-file", true),
1900
(TclConfig_Info['config_file_path'])?
1901
File.dirname(TclConfig_Info['config_file_path']) :
1902
with_config("tclConfig-dir", tcl_ldir || true),
1903
(TkConfig_Info['config_file_path'])?
1904
File.dirname(TkConfig_Info['config_file_path']) :
1905
with_config("tkConfig-dir", tk_ldir || true)
1907
TclConfig_Info.merge!(TkLib_Config["tclConfig_info"]) if TkLib_Config["tclConfig_info"]
1908
TkConfig_Info.merge!(TkLib_Config["tkConfig_info"]) if TkLib_Config["tkConfig_info"]
1909
TclConfig_Info['config_file_path'] ||= tclcfg
1910
TkConfig_Info['config_file_path'] ||= tkcfg
1515
1912
tk_cfg_dir = File.dirname(TkConfig_Info['config_file_path']) rescue nil
1516
1913
tcl_cfg_dir = File.dirname(TclConfig_Info['config_file_path']) rescue nil
1518
tk_ldir_list = [tk_ldir, tk_cfg_dir]
1519
tcl_ldir_list = [tcl_ldir, tcl_cfg_dir]
1915
tk_ldir_list = [tk_ldir, tk_cfg_dir].uniq
1916
tcl_ldir_list = [tcl_ldir, tcl_cfg_dir].uniq
1918
if TkConfig_Info['config_file_path']
1919
if TkLib_Config["tk-build-dir"]
1920
spec_dir = get_libpath(TkConfig_Info['TK_LIB_FLAG'], TkConfig_Info['TK_BUILD_LIB_SPEC'])
1922
spec_dir = get_libpath(TkConfig_Info['TK_LIB_FLAG'], TkConfig_Info['TK_LIB_SPEC'])
1924
tk_ldir_list << spec_dir if File.directory?(spec_dir)
1926
if TclConfig_Info['config_file_path']
1927
if TkLib_Config["tcl-build-dir"]
1928
spec_dir = get_libpath(TclConfig_Info['TCL_LIB_FLAG'], TclConfig_Info['TCL_BUILD_LIB_SPEC'])
1930
spec_dir = get_libpath(TclConfig_Info['TCL_LIB_FLAG'], TclConfig_Info['TCL_LIB_SPEC'])
1932
tcl_ldir_list << spec_dir if File.directory?(spec_dir)
1521
1935
# check tk_shlib_search_path
1522
check_shlib_search_path(with_config('tk-shlib-search-path'))
1936
TkLib_Config["checked_shlib_dirs"] =
1937
check_shlib_search_path(with_config('tk-shlib-search-path'))
1524
1939
# set TCL_DEFS and TK_DEFS
1525
1941
# $CPPFLAGS += " #{TclConfig_Info['TCL_DEFS']}"
1526
1942
# $CPPFLAGS += " #{TkConfig_Info['TK_DEFS']}"
1527
$CPPFLAGS += collect_tcltk_defs(TclConfig_Info['TCL_DEFS'], TkConfig_Info['TK_DEFS'])
1943
$defs += collect_tcltk_defs(TclConfig_Info['TCL_DEFS'], TkConfig_Info['TK_DEFS'])
1529
1945
# MacOS X Frameworks?
1530
1946
if TkLib_Config["tcltk-framework"]
1531
1947
puts("Use MacOS X Frameworks.")
1948
($LDFLAGS ||= "") << " -L#{TkLib_Config["tcl-build-dir"].quote}" if TkLib_Config["tcl-build-dir"]
1533
$INCFLAGS << ' ' << TclConfig_Info['TCL_INCLUDE_SPEC']
1951
TclConfig_Info['TCL_LIBS'] ||= ""
1952
($INCFLAGS ||= "") << ' ' << TclConfig_Info['TCL_INCLUDE_SPEC']
1534
1953
$LDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
1536
$LDFLAGS << ' ' << TclConfig_Info['TCL_STUB_LIB_SPEC']
1955
if TkLib_Config["tcl-build-dir"] &&
1956
TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC'] &&
1957
!TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC'].strip.empty?
1958
$LDFLAGS << ' ' << TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC']
1960
$LDFLAGS << ' ' << TclConfig_Info['TCL_STUB_LIB_SPEC']
1538
$LDFLAGS << ' ' << TclConfig_Info['TCL_LIB_SPEC']
1963
if TkLib_Config["tcl-build-dir"] &&
1964
TclConfig_Info['TCL_BUILD_LIB_SPEC'] &&
1965
!TclConfig_Info['TCL_BUILD_LIB_SPEC'].strip.empty?
1966
$LDFLAGS << ' ' << TclConfig_Info['TCL_BUILD_LIB_SPEC']
1968
$LDFLAGS << ' ' << TclConfig_Info['TCL_LIB_SPEC']
1973
$LDFLAGS << " -L#{TkLib_Config["tk-build-dir"].quote}" if TkLib_Config["tk-build-dir"]
1542
$INCFLAGS << ' ' << TkConfig_Info['TK_INCLUDE_SPEC']
1976
TkConfig_Info['TK_LIBS'] ||= ""
1977
($INCFLAGS ||= "") << ' ' << TkConfig_Info['TK_INCLUDE_SPEC']
1543
1978
$LDFLAGS << ' ' << TkConfig_Info['TK_LIBS']
1545
$LDFLAGS << ' ' << TkConfig_Info['TK_STUB_LIB_SPEC']
1980
if TkLib_Config["tk-build-dir"] &&
1981
TclConfig_Info['TK_BUILD_STUB_LIB_SPEC'] &&
1982
!TclConfig_Info['TK_BUILD_STUB_LIB_SPEC'].strip.empty?
1983
$LDFLAGS << ' ' << TkConfig_Info['TK_BUILD_STUB_LIB_SPEC']
1985
$LDFLAGS << ' ' << TkConfig_Info['TK_STUB_LIB_SPEC']
1547
$LDFLAGS << ' ' << TkConfig_Info['TK_LIB_SPEC']
1988
if TkLib_Config["tk-build-dir"] &&
1989
TclConfig_Info['TK_BUILD_LIB_SPEC'] &&
1990
!TclConfig_Info['TK_BUILD_LIB_SPEC'].strip.empty?
1991
$LDFLAGS << ' ' << TkConfig_Info['TK_BUILD_LIB_SPEC']
1993
$LDFLAGS << ' ' << TkConfig_Info['TK_LIB_SPEC']
1550
1997
setup_for_macosx_framework(tclver, tkver) if tcl_cfg_dir && tk_cfg_dir