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