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
I'm aware that i386 binary usually can be run on x86_64 machine ;) I'm
saying about ARM, PowerPC, etc.
As an optimization for Linux x86 case, prebuild i386 cmake can be used,
yeah.


2014-09-05 9:13 GMT+01:00 J-P Nurmi <notifications@github.com>:

> In configure:
>
> > +		exit 0
> > +		;;
> > +	*)
> > +		error "Unknown option: $key"
> > +		;;
> > +	esac
> > +	shift
> > +	if $shift_twice; then
> > +		shift
> > +		shift_twice=false
> > +	fi
> > +done
> > +
> > +#Check if CMake is in $PATH
> > +if ! which cmake > /dev/null; then
> > +	error "cmake not found" 1
>
> It doesn't matter if the prebuilt cmake is 32-bit, because it merely
> generates makefiles. A 64-bit system just needs 32-bit support
> libraries/runtimes for running the cmake executable, but the build product
> for a 64-bit compiler is, well, 64-bit. :) I'm just saying that if the
> 32-bit support is there but a non-admin user is missing cmake, grabbing the
> prebuilt binary must be the fastest and easiest way to get it.
>
> We could fairly well write a helper script to assist with all this, and we
> can trigger it from configure if no cmake is detected. Something like uname
> -m and uname -s for detection and offer to
> download/extract/configure/build the appropriate package. I don't know if
> there's a nice and universal way to test the presence of 32-bit support
> libs on 64-bit systems, but we can offer to download a source package by
> default and let the user choose.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/znc/znc/pull/648/files#r17161048>.
>