Patchwork [3/3] configure: try pkg-config for curses

login
register
mail settings
Submitter Stefan Hajnoczi
Date Jan. 15, 2013, 5:13 p.m.
Message ID <1358270033-18064-4-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/212257/
State New
Headers show

Comments

Stefan Hajnoczi - Jan. 15, 2013, 5:13 p.m.
From: Vadim Evard <v.e.evard@gmail.com>

Static linkikng against ncurses may require explicit -ltinfo.
In case -lcurses and -lncurses both didn't work give pkg-config a
chance.

Fixes #1094786 for me.

Signed-off-by: Vadim Evard <v.e.evard@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 configure | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Anthony Liguori - Jan. 15, 2013, 10:57 p.m.
Stefan Hajnoczi <stefanha@redhat.com> writes:

> From: Vadim Evard <v.e.evard@gmail.com>
>
> Static linkikng against ncurses may require explicit -ltinfo.
> In case -lcurses and -lncurses both didn't work give pkg-config a
> chance.
>
> Fixes #1094786 for me.
>
> Signed-off-by: Vadim Evard <v.e.evard@gmail.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  configure | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index c908f66..40473a9 100755
> --- a/configure
> +++ b/configure
> @@ -2039,7 +2039,7 @@ fi
>  if test "$mingw32" = "yes" ; then
>      curses_list="-lpdcurses"
>  else
> -    curses_list="-lncurses -lcurses"
> +    curses_list="-lncurses:-lcurses:$($pkg_config --libs ncurses)"

Please fix this as a follow up but this is sloppy.

pkg-config spews stuff to stderr when a package isn't found so this ends
up outputting junk in the configure if ncurses isn't found.

Regards,

Anthony Liguori

>  fi
>  
>  if test "$curses" != "no" ; then
> @@ -2052,13 +2052,16 @@ int main(void) {
>    return s != 0;
>  }
>  EOF
> +  IFS=:
>    for curses_lib in $curses_list; do
> +    unset IFS
>      if compile_prog "" "$curses_lib" ; then
>        curses_found=yes
>        libs_softmmu="$curses_lib $libs_softmmu"
>        break
>      fi
>    done
> +  unset IFS
>    if test "$curses_found" = "yes" ; then
>      curses=yes
>    else
> -- 
> 1.8.0.2

Patch

diff --git a/configure b/configure
index c908f66..40473a9 100755
--- a/configure
+++ b/configure
@@ -2039,7 +2039,7 @@  fi
 if test "$mingw32" = "yes" ; then
     curses_list="-lpdcurses"
 else
-    curses_list="-lncurses -lcurses"
+    curses_list="-lncurses:-lcurses:$($pkg_config --libs ncurses)"
 fi
 
 if test "$curses" != "no" ; then
@@ -2052,13 +2052,16 @@  int main(void) {
   return s != 0;
 }
 EOF
+  IFS=:
   for curses_lib in $curses_list; do
+    unset IFS
     if compile_prog "" "$curses_lib" ; then
       curses_found=yes
       libs_softmmu="$curses_lib $libs_softmmu"
       break
     fi
   done
+  unset IFS
   if test "$curses_found" = "yes" ; then
     curses=yes
   else