With continued problems in #5157, this time with regards to Slackware Linux, this revision expands on the scope of D1582 and tries to use pkg-config where possible.
For example, the X11 include-paths had been hard-coded as a list of possible locations, some of which existed on some distros, but not on others. This then presented a problem when some of those paths were soft-links to other paths, ie. /usr/X11R6/include is equivalent to /usr/include on Slackware.
As another example, gloox has its own config program: gloox-config. When run with the appropriate argument (--cflags) this was returning /usr/include, a directory that is included by default by gcc anyway and, as mentioned in D1582, a directory that if included too early causes problems.
In both instances, and in fact all instances below, a call to pkg-config has been used instead where possible. Unlike the hard-coding and (most) library-specific programs, pkg-config appears to take into account system headers included by gcc, thus preventing over-inclusion of certain files.
Depends on D1582
An earlier version of this changeset was confirmed to permit successful compilation on Slackware-current by @andy5995 over at #5157