1999-01-19 23:59:39 -05:00
|
|
|
require 'mkmf'
|
|
|
|
|
2012-02-20 07:09:25 -05:00
|
|
|
def transact
|
|
|
|
old_libs = $libs.dup
|
|
|
|
old_defs = $defs.dup
|
|
|
|
result = yield
|
|
|
|
if !result
|
|
|
|
$libs = old_libs
|
|
|
|
$defs = old_defs
|
|
|
|
end
|
|
|
|
result
|
|
|
|
end
|
|
|
|
|
2012-02-22 05:09:31 -05:00
|
|
|
def check_header_library(hdr, libs)
|
|
|
|
if !have_header(hdr)
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
libs.each {|lib|
|
|
|
|
if have_library(lib, "initscr")
|
|
|
|
return [hdr, lib]
|
|
|
|
end
|
|
|
|
}
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2001-12-31 12:48:33 -05:00
|
|
|
dir_config('curses')
|
|
|
|
dir_config('ncurses')
|
|
|
|
dir_config('termcap')
|
2001-02-18 03:18:47 -05:00
|
|
|
|
2000-05-13 12:13:31 -04:00
|
|
|
have_library("mytinfo", "tgetent") if /bow/ =~ RUBY_PLATFORM
|
2003-07-04 03:31:10 -04:00
|
|
|
have_library("tinfo", "tgetent") or have_library("termcap", "tgetent")
|
2012-02-20 07:09:25 -05:00
|
|
|
|
2012-02-22 05:09:31 -05:00
|
|
|
header_library = nil
|
|
|
|
[
|
|
|
|
["ncurses.h", ["ncursesw", "ncurses"]],
|
|
|
|
["ncurses/curses.h", ["ncurses"]],
|
|
|
|
["curses_colr/curses.h", ["cur_colr"]],
|
|
|
|
["curses.h", ["curses"]],
|
|
|
|
].each {|hdr, libs|
|
|
|
|
header_library = transact { check_header_library(hdr, libs) }
|
|
|
|
if header_library
|
|
|
|
break;
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
if header_library
|
|
|
|
header, _ = header_library
|
|
|
|
curses = [header]
|
|
|
|
if header == 'curses_colr/curses.h'
|
|
|
|
curses.unshift("varargs.h")
|
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2012-02-20 07:41:23 -05:00
|
|
|
for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash
|
|
|
|
getbkgd getnstr init isendwin keyname keypad resizeterm
|
|
|
|
scrl set setscrreg ungetch
|
|
|
|
wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr
|
|
|
|
wresize wscrl wsetscrreg
|
|
|
|
def_prog_mode reset_prog_mode timeout wtimeout nodelay
|
|
|
|
init_color wcolor_set use_default_colors newpad)
|
2007-11-15 05:50:34 -05:00
|
|
|
have_func(f) || (have_macro(f, curses) && $defs.push(format("-DHAVE_%s", f.upcase)))
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
2003-08-18 12:24:42 -04:00
|
|
|
flag = "-D_XOPEN_SOURCE_EXTENDED"
|
2012-02-20 07:41:23 -05:00
|
|
|
if try_static_assert("sizeof(char*)>sizeof(int)",
|
|
|
|
%w[stdio.h stdlib.h]+curses,
|
|
|
|
flag)
|
2003-08-18 12:24:42 -04:00
|
|
|
$defs << flag
|
|
|
|
end
|
2008-11-21 13:35:11 -05:00
|
|
|
have_var("ESCDELAY", curses)
|
2008-12-08 23:31:41 -05:00
|
|
|
have_var("TABSIZE", curses)
|
2009-02-24 10:19:17 -05:00
|
|
|
have_var("COLORS", curses)
|
|
|
|
have_var("COLOR_PAIRS", curses)
|
1998-01-16 07:13:05 -05:00
|
|
|
create_makefile("curses")
|
|
|
|
end
|