]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: add libtinfow check
authorKarel Zak <kzak@redhat.com>
Tue, 19 Sep 2017 10:55:49 +0000 (12:55 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 19 Sep 2017 10:55:49 +0000 (12:55 +0200)
It seems some systems differentiate between tinfo and tinfow. And it
seems that mix ncursesw and tinfo (wide vs. non-wide char) is problem
for the systems.

Note that for example Fedora have ncursesw as well as ncurses, but
only one tinfo library. So, we need fallback this scenario.

Reported-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
m4/ul.m4

index c534b49f2df7b6658365f5576e49aedc5ec9d597..73cf221689952e96edf8bf79bbf0e599bf3db80a 100644 (file)
@@ -905,27 +905,21 @@ AC_ARG_WITH([tinfo], AS_HELP_STRING([--without-tinfo], [compile without libtinfo
   [], [with_tinfo=auto]
 )
 have_tinfo=no
+have_tinfow=no
 AS_IF([test "x$with_tinfo" != xno], [
-  dnl Try pkg-config for libtinfo
-  PKG_CHECK_MODULES(TINFO, [tinfo], [
-    dnl pkg-config success
-    have_tinfo=yes
-    UL_PKG_STATIC([TINFO_LIBS_STATIC], [tinfo])], [
-
-    dnl If pkg-config failed, fall back to classic searching.
-    AC_CHECK_LIB([tinfo], [tgetent], [
-       have_tinfo=yes
-       TINFO_LIBS="-ltinfo"
-       TINFO_LIBS_STATIC="-ltinfo"
-       TINFO_CFLAGS=""])
+  AS_IF([test "x$have_ncursesw" = xyes], [
+    UL_TINFO_CHECK([tinfow])
+  ])
+  AS_IF([test "x$have_tinfow" = xno], [
+    UL_TINFO_CHECK([tinfo])
   ])
 ])
 AC_SUBST([TINFO_LIBS])
 AC_SUBST([TINFO_LIBS_STATIC])
 AC_SUBST([TINFO_CFLAGS])
-AM_CONDITIONAL([HAVE_TINFO], [test "x$have_tinfo" = xyes])
-AS_IF([test "x$have_tinfo" = xyes], [
-  AC_DEFINE(HAVE_LIBTINFO, 1, [Define if libtinfo available.])
+AM_CONDITIONAL([HAVE_TINFO], [test "x$have_tinfo" = xyes -o "x$have_tinfow" = xyes])
+AS_IF([test "x$have_tinfo" = xyes -o "x$have_tinfow" = xyes], [
+  AC_DEFINE(HAVE_LIBTINFO, 1, [Define if libtinfo or libtinfow available.])
 ])
 
 
index cfd2e68fc5c154ffa91ebaf05c6be023b579757c..351d9cb6b024de8a03e4673b729f3a6a7d92c98e 100644 (file)
--- a/m4/ul.m4
+++ b/m4/ul.m4
@@ -498,3 +498,30 @@ AC_DEFUN([UL_NCURSES_CHECK], [
     AS_IF([test "x$have_[]suffix" = xyes], [NCURSES_LIBS="-l[]suffix"])
   ])
 ])
+
+dnl
+dnl UL_TINFO_CHECK(NAME)
+dnl
+dnl Initializes $have_<name>, TINFO_LIBS and TINFO_CFLAGS variables.
+dnl
+dnl The expected <name> is tinfow or tinfo.
+dnl
+AC_DEFUN([UL_TINFO_CHECK], [
+  m4_define([suffix], $1)
+  m4_define([SUFFIX], m4_toupper($1))
+
+  PKG_CHECK_MODULES(SUFFIX, [$1], [
+    dnl pkg-config success
+    have_[]suffix=yes
+    TINFO_LIBS=${SUFFIX[]_LIBS}
+    TINFO_CFLAGS=${SUFFIX[]_CFLAGS}
+    UL_PKG_STATIC([TINFO_LIBS_STATIC], [$1])
+  ],[
+    dnl If pkg-config failed, fall back to classic searching.
+    AC_CHECK_LIB([$1], [tgetent], [
+       have_[]suffix=yes
+       TINFO_LIBS="-l[]suffix"
+       TINFO_LIBS_STATIC="-l[]suffix"
+       TINFO_CFLAGS=""])
+  ])
+])