Switch to CMake

I've tested on Linux, OSX and Cygwin, but please help with testing your favorite configurations and report any issues found.

This change provides a configure wrapper script to make it almost backwards compatible with the old build system. See `configure --help` for details.

What comes to the build flags, it's not 100% identical with the old ones. Some of the platform specific build flags collected over the last decade were intentionally left behind. The latest ZNC requires a modern toolchain that supports C++11 anyway, so many of those old exotic flags are probably no longer even needed. The idea is to let CMake as a cross-platform to specify the correct flags, mostly.

The proposal also changes the structure a bit. After struggling with the damn object files for a good while, I decided to propose building the core as a library instead, like it was already done on Cygwin. I strongly believe this is the right direction to go in the future (see #210 and [Wiki](http://wiki.znc.in/Ideas)).

/cc @samuelgaist
> And what is the big picture?

Maintainability to start with. Portability (both, platforms and toolchains) comes as a bonus. Did I already mention this? :)

> The devil is in the details...

Reviewing all the little details is important, thanks for all the effort with
that so far, but perhaps not every little difference to the current build system
needs to be considered a blocker. Both have their pros and cons.

> Checking for availability of a function in C when we'll use that function
> in C++ is weird, at least, and sometimes it can hurt.

Would it be something that you would be able to live with for the time being?
CMake is actively developed, so simply reporting the issue could be a viable
option.

> I can't say that I like the script which downloads cmake

If it was up to me, I'd leave out the whole thing. CMake is popular enough,
and for most users, local installation is trivial thanks to the binary packages.

> You mentioned limiting visible symbols for stable ABI...  It boils down to
> set of flags for gcc. Or cmake can do it easier way?

There's a portable way. I'd let CMake generate export macros.