for readline detection is actually linked against -ltermcap -lreadline. Also add other term libs and finally prefer ncurses over the rest.