Fix: Build: respect ncurses lib flags

Configure should detect ncurses' link flags and respect them to avoid compilation failure.

I used pkg-config to do so, maybe there may be a less ugly way but it works.

More info : https://bugs.gentoo.org/show_bug.cgi?id=526770