diff --git a/config.h.meson b/config.h.meson index 432402d5b..5979793e5 100644 --- a/config.h.meson +++ b/config.h.meson @@ -255,3 +255,9 @@ #mesondefine HAVE_PIDFD_OPEN #mesondefine HAVE_PIDFD_SEND_SIGNAL #mesondefine HAVE_RT_SIGQUEUEINFO + +/* Define to 1 if you want to use -ledit, otherwise 0 for default -lreadline. */ +#mesondefine HAVE_EDITLINE_READLINE + +/* Define to 1 if you have history support from -lreadline. */ +#mesondefine HAVE_READLINE_HISTORY diff --git a/meson.build b/meson.build index 608282819..0c5a28fbc 100644 --- a/meson.build +++ b/meson.build @@ -733,24 +733,33 @@ if enable_concheck endif config_h.set10('WITH_CONCHECK', enable_concheck) +config_h.set10('HAVE_READLINE_HISTORY', false) +config_h.set10('HAVE_EDITLINE_READLINE', false) +enable_readline = get_option('readline') +if enable_readline != 'none' + if enable_readline == 'libreadline' or enable_readline == 'auto' + readline = cc.find_library('readline') + if readline.found() + readline_dep = declare_dependency(link_args: '-lreadline') + config_h.set10('HAVE_READLINE_HISTORY', true) + else + assert(enable_readline == 'auto', 'libreadline was not found') + endif + endif + if enable_readline == 'libedit' or (enable_readline == 'auto' and not readline.found()) + edit = dependency('libedit') + if edit.found() + readline_dep = declare_dependency(link_args: '-ledit') + config_h.set10('HAVE_EDITLINE_READLINE', true) + else + assert(enable_readline == 'auto', 'libedit was not found') + endif + endif +endif + enable_nmcli = get_option('nmcli') if enable_nmcli - # FIXME: check for readline - # AX_LIB_READLINE - readline_dep = declare_dependency(link_args: '-lreadline') - ''' - foreach readline_lib: ['-lreadline', '-ledit', '-leditline'] - if not is_variable('readline_dep') - foreach termcap_lib: ['', '-lncurses', '-ltermcap', '-lcurses'] - test_dep = declare_dependency(link_args: ' '.join([readline_lib, termcap_lib])) - if cc.has_function('readline', dependencies: test_dep) and cc.has_header('readline', dependencies: test_dep) - readline_dep = test_dep - endif - endforeach - endif - endforeach - ''' - assert(readline_dep.found(), 'readline library with terminfo support is required (one of readline, edit, or editline, AND one of ncurses, curses, or termcap)') + assert(enable_readline != 'none', 'readline library with terminfo support is required (one of readline, edit, or editline, AND one of ncurses, curses, or termcap)') endif enable_nmtui = get_option('nmtui') @@ -1086,4 +1095,5 @@ output += ' sanitizers: ' + get_option('b_sanitize') + '\n' output += ' Mozilla Public Suffix List: ' + enable_libpsl.to_string() + '\n' output += ' vapi: ' + enable_vapi.to_string() + '\n' output += ' ebpf: ' + enable_ebpf.to_string() + '\n' +output += ' readline: ' + enable_readline + '\n' message(output) diff --git a/meson_options.txt b/meson_options.txt index 14ed4077a..76a131ad0 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -72,3 +72,4 @@ option('ld_gc', type: 'boolean', value: true, description: 'Enable garbage colle option('libpsl', type: 'boolean', value: true, description: 'Link against libpsl') option('crypto', type: 'combo', choices: ['nss', 'gnutls'], value: 'nss', description: 'Cryptography library to use for certificate and key operations') option('qt', type: 'boolean', value: true, description: 'enable Qt examples') +option('readline', type: 'combo', choices: ['auto', 'libreadline', 'libedit', 'none'], description: 'Using readline (auto) or libedit)')