1999-01-19 23:59:39 -05:00
|
|
|
require 'mkmf'
|
|
|
|
|
2012-02-22 07:45:04 -05:00
|
|
|
def have_all(*args)
|
2012-02-20 07:09:25 -05:00
|
|
|
old_libs = $libs.dup
|
|
|
|
old_defs = $defs.dup
|
2012-02-22 07:45:04 -05:00
|
|
|
result = []
|
|
|
|
begin
|
|
|
|
args.each {|arg|
|
|
|
|
r = arg.call(*result)
|
|
|
|
if !r
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
result << r
|
|
|
|
}
|
|
|
|
result
|
|
|
|
ensure
|
|
|
|
if result.length != args.length
|
|
|
|
$libs = old_libs
|
|
|
|
$defs = old_defs
|
2012-02-22 05:09:31 -05:00
|
|
|
end
|
2012-02-22 07:45:04 -05:00
|
|
|
end
|
2012-02-22 05:09:31 -05:00
|
|
|
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|
|
2012-02-22 07:45:04 -05:00
|
|
|
header_library = have_all(
|
|
|
|
lambda { have_header(hdr) && hdr },
|
|
|
|
lambda {|h| libs.find {|lib| have_library(lib, "initscr", h) } })
|
2012-02-22 05:09:31 -05:00
|
|
|
if header_library
|
|
|
|
break;
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
if header_library
|
2012-02-22 05:48:59 -05:00
|
|
|
header, library = header_library
|
|
|
|
puts "header: #{header}"
|
|
|
|
puts "library: #{library}"
|
|
|
|
|
2012-02-22 05:09:31 -05:00
|
|
|
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)
|
2012-02-22 06:44:26 -05:00
|
|
|
|
|
|
|
# SVR4 curses has a (undocumented) variable char *curses_version.
|
|
|
|
# ncurses and PDcurses has a function char *curses_version().
|
|
|
|
# Note that the original BSD curses doesn't provide version information.
|
|
|
|
|
|
|
|
prolog = cpp_include(curses)
|
|
|
|
if checking_for(checking_message('function curses_version', curses)) {
|
|
|
|
try_run(<<-"End")
|
|
|
|
#{prolog}
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
curses_version();
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
End
|
|
|
|
}
|
|
|
|
$defs << '-DHAVE_FUNC_CURSES_VERSION'
|
|
|
|
end
|
|
|
|
|
|
|
|
if checking_for(checking_message('variable curses_version', curses)) {
|
|
|
|
try_run(<<-"End")
|
|
|
|
#{prolog}
|
|
|
|
extern char *curses_version;
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
if (curses_version[i] == 0)
|
|
|
|
return 0 < i ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
if (curses_version[i] & 0x80)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
End
|
|
|
|
}
|
|
|
|
$defs << '-DHAVE_VAR_CURSES_VERSION'
|
|
|
|
end
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
create_makefile("curses")
|
|
|
|
end
|