From 55fa00f05b42293e575b781ec9e1e867ef111644 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 15 Jul 2021 17:33:09 +0200 Subject: [PATCH] build/meson: cleanup handling of libreadline build option - add "required:false" to dependency() and find_library(), otherwise autodetection will fail. - rename variable "enable_readline" to "with_readline" for consistency with autotools. - with -Dlibreadline=auto, once we detect a library, update "with_readline" variable to reflect the detected choice. This will also be printed in the summary output. This is also important for the nmcli check `assert(with_readline != 'none', 'readline ...`. --- meson.build | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 0c5a28fbc6..3c4be61509 100644 --- a/meson.build +++ b/meson.build @@ -735,31 +735,34 @@ 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') +with_readline = get_option('readline') +if with_readline != 'none' + if with_readline == 'libreadline' or with_readline == 'auto' + readline = cc.find_library('readline', required: false) if readline.found() readline_dep = declare_dependency(link_args: '-lreadline') config_h.set10('HAVE_READLINE_HISTORY', true) + with_readline = 'libreadline' else - assert(enable_readline == 'auto', 'libreadline was not found') + assert(with_readline == 'auto', 'libreadline was not found') endif endif - if enable_readline == 'libedit' or (enable_readline == 'auto' and not readline.found()) - edit = dependency('libedit') + if with_readline == 'libedit' or with_readline == 'auto' + edit = dependency('libedit', required: false) if edit.found() readline_dep = declare_dependency(link_args: '-ledit') config_h.set10('HAVE_EDITLINE_READLINE', true) + with_readline = 'libedit' else - assert(enable_readline == 'auto', 'libedit was not found') + assert(with_readline == 'auto', 'libedit was not found') + with_readline = 'none' endif endif endif enable_nmcli = get_option('nmcli') if enable_nmcli - assert(enable_readline != 'none', 'readline library with terminfo support is required (one of readline, edit, or editline, AND one of ncurses, curses, or termcap)') + assert(with_readline != 'none', 'nmcli requires readline library (-Dnmcli=false or -Dreadline=auto|libreadline|libedit|none)') endif enable_nmtui = get_option('nmtui') @@ -1095,5 +1098,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' +output += ' readline: ' + with_readline + '\n' message(output)