summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2017-05-30 17:10:40 +0200
committerKarel Zak2017-05-30 17:14:46 +0200
commit18451b2cf47191aa5f87d8829f9de22a52eca2e1 (patch)
tree9ec6103a1f6cfb7f3f5e4cdc867ab72b3d491159
parentlib/colors: ncurses cleanup (diff)
downloadkernel-qcow2-util-linux-18451b2cf47191aa5f87d8829f9de22a52eca2e1.tar.gz
kernel-qcow2-util-linux-18451b2cf47191aa5f87d8829f9de22a52eca2e1.tar.xz
kernel-qcow2-util-linux-18451b2cf47191aa5f87d8829f9de22a52eca2e1.zip
cal: ncurses cleanup
* use proper paths to term.h * keep ncurses support optional * link with TINFO_LIBS (-ltinfo), or fallback to NCURSES_LIBS (-ltinfo -lncurses) * don't include unnecessary ncurses.h (term.h is enough) Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--misc-utils/Makemodule.am14
-rw-r--r--misc-utils/cal.c15
2 files changed, 20 insertions, 9 deletions
diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am
index 2a159aa41..f28261c8b 100644
--- a/misc-utils/Makemodule.am
+++ b/misc-utils/Makemodule.am
@@ -2,8 +2,18 @@ if BUILD_CAL
usrbin_exec_PROGRAMS += cal
dist_man_MANS += misc-utils/cal.1
cal_SOURCES = misc-utils/cal.c
-cal_CFLAGS = $(AM_CFLAGS) $(NCURSES_CFLAGS)
-cal_LDADD = $(LDADD) libcommon.la libtcolors.la $(NCURSES_LIBS)
+cal_CFLAGS = $(AM_CFLAGS)
+cal_LDADD = $(LDADD) libcommon.la libtcolors.la
+# tinfo or ncurses are optional
+if HAVE_TINFO
+cal_LDADD += $(TINFO_LIBS)
+cal_CFLAGS += $(TINFO_CFLAGS)
+else
+if HAVE_NCURSES
+cal_LDADD += $(NCURSES_LIBS)
+cal_CFLAGS += $(NCURSES_CFLAGS)
+endif
+endif # !HAVE_TINFO
endif # BUILD_CAL
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 68c2a3da9..2b16979db 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -80,12 +80,13 @@ static int has_term = 0;
static const char *Senter = "", *Sexit = ""; /* enter and exit standout mode */
#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW)
-# ifdef HAVE_NCURSES_H
-# include <ncurses.h>
-# elif defined(HAVE_NCURSES_NCURSES_H)
-# include <ncurses/ncurses.h>
+# ifdef HAVE_TERM_H
+# include <term.h>
+# elif defined(HAVE_NCURSES_TERM_H)
+# include <ncurses/term.h>
+# elif defined(HAVE_NCURSESW_TERM_H)
+# include <ncursesw/term.h>
# endif
-# include <term.h>
#endif
static int setup_terminal(char *term
@@ -97,7 +98,7 @@ static int setup_terminal(char *term
#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW)
int ret;
- if (setupterm(term, STDOUT_FILENO, &ret) != OK || ret != 1)
+ if (setupterm(term, STDOUT_FILENO, &ret) != 0 || ret != 1)
return -1;
#endif
return 0;
@@ -114,7 +115,7 @@ static void my_putstring(char *s)
}
static const char *my_tgetstr(char *ss
- #if !defined(HAVE_LIBNCURSES) && !defined(HAVE_LIBNCURSESW)
+#if !defined(HAVE_LIBNCURSES) && !defined(HAVE_LIBNCURSESW)
__attribute__((__unused__))
#endif
)