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])
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],
usrbin_exec_PROGRAMS += pg
dist_man_MANS += text-utils/pg.1
pg_SOURCES = text-utils/pg.c
-pg_CFLAGS = $(AM_CFLAGS) $(BSD_WARN_CFLAGS)
-pg_LDADD = $(LDADD) libcommon.la @NCURSES_LIBS@
-if HAVE_TINFO
-pg_LDADD += -ltinfo
-endif
+pg_CFLAGS = $(AM_CFLAGS) $(BSD_WARN_CFLAGS) $(NCURSES_CFLAGS)
+pg_LDADD = $(LDADD) libcommon.la $(NCURSES_LIBS) $(TINFO_LIBS)
endif # BUILD_PG
usrbin_exec_PROGRAMS += ul
dist_man_MANS += text-utils/ul.1
ul_SOURCES = text-utils/ul.c
-ul_LDADD = $(LDADD)
-if HAVE_TINFO
-ul_LDADD += -ltinfo
-else
-ul_LDADD += @NCURSES_LIBS@
-endif
+ul_CFLAGS = $(AM_CFLAGS) $(NCURSES_CFLAGS)
+ul_LDADD = $(LDADD) $(NCURSES_LIBS) $(TINFO_LIBS)
endif # BUILD_UL
bin_PROGRAMS += more
dist_man_MANS += text-utils/more.1
more_SOURCES = text-utils/more.c
-more_CFLAGS = $(AM_CFLAGS) $(BSD_WARN_CFLAGS)
-more_LDADD = $(LDADD)
-if HAVE_TINFO
-more_LDADD += -ltinfo
-else
-if HAVE_NCURSES
-more_LDADD += @NCURSES_LIBS@
-else
+more_CFLAGS = $(AM_CFLAGS) $(BSD_WARN_CFLAGS) $(NCURSES_CFLAGS)
+more_LDADD = $(LDADD) $(NCURSES_LIBS) $(TINFO_LIBS)
+if HAVE_TERMCAP
more_LDADD += -ltermcap
endif
-endif
check_PROGRAMS += test_more
test_more_SOURCES = $(more_SOURCES)