meson: fix readline detection if there is no pkg-config file

Commit <74416b1d4849ef77ef31de5344dd75f03094434b> added check for
rl_completion_quote_character to make sure we have correct readline
library. Commit <a9443bc9a9ef451b46306e66ed3b706756fc1414> added
inaccurate comment that it's a function.

We need to check for generic symbol instead of checking for function.
In addition the readline/readline.h file requires stdio.h to by included
beforehand which was done in autotools but I dropped it in meson.

And lastly the final condition to print error or disable readline was
broken as well by replacing the readline_dep every time if readline was
not explicitly enabled.

Reported-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Pavel Hrdina 2020-08-05 12:39:24 +02:00
parent f1a298c20d
commit 84bb5fd1ab

View File

@ -1268,17 +1268,19 @@ if not readline_dep.found()
readline_dep = cc.find_library('readline', required: get_option('readline'))
if readline_dep.found()
# This function is present in all reasonable (5.0+) readline versions;
# This variable is present in all reasonable (5.0+) readline versions;
# however, the macOS base system contains a library called libedit which
# takes over the readline name despite lacking many of its features. We
# want to make sure we only enable readline support when linking against
# the actual readline library, and the availability of this specific
# functions is as good a witness for that fact as any.
correct_rl = cc.has_function('rl_completion_quote_character', prefix: '#include <readline/readline.h>')
if not correct_rl and get_option('readline').enabled()
error('readline is missing rl_completion_quote_character')
else
readline_dep = dependency('', required: false)
# variable is as good a witness for that fact as any.
correct_rl = cc.has_header_symbol('readline/readline.h', 'rl_completion_quote_character', prefix: '#include <stdio.h>')
if not correct_rl
if get_option('readline').enabled()
error('readline is missing rl_completion_quote_character')
else
readline_dep = dependency('', required: false)
endif
endif
endif
endif