090be3
diff --git a/ext/tk/extconf.rb b/ext/tk/extconf.rb
090be3
index 709e4d2..fa1bc80 100644
090be3
--- a/ext/tk/extconf.rb
090be3
+++ b/ext/tk/extconf.rb
090be3
@@ -623,7 +623,7 @@ def libcheck_for_tclConfig(tcldir, tkdir, tclconf, tkconf)
090be3
           $INCFLAGS << " -I" << File.join(File.dirname(File.dirname(file)),"include") if is_win32?
090be3
         else
090be3
           tcllibs = append_library($libs, libname)
090be3
-          tcllibs = "-L#{tcldir.quote} -Wl,-R#{tcldir.quote} " + tcllibs
090be3
+          tcllibs = "#{libpathflag(tcldir)} #{tcllibs}"
090be3
 
090be3
           # FIX ME: avoid pathname trouble (fail to find) on MinGW.
090be3
           $INCFLAGS << " -I" << File.join(File.dirname(tcldir),"include") if is_win32?
090be3
@@ -665,7 +665,7 @@ def libcheck_for_tclConfig(tcldir, tkdir, tclconf, tkconf)
090be3
         else
090be3
           tklibs = append_library("", libname)
090be3
           #tklibs = append_library("", $1)
090be3
-          tklibs = "-L#{tkdir.quote} -Wl,-R#{tkdir.quote} " + tklibs
090be3
+          tklibs = "#{libpathflag(tkdir)} #{tklibs}"
090be3
 
090be3
           # FIX ME: avoid pathname trouble (fail to find) on MinGW.
090be3
           $INCFLAGS << " -I" << File.join(File.dirname(tcldir),"include") if is_win32?
090be3
@@ -1161,7 +1161,7 @@ def find_tcl(tcllib, stubs, version, *opt_paths)
090be3
                   tcllibs = libs_param + " -DSTATIC_BUILD " + fname.quote
090be3
                 else
090be3
                   tcllibs = append_library($libs, lib_w_sufx)
090be3
-                  tcllibs = "-L#{path.quote} -Wl,-R#{path.quote} " + tcllibs
090be3
+                  tcllibs = "#{libpathflag(path)} #{tcllibs}"
090be3
                 end
090be3
                 if try_func(func, tcllibs, ["tcl.h"])
090be3
                   return [true, path, nil, tcllibs, *inc]
090be3
@@ -1300,7 +1300,7 @@ def find_tk(tklib, stubs, version, *opt_paths)
090be3
                   tklibs = libs_param + " -DSTATIC_BUILD " + fname.quote
090be3
                 else
090be3
                   tklibs = append_library($libs, lib_w_sufx)
090be3
-                  tklibs = "-L#{path.quote} -Wl,-R#{path.quote} " + tklibs
090be3
+                  tklibs = "#{libpathflag(path)} #{tklibs}"
090be3
                 end
090be3
                 if try_func(func, tklibs, ["tcl.h", "tk.h"])
090be3
                   return [true, path, nil, tklibs, *inc]
090be3
@@ -2013,7 +2013,7 @@ $defs += collect_tcltk_defs(TclConfig_Info['TCL_DEFS'], TkConfig_Info['TK_DEFS']
090be3
 # MacOS X Frameworks?
090be3
 if TkLib_Config["tcltk-framework"]
090be3
   puts("Use MacOS X Frameworks.")
090be3
-  ($LDFLAGS ||= "") << " -L#{TkLib_Config["tcl-build-dir"].quote} -Wl,-R#{TkLib_Config["tcl-build-dir"].quote}" if TkLib_Config["tcl-build-dir"]
090be3
+  ($LDFLAGS ||= "") << " " << libpathflag(TkLib_Config["tcl-build-dir"]) if TkLib_Config["tcl-build-dir"]
090be3
 
090be3
   libs = ''
090be3
   if tcl_cfg_dir
090be3
@@ -2039,7 +2039,7 @@ if TkLib_Config["tcltk-framework"]
090be3
     end
090be3
   end
090be3
 
090be3
-  libs << " -L#{TkLib_Config["tk-build-dir"].quote} -Wl,-R#{TkLib_Config["tk-build-dir"].quote}" if TkLib_Config["tk-build-dir"]
090be3
+  libs << " " << libpathflag(TkLib_Config["tk-build-dir"]) if TkLib_Config["tk-build-dir"]
090be3
 
090be3
   if tk_cfg_dir
090be3
     TkConfig_Info['TK_LIBS'] ||= ""
090be3
-- 
090be3
1.8.5.2
090be3