summaryrefslogtreecommitdiff
path: root/ext/tcltklib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-07-28 09:26:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-07-28 09:26:53 +0000
commit16adedaa6d6ceb8e3f21e33dc6653aed3ffa6932 (patch)
treed1c104d8b5e197b22830a2c37f84327de76586b3 /ext/tcltklib
parent7dcd244615f172994ca4af37108af7ff744d0998 (diff)
990728
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tcltklib')
-rw-r--r--ext/tcltklib/extconf.rb96
1 files changed, 29 insertions, 67 deletions
diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb
index 7a568edd103..ec06f8b2453 100644
--- a/ext/tcltklib/extconf.rb
+++ b/ext/tcltklib/extconf.rb
@@ -7,79 +7,41 @@ have_library("socket", "socket")
have_library("dl", "dlopen")
have_library("m", "log")
-$includes = []
-def search_header(include, *path)
- pwd = Dir.getwd
- begin
- for i in path.sort!.reverse!
- dir = Dir[i]
- for path in dir.sort!.reverse!
- next unless File.directory? path
- Dir.chdir path
- files = Dir[include]
- if files.size > 0
- unless $includes.include? path
- $includes << path
- end
- return
- end
- end
- end
- ensure
- Dir.chdir pwd
- end
-end
+dir_config("tk")
+dir_config("tcl")
+dir_config("X11")
-search_header("tcl.h",
- "/usr/include/tcl{,8*,7*}",
- "/usr/include",
- "/usr/local/include/tcl{,8*,7*}",
- "/usr/local/include")
-search_header("tk.h",
- "/usr/include/tk{,8*,4*}",
- "/usr/include",
- "/usr/local/include/tk{,8*,4*}",
- "/usr/local/include")
-search_header("X11/Xlib.h",
- "/usr/include/X11*",
- "/usr/include",
- "/usr/openwin/include",
- "/usr/X11*/include")
+tklib = with_config("tklib")
+tcllib = with_config("tcllib")
-$CFLAGS = $includes.collect{|path| "-I" + path}.join(" ")
+def find_tcl(tcllib)
+ paths = ["/usr/local/lib", "/usr/pkg"]
+ func = "Tcl_FindExecutable"
+ if tcllib
+ find_library(tcllib, func, *paths)
+ else
+ find_library("tcl", func, *paths) or
+ find_library("tcl8.0", func, *paths) or
+ find_library("tcl7.6", func, *paths)
+ end
+end
-$libraries = []
-def search_lib(file, func, *path)
- for i in path.reverse!
- dir = Dir[i]
- for path in dir.sort!.reverse!
- $LDFLAGS = $libraries.collect{|p| "-L" + p}.join(" ") + " -L" + path
- files = Dir[path+"/"+file]
- if files.size > 0
- for lib in files.sort!.reverse!
- lib = File::basename(lib)
- lib.sub!(/^lib/, '')
- lib.sub!(/\.(a|so(.[0-9.]+)?)$/, '')
- if have_library(lib, func)
- unless $libraries.include? path
- $libraries << path
- end
- return true
- end
- end
- end
- end
+def find_tk(tklib)
+ paths = ["/usr/local/lib", "/usr/pkg"]
+ func = "Tk_Init"
+ if tklib
+ find_library(tklib, func, *paths)
+ else
+ find_library("tk", func, *paths) or
+ find_library("tk8.0", func, *paths) or
+ find_library("tk4.2", func, *paths)
end
- return false;
end
if have_header("tcl.h") && have_header("tk.h") &&
- search_lib("libX11.{so*,a}", "XOpenDisplay",
- "/usr/lib", "/usr/openwin/lib", "/usr/X11*/lib") &&
- search_lib("libtcl{8*,7*,}.{so,a}", "Tcl_FindExecutable",
- "/usr/lib", "/usr/local/lib") &&
- search_lib("libtk{8*,4*,}.{so,a}", "Tk_Init",
- "/usr/lib", "/usr/local/lib")
- $LDFLAGS = $libraries.collect{|path| "-L" + path}.join(" ")
+ find_library("X11", "XOpenDisplay",
+ "/usr/X11/lib", "/usr/X11R6/lib", "/usr/openwin/lib") &&
+ find_tcl(tcllib) &&
+ find_tk(tklib)
create_makefile("tcltklib")
end