diff mbox

[2/5] curses: Use cursesw when available

Message ID 1466634202-24616-3-git-send-email-samuel.thibault@ens-lyon.org (mailing list archive)
State New, archived
Headers show

Commit Message

Samuel Thibault June 22, 2016, 10:23 p.m. UTC
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 configure | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

Comments

Gerd Hoffman June 23, 2016, 7:29 a.m. UTC | #1
Hi,

>  ##########################################
> +# cursesw probe
> +if test "$cursesw" != "no" ; then
> +  if test "$mingw32" = "yes" ; then
> +    cursesw_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):"
> +    cursesw_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lpdcurses"
> +  else
> +    cursesw_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):"
> +    cursesw_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw:-lncurses:-lcurses"
> +  fi
> [ ... ]

Do we *really* want this mess?

Is there any curses implementation without wide char support which is
still relevant today?

Is there any curses implementation beside ncurses still relevant today?

/me boots the freebsd guest.
/me finds libcurses being symlinks to libncurses.

I'm tempted to say just require ncursesw and be done with it.
That will also avoid the #ifdef mess in the following patches.

cheers,
  Gerd
diff mbox

Patch

diff --git a/configure b/configure
index 10cb212..ff10012 100755
--- a/configure
+++ b/configure
@@ -203,6 +203,7 @@  bluez=""
 brlapi=""
 curl=""
 curses=""
+cursesw=""
 docs=""
 fdt=""
 netmap="no"
@@ -978,6 +979,10 @@  for opt do
   ;;
   --enable-curses) curses="yes"
   ;;
+  --disable-cursesw) cursesw="no"
+  ;;
+  --enable-cursesw) cursesw="yes"
+  ;;
   --disable-curl) curl="no"
   ;;
   --enable-curl) curl="yes"
@@ -1327,6 +1332,7 @@  disabled with --disable-FEATURE, default is enabled if available:
   --with-gtkabi     select preferred GTK ABI 2.0 or 3.0
   vte             vte support for the gtk UI
   curses          curses UI
+  cursesw         cursesw UI
   vnc             VNC UI support
   vnc-sasl        SASL encryption for VNC server
   vnc-jpeg        JPEG lossy compression for VNC server
@@ -2873,8 +2879,60 @@  EOF
 fi
 
 ##########################################
+# cursesw probe
+if test "$cursesw" != "no" ; then
+  if test "$mingw32" = "yes" ; then
+    cursesw_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):"
+    cursesw_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lpdcurses"
+  else
+    cursesw_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):"
+    cursesw_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw:-lncurses:-lcurses"
+  fi
+  cursesw_found=no
+  cat > $TMPC << EOF
+#include <locale.h>
+#include <curses.h>
+#include <wchar.h>
+#include <langinfo.h>
+int main(void) {
+  const char *s = curses_version();
+  const char *codeset;
+  wchar_t wch = L'w';
+  setlocale(LC_ALL, "");
+  resize_term(0, 0);
+  addwstr(L"wide chars\n");
+  addnwstr(&wch, 1);
+  codeset = nl_langinfo(CODESET);
+  return s != 0 && codeset != 0;
+}
+EOF
+  IFS=:
+  for cursesw_inc in $cursesw_inc_list; do
+    for cursesw_lib in $cursesw_lib_list; do
+      unset IFS
+      if compile_prog "$cursesw_inc" "$cursesw_lib" ; then
+        cursesw_found=yes
+        QEMU_CFLAGS="$cursesw_inc $QEMU_CFLAGS"
+        libs_softmmu="$cursesw_lib $libs_softmmu"
+        break
+      fi
+    done
+  done
+  unset IFS
+  if test "$cursesw_found" = "yes" ; then
+    cursesw=yes
+    curses=yes
+  else
+    if test "$cursesw" = "yes" ; then
+      feature_not_found "cursesw" "Install ncursesw devel"
+    fi
+    cursesw=no
+  fi
+fi
+
+##########################################
 # curses probe
-if test "$curses" != "no" ; then
+if test "$curses" != "no" -a "$cursesw" != "yes"; then
   if test "$mingw32" = "yes" ; then
     curses_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
   else
@@ -4800,6 +4858,7 @@  echo "nettle            $nettle $(echo_version $nettle $nettle_version)"
 echo "nettle kdf        $nettle_kdf"
 echo "libtasn1          $tasn1"
 echo "curses support    $curses"
+echo "cursesw support   $cursesw"
 echo "virgl support     $virglrenderer"
 echo "curl support      $curl"
 echo "mingw32 support   $mingw32"
@@ -5058,6 +5117,9 @@  fi
 if test "$curses" = "yes" ; then
   echo "CONFIG_CURSES=y" >> $config_host_mak
 fi
+if test "$cursesw" = "yes" ; then
+  echo "CONFIG_CURSESW=y" >> $config_host_mak
+fi
 if test "$utimens" = "yes" ; then
   echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
 fi