Remove trailing whitespace
Prefer dynamic libs for security
Respect system CXXFLAGS

Especially source distros will have to patch this downstream,
since -Os, -ggdb etc are intrusive flags which are expected to
be set by the user. 'CXXFLAGS?=' only sets these if there is no
CXXFLAGS in the env.
Respect system LDFLAGS

Without '+=' any system/env LDFLAGS such as -Wl,-O1
would get ignored.
Respect CXXFLAGS in linking command

Even if all objects have been compiled directly, there are a lot
of flags that can affect both object compilation and linking.
The current standard in most build systems therefor is to just
include CFLAGS/CXXFLAGS in all linking commands as well.
Prefer pkg-config if available

pkg-config is a cross-distro interface for build systems to
get the correct libs/cflags of a library you want to build against.
In case it is not existent, we fall back to the previous logic.
Fix parallel build
Add 'make check' target
Add PHONY
Also pick up pkg-config from env
Merge pull request #25 from hasufell/master

some build system improvements