Re: [PATCH] build-sys: use ncursesw (wide version) when possibe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 08, 2008 at 08:03:58AM -0500, Mike Frysinger wrote:
> On Tuesday 04 March 2008, Karel Zak wrote:
> > +  if test x$with_ncurses = xauto; then
> > +    if test x$have_ncurses = xyes; then
> > +  if test x$have_ncurses = xno; then
> > +    if test x$have_ncurses = xyes; then
> > +if test x$have_ncurses = xno; then
> 
> the problem with underquoting user supplied variables is confusing errors at 
> configure time:
> ./configure --with-ncurses="moo cow"
> that'll get you ugly/confusing complaints from test iirc
> 
> (perhaps a more realistic case is if someone attempts to specify a path with 
> spaces in it)

 Well, ./configure --help doesn't suggest to use any other argument
 than yes/no. But I agree that the configure script should be more
 robust. Fixed. (I'm going to fix all $with_ and $enable_ tests too.)

 The previous version also didn't support --without-ncurses (to
 disable all ncurses/ncursesw support). Fixed.

 Thanks for your feedback.

    Karel


>From db9adb151002f04c0028527b97ba57ec88da351f Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@xxxxxxxxxx>
Date: Wed, 5 Mar 2008 00:53:24 +0100
Subject: [PATCH] build-sys: use ncursesw (wide version) when possibe

Detect ncursesw and use it in place of ncurses when possible
(default).  Allow people to use classic (non-wide) version by
--with-ncurses or disable all ncurses/ncursesw support by
--without-ncurses.

Co-Author: Mike Frysinger <vapier@xxxxxxxxxx>
Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>
---
 configure.ac           |   41 +++++++++++++++++++++++++++++------------
 fdisk/Makefile.am      |    2 +-
 misc-utils/Makefile.am |    6 +++---
 text-utils/Makefile.am |    8 ++++----
 4 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/configure.ac b/configure.ac
index 50e8b6f..6ca6ec0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -196,18 +196,35 @@ else
     ALL_LINGUAS="af am ar as be bg bn_IN bn ca cs cy da de el en_GB es et eu_ES fa fi fr gl gu he hi hr hu hy id is it ja ka kn ko ku lo lt lv mk ml mr ms my nb nl nn no nso or pa pl pt_BR pt ro ru si sk sl sq sr@Latn sr sv ta te th tr uk ur vi zh_CN zh_TW zu"
 fi
 
-have_ncurses=no
-AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h], [have_ncurses=yes])
-case $have_ncurses in
-yes)
-     AC_MSG_NOTICE([you have ncurses])
-     AC_DEFINE(HAVE_NCURSES, 1, [Do we have -lncurses?])
-     ;;
-no)
-     AC_MSG_NOTICE([you do not have ncurses])
-     ;;
-esac
-AM_CONDITIONAL(HAVE_NCURSES, test x$have_ncurses = xyes)
+AC_ARG_WITH([ncurses],
+  AS_HELP_STRING([--with-ncurses], [build with non-wide ncurses, default is wide version
+                                    (--without-ncurses disables all ncurses(w) support)]),
+  [], with_ncurses=auto
+)
+AM_CONDITIONAL(HAVE_NCURSES, false)
+
+if test "x$with_ncurses" != xno; then
+  have_ncurses=no
+  AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h], [
+    if test "x$with_ncurses" = xauto; then
+      UTIL_CHECK_LIB(ncursesw, tputs, ncurses)
+      if test "x$have_ncurses" = xyes; then
+        NCURSES_LIBS="-lncursesw"
+      fi
+    fi
+    if test x$have_ncurses = xno; then
+      UTIL_CHECK_LIB(ncurses, tputs)
+      if test x$have_ncurses = xyes; then
+        NCURSES_LIBS="-lncurses"
+      fi
+    fi
+  ])
+  if test x$have_ncurses = xno; then
+    AC_MSG_ERROR([ncurses or ncursesw selected, but library not found (--without-ncurses to disable)])
+  fi
+fi
+AC_SUBST([NCURSES_LIBS])
+
 
 AC_ARG_WITH([slang],
   AS_HELP_STRING([--with-slang], [compile cfdisk with slang]),
diff --git a/fdisk/Makefile.am b/fdisk/Makefile.am
index 3b9dec5..921563f 100644
--- a/fdisk/Makefile.am
+++ b/fdisk/Makefile.am
@@ -42,7 +42,7 @@ if HAVE_NCURSES
 sbin_PROGRAMS += cfdisk
 dist_man_MANS += cfdisk.8
 cfdisk_SOURCES = cfdisk.c $(fdisk_common)
-cfdisk_LDADD = -lncurses
+cfdisk_LDADD = @NCURSES_LIBS@
 endif
 endif
 
diff --git a/misc-utils/Makefile.am b/misc-utils/Makefile.am
index b799462..5441b01 100644
--- a/misc-utils/Makefile.am
+++ b/misc-utils/Makefile.am
@@ -18,10 +18,10 @@ dist_man_MANS = cal.1 chkdupexe.1 ddate.1 logger.1 look.1 mcookie.1 \
 	namei.1 script.1 whereis.1 scriptreplay.1
 
 if HAVE_TINFO
-cal_LDADD = -ltinfo -lncurses
+cal_LDADD = -ltinfo @NCURSES_LIBS@
 else
 if HAVE_NCURSES
-cal_LDADD = -lncurses
+cal_LDADD = @NCURSES_LIBS@
 else
 if HAVE_TERMCAP
 cal_LDADD = -ltermcap
@@ -41,7 +41,7 @@ endif
 if HAVE_TINFO
 setterm_LDADD = -ltinfo
 else
-setterm_LDADD = -lncurses
+setterm_LDADD = @NCURSES_LIBS@
 endif
 endif
 
diff --git a/text-utils/Makefile.am b/text-utils/Makefile.am
index d93af72..7c724ae 100644
--- a/text-utils/Makefile.am
+++ b/text-utils/Makefile.am
@@ -14,12 +14,12 @@ bin_PROGRAMS = more
 usrbinexec_PROGRAMS += ul pg
 if HAVE_TINFO
 more_LDADD = -ltinfo
-pg_LDADD = -ltinfo -lncurses
+pg_LDADD = -ltinfo @NCURSES_LIBS@
 ul_LDADD = -ltinfo
 else
-more_LDADD = -lncurses
-pg_LDADD = -lncurses
-ul_LDADD = -lncurses
+more_LDADD = @NCURSES_LIBS@
+pg_LDADD = @NCURSES_LIBS@
+ul_LDADD = @NCURSES_LIBS@
 endif
 dist_man_MANS += ul.1 more.1 pg.1
 else
-- 
1.5.3.8

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux