[前][次][番号順一覧][スレッド一覧]

ruby-changes:19847

From: nagai <ko1@a...>
Date: Thu, 2 Jun 2011 00:46:38 +0900 (JST)
Subject: [ruby-changes:19847] nagai:r31894 (trunk): * ext/tk/extconf.rb: fix for uninitialized global variables. [Ruby 1.9 - Bug #4811]

nagai	2011-06-02 00:46:31 +0900 (Thu, 02 Jun 2011)

  New Revision: 31894

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31894

  Log:
    * ext/tk/extconf.rb: fix for uninitialized global variables. [Ruby 1.9 - Bug #4811]

  Modified files:
    trunk/ChangeLog
    trunk/ext/tk/extconf.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31893)
+++ ChangeLog	(revision 31894)
@@ -1,3 +1,8 @@
+Thu Jun  2 00:45:26 2011  Hidetoshi NAGAI  <nagai@a...>
+
+	* ext/tk/extconf.rb: fix for uninitialized global variables.
+	  [Ruby 1.9 - Bug #4811]
+
 Wed Jun  1 21:57:08 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread_pthread.c (native_sleep): fix 1000times calculation error.
Index: ext/tk/extconf.rb
===================================================================
--- ext/tk/extconf.rb	(revision 31893)
+++ ext/tk/extconf.rb	(revision 31894)
@@ -25,7 +25,7 @@
 ##############################################################
 # 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 @@
     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 @@
     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 @@
 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 @@
     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 @@
 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 @@
     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 @@
     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 @@
     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 @@
         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 @@
         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 @@
 
 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 @@
 
   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 @@
 
   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 @@
       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 @@
 
   # check pthread mode
   if (TkLib_Config["ruby_with_thread"])
+    $CPPFLAGS ||= ""
+
     # ruby -> enable
     unless tcl_enable_thread
       # ruby -> enable && tcl -> disable
@@ -1760,6 +1765,7 @@
   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 @@
   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 @@
 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 @@
   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 @@
 # 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 @@
   $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 @@
   $INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
 
   # create
+  $CPPFLAGS ||= ""
   $CPPFLAGS << %[ -DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
   $CPPFLAGS << %[ -DRUBY_RELEASE_DATE=\\"#{RUBY_RELEASE_DATE}\\"]
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]