]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: fix readline detection if there is no pkg-config file
authorPavel Hrdina <phrdina@redhat.com>
Wed, 5 Aug 2020 10:39:24 +0000 (12:39 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 5 Aug 2020 11:32:59 +0000 (13:32 +0200)
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>
meson.build

index ad269640bafd170500119f1a4379ad4cf7672836..19b47955270153f856810babb582f775ddcabddd 100644 (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