diff options
author | Mike Frysinger | 2013-09-29 06:44:43 +0200 |
---|---|---|
committer | Karel Zak | 2013-09-30 13:41:07 +0200 |
commit | 2b8f22bd90f8074c714afaa872c314287e54a9a6 (patch) | |
tree | 10ed8a0302cbc37aa0c3e904dea6f92e6ae7ce1b /configure.ac | |
parent | setterm: fix term.h/ncurses.h include ordering (diff) | |
download | kernel-qcow2-util-linux-2b8f22bd90f8074c714afaa872c314287e54a9a6.tar.gz kernel-qcow2-util-linux-2b8f22bd90f8074c714afaa872c314287e54a9a6.tar.xz kernel-qcow2-util-linux-2b8f22bd90f8074c714afaa872c314287e54a9a6.zip |
clean up term lib handling
The ncurses package has been providing pkg-config files for a while now.
So let's start using them to get the proper linker & compiler flags. It
can make a difference when ncurses is configured in a way that requires
extra link time flags but util-linux doesn't provide them, or when the
headers live in a weird place and util-linux can't find them.
Since the NCURSES_LIBS is always defined for the Makefile, there's no need
to gate on the HAVE_NCURSES conditional. When it's disabled, the var will
simply be empty.
With a minor tweak to how tinfo is handled, we can do the same thing -- we
just always use TINFO_LIBS in the Makefile's.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac index 098692c9f..c7c66bcd8 100644 --- a/configure.ac +++ b/configure.ac @@ -595,25 +595,50 @@ AM_CONDITIONAL([HAVE_NCURSES], [false]) AS_IF([test "x$with_ncurses" != xno], [ have_ncurses=no - AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h], [ - AS_IF([test "x$with_ncurses" = xauto], [ - UL_CHECK_LIB([ncursesw], [initscr], [ncurses]) - AS_IF([test "x$have_ncurses" = xyes], [ - AC_CHECK_HEADERS([ncursesw/ncurses.h]) - NCURSES_LIBS="-lncursesw" + + dnl First try to find the pkg-config module. + PKG_CHECK_MODULES(NCURSESW, [ncursesw], [ + have_ncurses=yes + NCURSES_LIBS=${NCURSESW_LIBS} + NCURSES_CFLAGS=${NCURSESW_CFLAGS} + AC_DEFINE([HAVE_LIBNCURSESW]) + ], [ + PKG_CHECK_MODULES(NCURSES, [ncurses], [ + have_ncurses=yes + AC_DEFINE([HAVE_LIBNCURSES]) + ], [:]) + ]) + + AS_IF([test "x$have_ncurses" = xyes], [ + dnl If that worked, setup the defines that the code expects. + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $NCURSES_CFLAGS" + AC_CHECK_HEADERS([ncurses.h]) + CPPFLAGS="$save_CPPFLAGS" + ], [ + dnl If that failed, fall back to classic searching. + AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h], [ + AS_IF([test "x$with_ncurses" = xauto], [ + UL_CHECK_LIB([ncursesw], [initscr], [ncurses]) + AS_IF([test "x$have_ncurses" = xyes], [ + AC_CHECK_HEADERS([ncursesw/ncurses.h]) + NCURSES_LIBS="-lncursesw" + ]) ]) - ]) - AS_IF([test "x$have_ncurses" = xno], [ - UL_CHECK_LIB(ncurses, initscr) - AS_IF([test "x$have_ncurses" = xyes], [ - NCURSES_LIBS="-lncurses" + AS_IF([test "x$have_ncurses" = xno], [ + UL_CHECK_LIB(ncurses, initscr) + AS_IF([test "x$have_ncurses" = xyes], [ + NCURSES_LIBS="-lncurses" + ]) ]) ]) ]) + AS_IF([test "x$have_ncurses" = xno], [ AC_MSG_ERROR([ncurses or ncursesw selected, but library not found (--without-ncurses to disable)]) ]) ]) +AC_SUBST([NCURSES_CFLAGS]) AC_SUBST([NCURSES_LIBS]) @@ -642,9 +667,11 @@ AM_CONDITIONAL([HAVE_SLANG], [test "x$have_slang" = xyes]) AM_CONDITIONAL([BUILD_CFDISK], [test "x$have_slang" = xyes -o "x$have_ncurses" = xyes]) -have_tinfo=no AC_CHECK_LIB([tinfo], [tgetent], [have_tinfo=yes]) -AM_CONDITIONAL([HAVE_TINFO], [test "x$have_tinfo" = xyes]) +AS_IF([test "x$have_tinfo" = xyes], [ + TINFO_LIBS="-ltinfo" +]) +AC_SUBST([TINFO_LIBS]) AC_ARG_WITH([utempter], |