Change handling of libraries and cflags, add option for pkg-config