1998-01-16 07:19:09 -05:00
|
|
|
# extconf.rb for tcltklib
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
require 'mkmf'
|
|
|
|
|
|
|
|
have_library("nsl", "t_open")
|
1998-01-16 07:19:09 -05:00
|
|
|
have_library("socket", "socket")
|
1999-01-19 23:59:39 -05:00
|
|
|
have_library("dl", "dlopen")
|
|
|
|
have_library("m", "log")
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
$includes = []
|
|
|
|
def search_header(include, *path)
|
1998-01-16 07:19:09 -05:00
|
|
|
pwd = Dir.getwd
|
|
|
|
begin
|
1999-01-19 23:59:39 -05:00
|
|
|
for i in path.sort!.reverse!
|
1998-01-16 07:19:09 -05:00
|
|
|
dir = Dir[i]
|
1999-01-19 23:59:39 -05:00
|
|
|
for path in dir.sort!.reverse!
|
|
|
|
next unless File.directory? path
|
1998-01-16 07:19:09 -05:00
|
|
|
Dir.chdir path
|
|
|
|
files = Dir[include]
|
|
|
|
if files.size > 0
|
1999-01-19 23:59:39 -05:00
|
|
|
unless $includes.include? path
|
|
|
|
$includes << path
|
|
|
|
end
|
|
|
|
return
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
ensure
|
|
|
|
Dir.chdir pwd
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
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")
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
$CFLAGS = $includes.collect{|path| "-I" + path}.join(" ")
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
|
|
$libraries = []
|
1999-01-19 23:59:39 -05:00
|
|
|
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)$/, '')
|
|
|
|
if have_library(lib, func)
|
|
|
|
unless $libraries.include? path
|
|
|
|
$libraries << path
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false;
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
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(" ")
|
1998-01-16 07:19:09 -05:00
|
|
|
create_makefile("tcltklib")
|
|
|
|
end
|