I'm not against sorting things out in configure.in, but I'm not quite
sure that it will be more portable than ldd:
On FreeBSD (the problem system!) I can't get this to work:
[stefan@freebsd-i386 ~]$ echo 'int main() { readline(); }' > test_readline.c
[stefan@freebsd-i386 ~]$ gcc -Wl,--warn-common xxx.c -lreadline -ltermcap -lncurses -lncursesw
[stefan@freebsd-i386 ~]$ gcc -Wl,--warn-common xxx.c -lreadline -lncurses -lncursesw
[stefan@freebsd-i386 ~]$ gcc -Wl,--warn-common xxx.c -lreadline -lncursesw
On OpenSolaris with suncc, ld does not have -warn-common.