require "mkmf"

$CFLAGS="-I"+ENV['HOME']+"/include -I/usr/include/slang -I/usr/include -I/usr/local/include/slang-ja -I/usr/local/include/slang -I/usr/local/include"
$LDFLAGS="-L"+ENV['HOME']+"/lib -L/usr/lib -L/usr/local/lib"

if have_header("slang.h")
  if have_library("slang", "SLsmg_refresh") 
    $LDFLAGS += " -lslang"
  else
    exit
  end
#  for f in ["kanji_pos", "IsKcode"]
#    have_func(f)
#  end
  termcap = true
  for mid in %w(lib share share/lib local/lib)
    if FileTest.directory? "/usr/#{mid}/terminfo"
      termcap = false
      break
    end
  end
  if termcap
    $libs += " -ltermcap "
  end
  create_makefile("slanglib")
end
