diff mbox

[PULL,6/6] curses: Use cursesw instead of curses

Message ID 1477656698-13569-7-git-send-email-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gerd Hoffmann Oct. 28, 2016, 12:11 p.m. UTC
From: Samuel Thibault <samuel.thibault@ens-lyon.org>

Use ncursesw package instead of curses on non-mingw, and check a few
functions.
Also take cflags from pkg-config, since cursesw headers may be in a
separate, non-default directory.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-id: 20161015195308.20473-3-samuel.thibault@ens-lyon.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

Comments

Cornelia Huck Oct. 31, 2016, 11:45 a.m. UTC | #1
On Fri, 28 Oct 2016 14:11:38 +0200
Gerd Hoffmann <kraxel@redhat.com> wrote:

> From: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> Use ncursesw package instead of curses on non-mingw, and check a few
> functions.
> Also take cflags from pkg-config, since cursesw headers may be in a
> separate, non-default directory.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Message-id: 20161015195308.20473-3-samuel.thibault@ens-lyon.org
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  configure | 29 ++++++++++++++++++++---------
>  1 file changed, 20 insertions(+), 9 deletions(-)

This seems to break configure on one of the systems I use (which may or
may not have a broken setup). SLES12SP1 (s390x) without curses in the
output of pkg-config --list-all, but headers seem to be present (? --
I'm not the admin). Other systems (Fedora and Ubuntu) are fine.

Before this commit, configure detected curses=yes and all seemed well.

Now, configure barfs about -Werror. Some snippets from config.log:

# QEMU configure log Mon Oct 31 12:35:26 CET 2016
# Configured with: '/home/cohuck/git/qemu/build/../configure' '--target-list=s39
0x-softmmu s390x-linux-user' '--enable-kvm' '--enable-vhost-net' '--enable-linux
-aio'

cc -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-protot
ypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-s
trict-aliasing -fno-common -fwrapv -Wendif-labels -Wmissing-include-dirs -Wempty
-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qual
ifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-prot
ector-all -I/usr/include/libpng16 -o config-temp/qemu-conf.exe config-temp/qemu-
conf.c -m64 -g
config-temp/qemu-conf.c: In function ‘main’:
config-temp/qemu-conf.c:9:3: warning: implicit declaration of function ‘addwstr’ [-Wimplicit-function-declaration]
   addwstr(L"wide chars\n");
   ^
config-temp/qemu-conf.c:9:3: warning: nested extern declaration of ‘addwstr’ [-Wnested-externs]
config-temp/qemu-conf.c:10:3: warning: implicit declaration of function ‘addnwstr’ [-Wimplicit-function-declaration]
   addnwstr(&wch, 1);
   ^
config-temp/qemu-conf.c:10:3: warning: nested extern declaration of ‘addnwstr’ [-Wnested-externs]
/tmp/ccgsfoYo.o: In function `main':
/home/cohuck/git/qemu/build/config-temp/qemu-conf.c:5: undefined reference to `curses_version'
/home/cohuck/git/qemu/build/config-temp/qemu-conf.c:8: undefined reference to `resize_term'
/home/cohuck/git/qemu/build/config-temp/qemu-conf.c:9: undefined reference to `addwstr'
/home/cohuck/git/qemu/build/config-temp/qemu-conf.c:10: undefined reference to `addnwstr'
collect2: error: ld returned 1 exit status
cc -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all -I/usr/include/libpng16 -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -m64 -g -lncursesw
config-temp/qemu-conf.c: In function ‘main’:
config-temp/qemu-conf.c:9:3: warning: implicit declaration of function ‘addwstr’ [-Wimplicit-function-declaration]
   addwstr(L"wide chars\n");
   ^
config-temp/qemu-conf.c:9:3: warning: nested extern declaration of ‘addwstr’ [-Wnested-externs]
config-temp/qemu-conf.c:10:3: warning: implicit declaration of function ‘addnwstr’ [-Wimplicit-function-declaration]
   addnwstr(&wch, 1);
   ^
config-temp/qemu-conf.c:10:3: warning: nested extern declaration of ‘addnwstr’ [-Wnested-externs]
/tmp/ccgsfoYo.o: In function `main':
/home/cohuck/git/qemu/build/config-temp/qemu-conf.c:5: undefined reference to `curses_version'
/home/cohuck/git/qemu/build/config-temp/qemu-conf.c:8: undefined reference to `resize_term'
/home/cohuck/git/qemu/build/config-temp/qemu-conf.c:9: undefined reference to `addwstr'
/home/cohuck/git/qemu/build/config-temp/qemu-conf.c:10: undefined reference to `addnwstr'
collect2: error: ld returned 1 exit status
cc -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all -I/usr/include/libpng16 -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -m64 -g -lncursesw
config-temp/qemu-conf.c: In function ‘main’:
config-temp/qemu-conf.c:9:3: warning: implicit declaration of function ‘addwstr’ [-Wimplicit-function-declaration]
   addwstr(L"wide chars\n");
   ^
config-temp/qemu-conf.c:9:3: warning: nested extern declaration of ‘addwstr’ [-Wnested-externs]
config-temp/qemu-conf.c:10:3: warning: implicit declaration of function ‘addnwstr’ [-Wimplicit-function-declaration]
   addnwstr(&wch, 1);
   ^
config-temp/qemu-conf.c:10:3: warning: nested extern declaration of ‘addnwstr’ [-Wnested-externs]
cc -Werror -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all -I/usr/include/libpng16 -o config-temp/qemu-conf.exe config-temp/qemu-conf.c -m64 -g -lncursesw
config-temp/qemu-conf.c: In function ‘main’:
config-temp/qemu-conf.c:9:3: error: implicit declaration of function ‘addwstr’ [-Werror=implicit-function-declaration]
   addwstr(L"wide chars\n");
   ^
config-temp/qemu-conf.c:9:3: error: nested extern declaration of ‘addwstr’ [-Werror=nested-externs]
config-temp/qemu-conf.c:10:3: error: implicit declaration of function ‘addnwstr’ [-Werror=implicit-function-declaration]
   addnwstr(&wch, 1);
   ^
config-temp/qemu-conf.c:10:3: error: nested extern declaration of ‘addnwstr’ [-Werror=nested-externs]
cc1: all warnings being treated as errors

As said, I'm not sure whether this system has a sane setup, and I'm
just a user there. Just noticed this new breakage (which goes away with
--disable-curses).
Samuel Thibault Oct. 31, 2016, 12:01 p.m. UTC | #2
Cornelia Huck, on Mon 31 Oct 2016 12:45:30 +0100, wrote:
> > From: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > 
> > Use ncursesw package instead of curses on non-mingw, and check a few
> > functions.
> > Also take cflags from pkg-config, since cursesw headers may be in a
> > separate, non-default directory.
> > 
> > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > Message-id: 20161015195308.20473-3-samuel.thibault@ens-lyon.org
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> >  configure | 29 ++++++++++++++++++++---------
> >  1 file changed, 20 insertions(+), 9 deletions(-)
> 
> This seems to break configure on one of the systems I use (which may or
> may not have a broken setup). SLES12SP1 (s390x) without curses in the
> output of pkg-config --list-all, but headers seem to be present (? --
> I'm not the admin). Other systems (Fedora and Ubuntu) are fine.

> config-temp/qemu-conf.c:9:3: warning: implicit declaration of function ‘addwstr’ [-Wimplicit-function-declaration]

Bleh.

Could you try to replace #include <curses.h> with #include <cursesw.h>
in ui/curses.c, to see whether that fixes the missing declaration on
that system?  We could be trying both headers to look for the wide
functions and include the one which works.

Samuel
Samuel Thibault Oct. 31, 2016, 12:05 p.m. UTC | #3
Samuel Thibault, on Mon 31 Oct 2016 13:01:59 +0100, wrote:
> Cornelia Huck, on Mon 31 Oct 2016 12:45:30 +0100, wrote:
> > > From: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > > 
> > > Use ncursesw package instead of curses on non-mingw, and check a few
> > > functions.
> > > Also take cflags from pkg-config, since cursesw headers may be in a
> > > separate, non-default directory.
> > > 
> > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > > Message-id: 20161015195308.20473-3-samuel.thibault@ens-lyon.org
> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > > ---
> > >  configure | 29 ++++++++++++++++++++---------
> > >  1 file changed, 20 insertions(+), 9 deletions(-)
> > 
> > This seems to break configure on one of the systems I use (which may or
> > may not have a broken setup). SLES12SP1 (s390x) without curses in the
> > output of pkg-config --list-all, but headers seem to be present (? --
> > I'm not the admin). Other systems (Fedora and Ubuntu) are fine.
> 
> > config-temp/qemu-conf.c:9:3: warning: implicit declaration of function ‘addwstr’ [-Wimplicit-function-declaration]
> 
> We could be trying both headers to look for the wide
> functions and include the one which works.

I'm however surprised that this didn't get catched by configure, we do
look for addwstr there. Could you also post the config.log?

Thanks,
Samuel
Cornelia Huck Oct. 31, 2016, 12:08 p.m. UTC | #4
On Mon, 31 Oct 2016 13:01:59 +0100
Samuel Thibault <samuel.thibault@gnu.org> wrote:

> Cornelia Huck, on Mon 31 Oct 2016 12:45:30 +0100, wrote:
> > > From: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > > 
> > > Use ncursesw package instead of curses on non-mingw, and check a few
> > > functions.
> > > Also take cflags from pkg-config, since cursesw headers may be in a
> > > separate, non-default directory.
> > > 
> > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > > Message-id: 20161015195308.20473-3-samuel.thibault@ens-lyon.org
> > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > > ---
> > >  configure | 29 ++++++++++++++++++++---------
> > >  1 file changed, 20 insertions(+), 9 deletions(-)
> > 
> > This seems to break configure on one of the systems I use (which may or
> > may not have a broken setup). SLES12SP1 (s390x) without curses in the
> > output of pkg-config --list-all, but headers seem to be present (? --
> > I'm not the admin). Other systems (Fedora and Ubuntu) are fine.
> 
> > config-temp/qemu-conf.c:9:3: warning: implicit declaration of function ‘addwstr’ [-Wimplicit-function-declaration]
> 
> Bleh.
> 
> Could you try to replace #include <curses.h> with #include <cursesw.h>
> in ui/curses.c, to see whether that fixes the missing declaration on
> that system?  We could be trying both headers to look for the wide
> functions and include the one which works.

You mean in configure, right? Including cursesw.h in the test program
gets configure going again.
Samuel Thibault Oct. 31, 2016, 12:16 p.m. UTC | #5
Cornelia Huck, on Mon 31 Oct 2016 13:08:06 +0100, wrote:
> On Mon, 31 Oct 2016 13:01:59 +0100
> Samuel Thibault <samuel.thibault@gnu.org> wrote:
> 
> > Cornelia Huck, on Mon 31 Oct 2016 12:45:30 +0100, wrote:
> > > config-temp/qemu-conf.c:9:3: warning: implicit declaration of function ‘addwstr’ [-Wimplicit-function-declaration]
> > 
> > Bleh.
> > 
> > Could you try to replace #include <curses.h> with #include <cursesw.h>
> > in ui/curses.c, to see whether that fixes the missing declaration on
> > that system?  We could be trying both headers to look for the wide
> > functions and include the one which works.
> 
> You mean in configure, right?

Ah, sorry, I read too fast, I thought what you had was a build failure,
not a configuration failure.

> Including cursesw.h in the test program gets configure going again.

Ok, that makes sense, thanks.

Samuel
diff mbox

Patch

diff --git a/configure b/configure
index 8e10059..5e44469 100755
--- a/configure
+++ b/configure
@@ -2917,27 +2917,38 @@  fi
 # curses probe
 if test "$curses" != "no" ; then
   if test "$mingw32" = "yes" ; then
-    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
+    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
+    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
   else
-    curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lncurses:-lcurses"
+    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):"
+    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
   fi
   curses_found=no
   cat > $TMPC << EOF
+#include <locale.h>
 #include <curses.h>
+#include <wchar.h>
 int main(void) {
   const char *s = curses_version();
+  wchar_t wch = L'w';
+  setlocale(LC_ALL, "");
   resize_term(0, 0);
+  addwstr(L"wide chars\n");
+  addnwstr(&wch, 1);
   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
+  for curses_inc in $curses_inc_list; do
+    for curses_lib in $curses_lib_list; do
+      unset IFS
+      if compile_prog "$curses_inc" "$curses_lib" ; then
+        curses_found=yes
+        QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
+        libs_softmmu="$curses_lib $libs_softmmu"
+        break
+      fi
+    done
   done
   unset IFS
   if test "$curses_found" = "yes" ; then