summaryrefslogtreecommitdiff
path: root/ext/tcltklib/extconf.rb
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-01-16 12:19:22 +0000
commitf12baed5df6d3c213dd75d2f0d9f36bb179fb843 (patch)
treec39f9c14cd6f8bcf85b6b842a2774cafb102bc2e /ext/tcltklib/extconf.rb
parent22ab6d39643b1bbc997e15b763d2b12996b1f1b9 (diff)
This commit was manufactured by cvs2svn to create branch 'RUBY'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/RUBY@9 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tcltklib/extconf.rb')
-rw-r--r--ext/tcltklib/extconf.rb79
1 files changed, 79 insertions, 0 deletions
diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb
new file mode 100644
index 00000000000..26e7fe7b092
--- /dev/null
+++ b/ext/tcltklib/extconf.rb
@@ -0,0 +1,79 @@
+# extconf.rb for tcltklib
+
+have_library("socket", "socket")
+have_library("nsl", "gethostbyname")
+
+def search_file(var, include, *path)
+ pwd = Dir.getwd
+ begin
+ for i in path.reverse!
+ dir = Dir[i]
+ for path in dir
+ Dir.chdir path
+ files = Dir[include]
+ if files.size > 0
+ var << path
+ return files.pop
+ end
+ end
+ end
+ ensure
+ Dir.chdir pwd
+ end
+end
+
+$includes = []
+search_file($includes,
+ "tcl.h",
+ "/usr/include/tcl*",
+ "/usr/include",
+ "/usr/local/include/tcl*",
+ "/usr/local/include")
+search_file($includes,
+ "tk.h",
+ "/usr/include/tk*",
+ "/usr/include",
+ "/usr/local/include/tk*",
+ "/usr/local/include")
+search_file($includes,
+ "X11/Xlib.h",
+ "/usr/include",
+ "/usr/X11*/include",
+ "/usr/include",
+ "/usr/X11*/include")
+
+$CFLAGS = "-Wall " + $includes.collect{|path| "-I" + path}.join(" ")
+
+$libraries = []
+tcllibfile = search_file($libraries,
+ "libtcl{,7*,8*}.{a,so}",
+ "/usr/lib",
+ "/usr/local/lib")
+if tcllibfile
+ tcllibfile.sub!(/^lib/, '')
+ tcllibfile.sub!(/\.(a|so)$/, '')
+end
+tklibfile = search_file($libraries,
+ "libtk{,4*,8*}.{a,so}",
+ "/usr/lib",
+ "/usr/local/lib")
+if tklibfile
+ tklibfile.sub!(/^lib/, '')
+ tklibfile.sub!(/\.(a|so)$/, '')
+end
+search_file($libraries,
+ "libX11.{a,so}",
+ "/usr/lib",
+ "/usr/X11*/lib")
+
+$LDFLAGS = $libraries.collect{|path| "-L" + path}.join(" ")
+
+have_library("dl", "dlopen")
+if have_header("tcl.h") &&
+ have_header("tk.h") &&
+ have_library("X11", "XOpenDisplay") &&
+ have_library("m", "log") &&
+ have_library(tcllibfile, "Tcl_FindExecutable") &&
+ have_library(tklibfile, "Tk_Init")
+ create_makefile("tcltklib")
+end