2015-12-16 00:31:54 -05:00
|
|
|
# frozen_string_literal: false
|
1999-01-19 23:59:32 -05:00
|
|
|
require "mkmf"
|
|
|
|
|
2012-06-19 05:21:58 -04:00
|
|
|
readline = Struct.new(:headers, :extra_check).new(["stdio.h"])
|
2005-05-19 10:36:20 -04:00
|
|
|
|
2012-06-19 05:21:58 -04:00
|
|
|
def readline.have_header(header)
|
|
|
|
if super(header, &extra_check)
|
|
|
|
headers.push(header)
|
2005-05-19 10:36:20 -04:00
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-19 05:21:58 -04:00
|
|
|
def readline.have_var(var)
|
|
|
|
return super(var, headers)
|
2005-05-19 10:36:20 -04:00
|
|
|
end
|
|
|
|
|
2012-06-19 05:21:58 -04:00
|
|
|
def readline.have_func(func)
|
|
|
|
return super(func, headers)
|
2008-06-22 01:16:30 -04:00
|
|
|
end
|
|
|
|
|
2014-03-01 21:13:41 -05:00
|
|
|
def readline.have_type(type)
|
|
|
|
return super(type, headers)
|
|
|
|
end
|
|
|
|
|
2004-07-15 10:04:09 -04:00
|
|
|
dir_config('curses')
|
|
|
|
dir_config('ncurses')
|
|
|
|
dir_config('termcap')
|
1999-08-13 01:37:52 -04:00
|
|
|
dir_config("readline")
|
2005-05-19 10:36:20 -04:00
|
|
|
enable_libedit = enable_config("libedit")
|
2010-05-31 14:48:16 -04:00
|
|
|
|
2000-05-13 12:13:31 -04:00
|
|
|
have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM
|
2005-05-19 10:36:20 -04:00
|
|
|
have_library("ncurses", "tgetnum") ||
|
|
|
|
have_library("termcap", "tgetnum") ||
|
2000-05-18 00:32:13 -04:00
|
|
|
have_library("curses", "tgetnum")
|
|
|
|
|
2011-04-12 05:08:08 -04:00
|
|
|
case enable_libedit
|
|
|
|
when true
|
2011-06-21 00:20:33 -04:00
|
|
|
# --enable-libedit
|
2015-11-30 04:48:24 -05:00
|
|
|
dir_config("libedit")
|
2012-06-19 05:21:58 -04:00
|
|
|
unless (readline.have_header("editline/readline.h") ||
|
|
|
|
readline.have_header("readline/readline.h")) &&
|
2005-05-19 10:36:20 -04:00
|
|
|
have_library("edit", "readline")
|
2012-05-18 03:02:10 -04:00
|
|
|
raise "libedit not found"
|
2001-09-06 01:14:06 -04:00
|
|
|
end
|
2011-06-21 00:20:33 -04:00
|
|
|
when false
|
|
|
|
# --disable-libedit
|
2012-06-19 05:21:58 -04:00
|
|
|
unless ((readline.have_header("readline/readline.h") &&
|
|
|
|
readline.have_header("readline/history.h")) &&
|
2011-04-12 05:08:08 -04:00
|
|
|
have_library("readline", "readline"))
|
2012-05-18 03:02:10 -04:00
|
|
|
raise "readline not found"
|
2011-04-12 05:08:08 -04:00
|
|
|
end
|
2005-05-19 10:36:20 -04:00
|
|
|
else
|
2011-06-21 00:20:33 -04:00
|
|
|
# does not specify
|
2012-06-19 05:21:58 -04:00
|
|
|
unless ((readline.have_header("readline/readline.h") &&
|
|
|
|
readline.have_header("readline/history.h")) &&
|
2005-05-19 10:36:20 -04:00
|
|
|
(have_library("readline", "readline") ||
|
|
|
|
have_library("edit", "readline"))) ||
|
2012-06-19 05:21:58 -04:00
|
|
|
(readline.have_header("editline/readline.h") &&
|
2005-05-19 10:36:20 -04:00
|
|
|
have_library("edit", "readline"))
|
2016-10-05 22:38:18 -04:00
|
|
|
raise "Neither readline nor libedit was found"
|
2001-09-06 01:14:06 -04:00
|
|
|
end
|
1999-01-19 23:59:32 -05:00
|
|
|
end
|
2005-05-19 10:36:20 -04:00
|
|
|
|
2012-06-19 05:21:58 -04:00
|
|
|
readline.have_func("rl_getc")
|
|
|
|
readline.have_func("rl_getc_function")
|
|
|
|
readline.have_func("rl_filename_completion_function")
|
|
|
|
readline.have_func("rl_username_completion_function")
|
|
|
|
readline.have_func("rl_completion_matches")
|
|
|
|
readline.have_func("rl_refresh_line")
|
|
|
|
readline.have_var("rl_deprep_term_function")
|
|
|
|
readline.have_var("rl_completion_append_character")
|
|
|
|
readline.have_var("rl_basic_word_break_characters")
|
|
|
|
readline.have_var("rl_completer_word_break_characters")
|
|
|
|
readline.have_var("rl_basic_quote_characters")
|
|
|
|
readline.have_var("rl_completer_quote_characters")
|
|
|
|
readline.have_var("rl_filename_quote_characters")
|
|
|
|
readline.have_var("rl_attempted_completion_over")
|
|
|
|
readline.have_var("rl_library_version")
|
|
|
|
readline.have_var("rl_editing_mode")
|
|
|
|
readline.have_var("rl_line_buffer")
|
|
|
|
readline.have_var("rl_point")
|
2016-10-03 04:20:07 -04:00
|
|
|
readline.have_var("rl_char_is_quoted_p")
|
2008-02-20 09:43:39 -05:00
|
|
|
# workaround for native windows.
|
2012-06-19 05:21:58 -04:00
|
|
|
/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_event_hook")
|
|
|
|
/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_sigwinch")
|
|
|
|
/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_signals")
|
|
|
|
readline.have_var("rl_pre_input_hook")
|
|
|
|
readline.have_var("rl_special_prefixes")
|
|
|
|
readline.have_func("rl_cleanup_after_signal")
|
|
|
|
readline.have_func("rl_free_line_state")
|
|
|
|
readline.have_func("rl_clear_signals")
|
|
|
|
readline.have_func("rl_set_screen_size")
|
|
|
|
readline.have_func("rl_get_screen_size")
|
|
|
|
readline.have_func("rl_vi_editing_mode")
|
|
|
|
readline.have_func("rl_emacs_editing_mode")
|
|
|
|
readline.have_func("replace_history_entry")
|
|
|
|
readline.have_func("remove_history")
|
|
|
|
readline.have_func("clear_history")
|
|
|
|
readline.have_func("rl_redisplay")
|
|
|
|
readline.have_func("rl_insert_text")
|
2013-07-21 20:37:10 -04:00
|
|
|
readline.have_func("rl_delete_text")
|
2014-04-04 11:31:23 -04:00
|
|
|
unless readline.have_type("rl_hook_func_t*")
|
2014-03-02 01:22:27 -05:00
|
|
|
# rl_hook_func_t is available since readline-4.2 (2001).
|
|
|
|
# Function is removed at readline-6.3 (2014).
|
|
|
|
# However, editline (NetBSD 6.1.3, 2014) doesn't have rl_hook_func_t.
|
2014-03-31 10:57:47 -04:00
|
|
|
$defs << "-Drl_hook_func_t=Function"
|
2014-03-01 21:13:41 -05:00
|
|
|
end
|
|
|
|
|
2014-09-12 09:11:13 -04:00
|
|
|
$INCFLAGS << " -I$(top_srcdir)"
|
2005-05-19 10:36:20 -04:00
|
|
|
create_makefile("readline")
|