Needed to ensure we pick up definitions from ncurses' pkg-config file
like -DNCURSES_WIDECHAR (issue is observable on say, musl).
--- a/x3270if/Makefile.obj.in
+++ b/x3270if/Makefile.obj.in
@@ -51,9 +51,9 @@ INSTALL_DATA = @INSTALL_DATA@
 
 CCOPTIONS = @CCOPTIONS@
 XCPPFLAGS = -I$(THIS) -I$(TOP)/include -I$(TOP)/Common/x3270if @CPPFLAGS@
-override CFLAGS += $(CCOPTIONS) $(CDEBUGFLAGS) $(XCPPFLAGS) @CFLAGS@
+override CFLAGS += $(CCOPTIONS) $(CDEBUGFLAGS) $(XCPPFLAGS) @ncurses_CFLAGS@ @CFLAGS@
 LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
+LIBS = @LIBS@ @ncurses_LIBS@
 
 XVERSION = xversion.c
 version.o: mkversion.py $(VOBJS) version.txt
--- a/x3270if/configure.in
+++ b/x3270if/configure.in
@@ -76,6 +76,9 @@ if test "$with_readline" != no; then
  fi
  AC_CHECK_HEADERS(readline/history.h)
 fi
+
+dnl Try pkg-config first, and if it fails, try the traditional methods.
+PKG_CHECK_MODULES([ncurses], [ncursesw], [AC_DEFINE([HAVE_NCURSESW_NCURSES_H] ,[1]) AC_DEFINE([HAVE_NCURSESW_TERM_H], [1])], [
 dnl Find the best curses header file and hope it's consistent with the library
 dnl we found.
 AC_CHECK_HEADERS(ncursesw/ncurses.h, ,
@@ -86,15 +89,16 @@ AC_CHECK_HEADERS(ncursesw/term.h, ,
  [AC_CHECK_HEADERS(ncurses/term.h, ,
   [AC_CHECK_HEADERS(term.h)])])
 
+AC_SEARCH_LIBS(newterm, ncursesw ncurses curses, , [AC_MSG_ERROR(Can't find libncurses or new-enough libcurses)])
+AC_SEARCH_LIBS(setupterm, tinfow tinfo, , [AC_MSG_ERROR(Can't find terminfo library)])
+AC_CHECK_FUNCS(tiparm)])
+
 dnl Check for --without-readline
 AC_ARG_WITH(readline, [  --without-readline      Don't use the readline library]) 
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS(vasprintf)
 AC_FUNC_FSEEKO
-AC_SEARCH_LIBS(newterm, ncursesw ncurses curses)
-AC_SEARCH_LIBS(setupterm, tinfow tinfo)
-AC_CHECK_FUNCS(tiparm)
 if test "$with_readline" != no; then
  if test -n "$with_readline" -a "$with_readline" != yes; then
   dnl Use the speficied readline install path.
