Switch to use pkg-config to detect libevent and openssl

Switching to pkg-config fixes a number of problems when detecting the
libraries. For example the detection of libpthread was failing,
because libevent_threads was added to LIBS before libevent itself,
causing the libpthread test to fail due to missing symbols. pkg-config
is anyway nowadays the preferred way for detecting libraries. It also
has the benefit of working properly in static library situations.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>