]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: use ncurses-config rather than pkg-config
authorKarel Zak <kzak@redhat.com>
Thu, 20 Oct 2016 14:52:31 +0000 (16:52 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 20 Oct 2016 14:52:31 +0000 (16:52 +0200)
It's painful, but ncurses upstream does not distribute .pc files by
default and it seems that ncurses{6,5}-config is the preferred solution.

For better compatibility lets use ncurses-config.

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
m4/ul.m4

index 61264b1c28f78666a5bd78bfa5e47b9623336cbf..66601ecf3c9d40c433b9e5624701bda73470182f 100644 (file)
@@ -778,14 +778,12 @@ AC_ARG_WITH([ncursesw],
 )
 have_ncursesw=no
 AS_IF([test "x$with_ncursesw" != xno], [
-  PKG_CHECK_MODULES(NCURSESW, [ncursesw], [
-    have_ncursesw=yes
-    NCURSES_LIBS=${NCURSESW_LIBS}
-    NCURSES_CFLAGS=${NCURSESW_CFLAGS}
+  UL_NCURSES_CHECK([ncursesw])
+  AS_IF([test "x$have_ncursesw" = xyes], [
     AC_DEFINE([HAVE_LIBNCURSESW], [1], [Define if ncursesw library available])
     CURSES_LIB_NAME="ncursesw"
     AC_CHECK_HEADERS([ncursesw/ncurses.h ncurses.h])
-  ], [have_ncursesw=no])
+  ])
 ])
 AS_CASE([$with_ncursesw:$have_ncursesw],
   [yes:no], [AC_MSG_ERROR([ncursesw selected, but library not found])])
@@ -802,12 +800,12 @@ AS_CASE([$with_ncurses:$build_widechar],
   [yes:yes], [AC_MSG_ERROR([wide-char support enabled, but non-wide ncurses selects])])
 
 AS_IF([test "x$have_ncursesw" = xno -a "x$with_ncurses" != xno ], [
-  PKG_CHECK_MODULES(NCURSES, [ncurses], [
-    have_ncurses=yes
+  UL_NCURSES_CHECK([ncurses])
+  AS_IF([test "x$have_ncurses" = xyes], [
     AC_DEFINE([HAVE_LIBNCURSES], [1], [Define if ncurses library available])
     CURSES_LIB_NAME="ncurses"
     AC_CHECK_HEADERS([ncurses/ncurses.h ncurses.h])
-  ],[have_ncurses=no])
+  ])
 ])
 AS_CASE([$with_ncurses:$have_ncurses],
   [yes:no], [AC_MSG_ERROR([ncurses selected, but library not found])])
index 6c439511d8a15d69c7992a3462504971c54ce32f..280e422ae64dd130a4068f721a34982596e20a0e 100644 (file)
--- a/m4/ul.m4
+++ b/m4/ul.m4
@@ -428,3 +428,38 @@ AC_DEFUN([UL_DEFAULT_ENABLE], [
     enable_[]suffix=$2
   fi
 ])
+
+dnl UL_NCURSES_CHECK(NAME)
+dnl
+dnl Initializes $have_<name>, NCURSES_LIBS and NCURSES_CFLAGS variables according to
+dnl <name>{6,5}_config output.
+dnl
+dnl The expected <name> is ncurses or ncursesw.
+dnl
+AC_DEFUN([UL_NCURSES_CHECK], [
+  m4_define([suffix], $1)
+
+  # ncurses-config should be everywhere, pkg-config is not supported by default
+  # by ncurses upstream
+  #
+  AC_MSG_CHECKING([$1])
+  if AC_RUN_LOG([suffix[]6-config --version >/dev/null]); then
+    have_[]suffix=yes
+    NCURSES_LIBS=`suffix[]6-config --libs`
+    NCURSES_CFLAGS=`suffix[]6-config --cflags`
+    AC_MSG_RESULT([(v6) yes])
+  elif AC_RUN_LOG([suffix[]5-config --version 2>/dev/null]); then
+    have_[]suffix=yes
+    NCURSES_LIBS=`suffix[]5-config --libs`
+    NCURSES_CFLAGS=`suffix[]5-config --cflags`
+    AC_MSG_RESULT([(v5) yes])
+  else
+    AC_MSG_RESULT([no])
+
+    # fallback
+    AC_CHECK_LIB([$1], [initscr], [have_[]suffix=yes], [have_[]suffix=no])
+    AS_IF([test "x$have_[]suffix" = xyes], [
+      NCURSES_LIBS="-l[]suffix"
+    ])
+  fi
+])