From e4836e08ee27dd6b754ead1e0c20bee994d36a5b Mon Sep 17 00:00:00 2001 From: Craig Small Date: Thu, 27 Oct 2011 08:53:55 +1100 Subject: [PATCH] ncurses and configure again Another fix to link properly to ncurses Some minor top fixes Added *~ to gitignore because these files crop up sometimes --- .gitignore | 1 + Makefile.am | 2 +- configure.ac | 41 ++++++++++++----------------------------- top.c | 17 ++++++----------- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index cac09ec3..850614ad 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ uptime vmstat w watch +*~ diff --git a/Makefile.am b/Makefile.am index 9ca3c53b..5338f532 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,7 +42,7 @@ bin_PROGRAMS = kill dist_man_MANS += kill.1 endif -if HAVE_NCURSES +if WITH_NCURSES usrbin_exec_PROGRAMS += \ slabtop \ top \ diff --git a/configure.ac b/configure.ac index 4ed45257..8d33183a 100644 --- a/configure.ac +++ b/configure.ac @@ -92,44 +92,27 @@ AC_CHECK_FUNCS([\ wcwidth ]) -usrbin_execdir='${exec_prefix}/usr/bin' -AC_SUBST([usrbin_execdir]) - -dnl UTIL_CHECK_LIB(LIBRARY, FUNCTION, [VARSUFFIX = $1])) -dnl The VARSUFFIX is optional and overrides the default behaviour. For example: -dnl UTIL_CHECK_LIB(yyy, func, xxx) generates have_xxx and HAVE_LIBXXX -dnl UTIL_CHECK_LIB(yyy, func) generates have_yyy and HAVE_LIBYYY -dnl --------------------------------- -AC_DEFUN([UTIL_CHECK_LIB], [ - m4_define([suffix], m4_default([$3],$1)) - [have_]suffix=yes - m4_ifdef([$3], [AC_CHECK_LIB([$1], [$2], [], [[have_]suffix=no])], []) - AM_CONDITIONAL(AS_TR_CPP([HAVE_]suffix), [test [$have_]suffix = yes]) -]) - AC_ARG_WITH([ncurses], AS_HELP_STRING([--without-ncurses], [build only applications not needing ncurses]), - [], with_ncurses=yes + [with_ncurses=no], [with_ncurses=yes] ) -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" = xyes; then - UTIL_CHECK_LIB(ncursesw, initscr, ncurses) - if test "x$have_ncurses" = xyes; then - AC_CHECK_HEADERS([ncursesw/ncurses.h]) - NCURSES_LIBS="-lncursesw" - fi - fi - ]) +if test "x$with_ncurses" = xno; then + AM_CONDITIONAL(WITH_NCURSES, false) +else + AC_CHECK_LIB(ncursesw, initscr, [have_ncurses=yes], [have_ncurses=no]) + AC_CHECK_HEADERS(ncursesw/ncurses.h, [], [have_ncurses=no]) if test "x$have_ncurses" = xno; then - AC_MSG_ERROR([ncurses selected, but library not found (--without-ncurses to disable)]) + AC_MSG_ERROR([ncurses support missing (for partial build use --without-ncurses)]) fi + AM_CONDITIONAL(WITH_NCURSES, true) + NCURSES_LIBS="-lncursesw" fi AC_SUBST([NCURSES_LIBS]) +usrbin_execdir='${exec_prefix}/usr/bin' +AC_SUBST([usrbin_execdir]) + AC_ARG_ENABLE([kill], AS_HELP_STRING([--disable-kill], [do not build kill]), [], enable_kill=yes diff --git a/top.c b/top.c index 64e794dc..c22d4f00 100644 --- a/top.c +++ b/top.c @@ -3608,20 +3608,15 @@ static int window_show (WIN_t *q, int wmax) { * This guy's just a *Helper* function who apportions the * remaining amount of screen real estate under multiple windows */ static void framehlp (int wix, int max) { - int i, rsvd, size, wins; + int i, size, wins; - // calc remaining number of visible windows + total 'user' lines - for (i = wix, rsvd = 0, wins = 0; i < GROUPSMAX; i++) { - if (CHKw(&Winstk[i], Show_TASKON)) { - rsvd += Winstk[i].rc.maxtasks; + // calc remaining number of visible windows + for (i = wix, wins = 0; i < GROUPSMAX; i++) + if (CHKw(&Winstk[i], Show_TASKON)) ++wins; - if (max <= rsvd) break; - } - } + if (!wins) wins = 1; - // set aside 'rsvd' & deduct 1 line/window for the columns heading - size = (max - wins) - rsvd; - if (0 <= size) size = max; + // deduct 1 line/window for the columns heading size = (max - wins) / wins; /* for subject window, set WIN_t winlines to either the user's -- 2.40.0