Fix up curses detection logic, Solaris fixes

Makes git master compile on Solaris again, and mostly work.
Use the right attribute for __unused with gcc
Include vdef.h for __printflike