use pkg-config to look up ncurses

Hardcoding -ltinfo breaks on distros that do not build the sep library
(which is the default ncurses behavior).  Use pkg-config to look up the
right libraries regardless of how the distro built things.
Rename LIBNCURSES* to LIBTINFO*.

We actually depend on libtinfo or libtermcap, not curses, so
rename the variable.

This updates commit 96add4d5b34daabbae5a2766f564ae98b48cf576.