ext/tcltklib/extconf.rb


DEFINITIONS

This source file includes following functions.


   1  # extconf.rb for tcltklib
   2  
   3  require 'mkmf'
   4  
   5  if RUBY_PLATFORM !~ /mswin32|mingw|cygwin|bccwin32/
   6    have_library("nsl", "t_open")
   7    have_library("socket", "socket")
   8    have_library("dl", "dlopen")
   9    have_library("m", "log") 
  10  end
  11  
  12  dir_config("tk")
  13  dir_config("tcl")
  14  dir_config("X11")
  15  
  16  tklib = with_config("tklib")
  17  tcllib = with_config("tcllib")
  18  stubs = enable_config("tcltk_stubs") || with_config("tcltk_stubs")
  19  
  20  def find_tcl(tcllib, stubs)
  21    paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
  22    func = stubs ? "Tcl_InitStubs" : "Tcl_FindExecutable"
  23    if tcllib
  24      find_library(tcllib, func, *paths)
  25    elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin|bccwin32/
  26      find_library("tcl", func, *paths) or
  27        find_library("tcl84", func, *paths) or
  28        find_library("tcl83", func, *paths) or
  29        find_library("tcl82", func, *paths) or
  30        find_library("tcl80", func, *paths) or
  31        find_library("tcl76", func, *paths)
  32    else
  33      find_library("tcl", func, *paths) or
  34        find_library("tcl8.4", func, *paths) or
  35        find_library("tcl8.3", func, *paths) or
  36        find_library("tcl8.2", func, *paths) or
  37        find_library("tcl8.0", func, *paths) or
  38        find_library("tcl7.6", func, *paths)
  39    end
  40  end
  41  
  42  def find_tk(tklib, stubs)
  43    paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
  44    func = stubs ? "Tk_InitStubs" : "Tk_Init"
  45    if tklib
  46      find_library(tklib, func, *paths)
  47    elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin|bccwin32/
  48      find_library("tk", func, *paths) or
  49        find_library("tk84", func, *paths) or
  50        find_library("tk83", func, *paths) or
  51        find_library("tk82", func, *paths) or
  52        find_library("tk80", func, *paths) or
  53        find_library("tk42", func, *paths)
  54    else
  55      find_library("tk", func, *paths) or
  56        find_library("tk8.4", func, *paths) or
  57        find_library("tk8.3", func, *paths) or
  58        find_library("tk8.2", func, *paths) or
  59        find_library("tk8.0", func, *paths) or
  60        find_library("tk4.2", func, *paths)
  61    end
  62  end
  63  
  64  if have_header("tcl.h") && have_header("tk.h") &&
  65      (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM || find_library("X11", "XOpenDisplay",
  66          "/usr/X11/lib", "/usr/X11R6/lib", "/usr/openwin/lib")) &&
  67      find_tcl(tcllib, stubs) &&
  68      find_tk(tklib, stubs)
  69    $CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS' if stubs
  70    $CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
  71    create_makefile("tcltklib")
  72  end