summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 15:46:31 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-01 15:46:31 +0000
commiteeccb5935b3b60732e5ee0c02e54ac55dc7f53cb (patch)
tree36a8d042c905af3029c5125010c6cb4fcaa9c386 /ext
parent859da834551657478bec39e55058e987780fcc54 (diff)
* ext/tk/extconf.rb: fix for uninitialized global variables. [Ruby 1.9 - Bug #4811]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/tk/extconf.rb86
1 files changed, 47 insertions, 39 deletions
diff --git a/ext/tk/extconf.rb b/ext/tk/extconf.rb
index 4442c13c8e..ed150ef356 100644
--- a/ext/tk/extconf.rb
+++ b/ext/tk/extconf.rb
@@ -25,7 +25,7 @@ end
##############################################################
# check configs
##############################################################
-$cleanfiles << 'config_list'
+($cleanfiles ||= "") << 'config_list'
config_list_file = 'config_list'
config_list_file_source = File.join(File.dirname(__FILE__),'config_list.in')
if !File.exist?(config_list_file) ||
@@ -569,9 +569,9 @@ def libcheck_for_tclConfig(tcldir, tkdir, tclconf, tkconf)
tkfunc = "Tk_Init"
end
- incflags = $INCFLAGS.dup
- libpath = $LIBPATH.dup
- libs_param = $libs.dup
+ incflags = ($INCFLAGS ||= "").dup
+ libpath = ($LIBPATH ||= []).dup
+ libs_param = ($libs ||= "").dup
tcllibs = nil
mkmf_param = nil
@@ -922,6 +922,7 @@ def get_tclConfig(tclConfig_file, tkConfig_file, tclConfig_dir, tkConfig_dir)
dirs |= dirs
puts("Valid [tclConfig.sh, tkConfig.sh] are found in #{dirs.inspect}")
puts("Use [tclConfig.sh, tkConfig.sh] == #{[tclConfig, tkConfig].inspect}")
+ $LIBPATH ||= []
$LIBPATH |= [File.dirname(tclConfig)] if tclConfig
$LIBPATH |= [File.dirname(tkConfig)] if tkConfig
#TkLib_Config["tclConfig_paths"].each{|tclcfg, tkcfg|
@@ -1020,9 +1021,9 @@ end
def find_tcl(tcllib, stubs, version, *opt_paths)
if TclConfig_Info['MKMF_PARAMS']
# already checked existence of tcl library based on tclConfig.sh
- $INCFLAGS << " " << TclConfig_Info['MKMF_PARAMS']['INCFLAGS']
- $LIBPATH |= TclConfig_Info['MKMF_PARAMS']['LIBPATH']
- $libs << " " << TclConfig_Info['MKMF_PARAMS']['libs']
+ ($INCFLAGS ||= "") << " " << TclConfig_Info['MKMF_PARAMS']['INCFLAGS']
+ $LIBPATH ||= []; $LIBPATH |= TclConfig_Info['MKMF_PARAMS']['LIBPATH']
+ ($libs ||= "") << " " << TclConfig_Info['MKMF_PARAMS']['libs']
return [true, nil, nil, nil]
end
# else, no available tclConfig.sh on the system
@@ -1081,9 +1082,9 @@ def find_tcl(tcllib, stubs, version, *opt_paths)
paths = check_tcl_NG_path(default_paths)
end
- incflags = $INCFLAGS.dup
- libpath = $LIBPATH.dup
- libs_param = $libs.dup
+ incflags = ($INCFLAGS ||= "").dup
+ libpath = ($LIBPATH ||= []).dup
+ libs_param = ($libs ||= "").dup
tcllibs = nil
exts = "(" + get_ext_list.join('|') + ")"
@@ -1164,9 +1165,9 @@ end
def find_tk(tklib, stubs, version, *opt_paths)
if TkConfig_Info['MKMF_PARAMS']
# already checked existence of tcl library based on tkConfig.sh
- $INCFLAGS << " " << TkConfig_Info['MKMF_PARAMS']['INCFLAGS']
- $LIBPATH |= TkConfig_Info['MKMF_PARAMS']['LIBPATH']
- $libs << " " << TkConfig_Info['MKMF_PARAMS']['libs']
+ ($INCFLAGS ||= "") << " " << TkConfig_Info['MKMF_PARAMS']['INCFLAGS']
+ $LIBPATH ||= []; $LIBPATH |= TkConfig_Info['MKMF_PARAMS']['LIBPATH']
+ ($libs ||= "") << " " << TkConfig_Info['MKMF_PARAMS']['libs']
return [true, nil, nil, nil]
end
# else, no available tkConfig.sh on the system
@@ -1221,9 +1222,9 @@ def find_tk(tklib, stubs, version, *opt_paths)
paths = check_tk_NG_path(default_paths)
end
- incflags = $INCFLAGS.dup
- libpath = $LIBPATH.dup
- libs_param = $libs.dup
+ incflags = ($INCFLAGS ||= "").dup
+ libpath = ($LIBPATH ||= []).dup
+ libs_param = ($libs ||= "").dup
tcllibs = nil
exts = "(" + get_ext_list.join('|') + ")"
@@ -1292,9 +1293,10 @@ def find_tcltk_library(tcllib, tklib, stubs, tclversion, tkversion,
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.")
return false
else
- $LIBPATH |= [path] if path
+ ($LIBPATH ||= []; $LIBPATH |= [path]) if path
$libs = append_library($libs, lib) if lib
- $libs << " " << libs if libs
+ ($libs ||= "") << " " << libs if libs
+ $INCFLAGS ||= ""
inc.each{|f| $INCFLAGS << " -I" << f}
end
@@ -1303,9 +1305,10 @@ def find_tcltk_library(tcllib, tklib, stubs, tclversion, tkversion,
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.")
return false
else
- $LIBPATH |= [path] if path
+ ($LIBPATH ||= []; $LIBPATH |= [path]) if path
$libs = append_library($libs, lib) if lib && !lib.empty?
- $libs << " " << libs if libs
+ ($libs ||= "") << " " << libs if libs
+ $INCFLAGS ||= ""
inc.each{|f| $INCFLAGS << " -I" << f}
end
@@ -1387,7 +1390,7 @@ def find_tcltk_header(tclver, tkver)
print(".") # progress
inc_opt = " -I#{path.quote}"
if try_cpp(code, inc_opt)
- $INCFLAGS << inc_opt
+ ($INCFLAGS ||= "") << inc_opt
true
else
false
@@ -1443,7 +1446,7 @@ def find_tcltk_header(tclver, tkver)
print(".") # progress
inc_opt = " -I#{path.quote}"
if try_cpp(code, inc_opt)
- $INCFLAGS << inc_opt
+ ($INCFLAGS ||= "") << inc_opt
true
else
false
@@ -1459,20 +1462,20 @@ end
def setup_for_macosx_framework(tclver, tkver)
# use framework, but no tclConfig.sh
- unless $LDFLAGS.include?('-framework')
- $LDFLAGS << ' -framework Tk -framework Tcl'
+ unless $LDFLAGS && $LDFLAGS.include?('-framework')
+ ($LDFLAGS ||= "") << ' -framework Tk -framework Tcl'
end
if TkLib_Config["tcl-framework-header"]
- TclConfig_Info['TCL_INCLUDE_SPEC'] <<
- "-I#{TkLib_Config["tcl-framework-header"].quote} "
+ (TclConfig_Info['TCL_INCLUDE_SPEC'] ||= "") <<
+ " -I#{TkLib_Config["tcl-framework-header"].quote} "
else
TclConfig_Info['TCL_INCLUDE_SPEC'] = ""
tcl_base = File.join(TkLib_Config["tcltk-framework"], 'Tcl.framework')
if tclver
TclConfig_Info['TCL_INCLUDE_SPEC'] <<
- "-I#{File.join(tcl_base, 'Versions', tclver, 'Headers').quote} "
+ " -I#{File.join(tcl_base, 'Versions', tclver, 'Headers').quote} "
end
TclConfig_Info['TCL_INCLUDE_SPEC'] << File.join(tcl_base, 'Headers')
@@ -1486,14 +1489,14 @@ def setup_for_macosx_framework(tclver, tkver)
if TkLib_Config["tk-framework-header"]
TkConfig_Info['TK_INCLUDE_SPEC'] =
- "-I#{TkLib_Config["tk-framework-header"].quote} "
+ " -I#{TkLib_Config["tk-framework-header"].quote} "
else
TkConfig_Info['TK_INCLUDE_SPEC'] = ""
tk_base = File.join(TkLib_Config["tcltk-framework"], 'Tk.framework')
if tkver
TkConfig_Info['TK_INCLUDE_SPEC'] <<
- "-I#{File.join(tk_base, 'Versions', tkver, 'Headers').quote} "
+ " -I#{File.join(tk_base, 'Versions', tkver, 'Headers').quote} "
end
TkConfig_Info['TK_INCLUDE_SPEC'] << File.join(tk_base, 'Headers')
@@ -1540,7 +1543,7 @@ def search_X_libraries
if TkConfig_Info['TK_XINCLUDES'] &&
!TkConfig_Info['TK_XINCLUDES'].strip.empty?
- $INCFLAGS << " " << TkConfig_Info['TK_XINCLUDES'].strip
+ ($INCFLAGS ||= "") << " " << TkConfig_Info['TK_XINCLUDES'].strip
end
if use_X
@@ -1552,7 +1555,7 @@ def search_X_libraries
if use_tkConfig &&
TkConfig_Info['TK_XLIBSW'] && !TkConfig_Info['TK_XLIBSW'].strip.empty?
puts("But, try to use TK_XLIBSW information (believe tkCOnfig.sh).")
- $libs << " " << TkConfig_Info['TK_XLIBSW'] << " "
+ ($libs ||= "") << " " << TkConfig_Info['TK_XLIBSW'] << " "
else
puts("So, can't make tcltklib.so which is required by Ruby/Tk.")
exit
@@ -1654,6 +1657,8 @@ EOF
# check pthread mode
if (TkLib_Config["ruby_with_thread"])
+ $CPPFLAGS ||= ""
+
# ruby -> enable
unless tcl_enable_thread
# ruby -> enable && tcl -> disable
@@ -1760,6 +1765,7 @@ unless is_win32?
have_library("m", "log", "math.h")
print("\n") # progress
end
+$CPPFLAGS ||= ""
$CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
# Does ruby have nativethread ?
@@ -1778,15 +1784,15 @@ if TkLib_Config["tcl-build-dir"]
puts("use Tcl build (pre-install) dir \"#{TkLib_Config["tcl-build-dir"]}\"")
TkLib_Config["tcl-build-dir"] = File.expand_path(TkLib_Config["tcl-build-dir"])
base = File.dirname(TkLib_Config["tcl-build-dir"])
- $INCFLAGS << " -I#{File.join(base, "generic").quote} -I#{TkLib_Config["tcl-build-dir"].quote}"
- $LIBPATH |= [TkLib_Config["tcl-build-dir"]]
+ ($INCFLAGS ||= "") << " -I#{File.join(base, "generic").quote} -I#{TkLib_Config["tcl-build-dir"].quote}"
+ $LIBPATH ||= []; $LIBPATH |= [TkLib_Config["tcl-build-dir"]]
end
if TkLib_Config["tk-build-dir"]
puts("use Tk build (pre-install) dir \"#{TkLib_Config["tk-build-dir"]}\"")
TkLib_Config["tk-build-dir"] = File.expand_path(TkLib_Config["tk-build-dir"])
base = File.dirname(TkLib_Config["tk-build-dir"])
- $INCFLAGS << " -I#{File.join(base, "generic").quote} -I#{TkLib_Config["tk-build-dir"].quote}"
- $LIBPATH |= [TkLib_Config["tk-build-dir"]]
+ ($INCFLAGS ||= "") << " -I#{File.join(base, "generic").quote} -I#{TkLib_Config["tk-build-dir"].quote}"
+ $LIBPATH ||= []; $LIBPATH |= [TkLib_Config["tk-build-dir"]]
end
# check requirement of Tcl/tk version
@@ -1861,7 +1867,7 @@ end
stubs = enable_config("tcltk-stubs") || with_config("tcltk-stubs")
if (TkLib_Config["tcltk-stubs"] = stubs)
puts("Compile with Tcl/Tk stubs.")
- $CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS'
+ $CPPFLAGS ||= ""; $CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS'
end
# directory configuration of Tcl/Tk libraries
@@ -1933,6 +1939,7 @@ TkLib_Config["checked_shlib_dirs"] =
check_shlib_search_path(with_config('tk-shlib-search-path'))
# set TCL_DEFS and TK_DEFS
+$CPPFLAGS ||= ""
# $CPPFLAGS += " #{TclConfig_Info['TCL_DEFS']}"
# $CPPFLAGS += " #{TkConfig_Info['TK_DEFS']}"
$CPPFLAGS += collect_tcltk_defs(TclConfig_Info['TCL_DEFS'], TkConfig_Info['TK_DEFS'])
@@ -1940,10 +1947,10 @@ $CPPFLAGS += collect_tcltk_defs(TclConfig_Info['TCL_DEFS'], TkConfig_Info['TK_DE
# MacOS X Frameworks?
if TkLib_Config["tcltk-framework"]
puts("Use MacOS X Frameworks.")
- $LDFLAGS << " -L#{TkLib_Config["tcl-build-dir"].quote} -Wl,-R#{TkLib_Config["tcl-build-dir"].quote}" if TkLib_Config["tcl-build-dir"]
+ ($LDFLAGS ||= "") << " -L#{TkLib_Config["tcl-build-dir"].quote} -Wl,-R#{TkLib_Config["tcl-build-dir"].quote}" if TkLib_Config["tcl-build-dir"]
if tcl_cfg_dir
- $INCFLAGS << ' ' << TclConfig_Info['TCL_INCLUDE_SPEC']
+ ($INCFLAGS ||= "") << ' ' << TclConfig_Info['TCL_INCLUDE_SPEC']
$LDFLAGS << ' ' << TclConfig_Info['TCL_LIBS']
if stubs
if TkLib_Config["tcl-build-dir"] &&
@@ -1967,7 +1974,7 @@ if TkLib_Config["tcltk-framework"]
$LDFLAGS << " -L#{TkLib_Config["tk-build-dir"].quote} -Wl,-R#{TkLib_Config["tk-build-dir"].quote}" if TkLib_Config["tk-build-dir"]
if tk_cfg_dir
- $INCFLAGS << ' ' << TkConfig_Info['TK_INCLUDE_SPEC']
+ ($INCFLAGS ||= "") << ' ' << TkConfig_Info['TK_INCLUDE_SPEC']
$LDFLAGS << ' ' << TkConfig_Info['TK_LIBS']
if stubs
if TkLib_Config["tk-build-dir"] &&
@@ -2011,6 +2018,7 @@ if (TkLib_Config["tcltk-framework"] ||
$INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
# create
+ $CPPFLAGS ||= ""
$CPPFLAGS << %[ -DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
$CPPFLAGS << %[ -DRUBY_RELEASE_DATE=\\"#{RUBY_RELEASE_DATE}\\"]