*pop* AC_LANG after pushing it

rather than *push* it twice...
use AC_LINK_IFELSE to detect needed OpenGL-libraries

AC_SEARCH_LIBS does some over-simplification (by providing it's own
function declaration of glBegin(), which might *not* be compatible with the
function implementation provided by the actual lib), which makes
this test fail on MinGW.

with AC_LINK_IFELSE, we can use a "real" program, including proper includes.
use AC_LINK_IFELSE to detect needed GLU-libraries

AC_SEARCH_LIBS does some over-simplification (by providing it's own
function declaration of gluBeginCurve(), which might *not* be compatible
with the function implementation provided by the actual lib), which makes
this test fail on MinGW.

with AC_LINK_IFELSE, we can use a "real" program, including proper includes.
on MinGW, try "-lpthread" first

as "-pthread" will only set the CFLAGS and leave LIBS untouched,
which results in a linker error (with separate compilation/linking stages)
fix substitute name for "GEM_THREAD_FLAGS"

no use to export "GEM_PTHREAD_CFLAGS" when we only modify "GEM_THREADS_CFLAGS"
added GEM_THREADS_* flags (core)

some Gem-modules require threading, so we need to add GEM_THREADS_* flags
added GEM_THREADS_* flags (plugins)

some Gem-plugins require threading, so we need to add GEM_THREADS_* flags