diff --git a/m4/dune_common.m4 b/m4/dune_common.m4
index d6e9ea3b080176e50e953af910b7b3cb41c316d7..7b73c716f85d78a1a725cd515abb6cf479b93a12 100644
--- a/m4/dune_common.m4
+++ b/m4/dune_common.m4
@@ -23,7 +23,6 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
   AC_REQUIRE([DUNE_SET_MINIMAL_DEBUG_LEVEL])
   AC_REQUIRE([DUNE_PATH_XDR])
   AC_REQUIRE([DUNE_MPI])
-  DUNE_ADD_ALL_PKG([MPI], [$DUNEMPICPPFLAGS], [$DUNEMPILDFLAGS], [$DUNEMPILIBS])
   AC_REQUIRE([DUNE_EXPRTMPL])
   AC_REQUIRE([DUNE_DEV_MODE])
 
diff --git a/m4/dune_mpi.m4 b/m4/dune_mpi.m4
index 96128b6c09b40abc93a73827723f833263867beb..47f5d6e3a31686b8a0a9d30546afc50720841649 100644
--- a/m4/dune_mpi.m4
+++ b/m4/dune_mpi.m4
@@ -69,6 +69,9 @@ dnl -*- autoconf -*-
 #   dune_MPI_VERSION
 #   with_mpi ("no" if MPI is missing, "yes" followed by some more details if
 #             MPI is present)
+#   ALL_PKG_CPPFLAGS (adds its stuff here)
+#   ALL_PKG_LDFLAGS (adds its stuff here)
+#   ALL_PKG_LIBS (adds its stuff here)
 #
 # configure substitutions/Makefile variables
 #   MPICC
@@ -212,6 +215,8 @@ AC_DEFUN([DUNE_MPI],[
     [The MPI_CPPFLAGS configure substitute is deprecated.  Please change your Makefile.am to use DUNEMPICPPFLAGS instead.  Note that it is a good idea to change any occurance of MPI_LDFLAGS into DUNEMPILIBS and DUNEMPILDFLAGS as apropriate, since it is not possible to issue a deprecation warning in that case.])
   AC_SUBST(MPI_LDFLAGS)
 
+  DUNE_ADD_ALL_PKG([MPI], [$DUNEMPICPPFLAGS], [$DUNEMPILDFLAGS], [$DUNEMPILIBS])
+
   AM_CONDITIONAL(MPI, [test "x$with_mpi" != "xno"])
 
   DUNE_ADD_SUMMARY_ENTRY([MPI],[$with_mpi])
diff --git a/m4/opengl.m4 b/m4/opengl.m4
index 33ebac3c7a4c592fd542de414f701fd751d3bd49..9c0134b239c863d1d070cda5f03810cd7e3441a3 100644
--- a/m4/opengl.m4
+++ b/m4/opengl.m4
@@ -1,6 +1,11 @@
+## -*- autoconf -*-
 # $Id$
 # searches for OpenGL-stuff
 
+# DUNE_PATH_OPENGL()
+#
+# Call AX_CHECK_OPENGL, but also add the discovered flags too the ALL_PKG_*
+# family and add a summary entry.  Also make sure that pthreads are supported.
 AC_DEFUN([DUNE_PATH_OPENGL],[
 dnl use test from autoconf-archive
   AC_REQUIRE([AX_CHECK_GL])
@@ -15,6 +20,10 @@ dnl use test from autoconf-archive
 
     # need pthreads-stuff in linker commandline as well
     AC_SUBST(GL_LDFLAGS, $PTHREAD_CFLAGS)
+    # GL_CFLAGS contain stuff like -pthread, which according to the gcc
+    # documentation is a flag for both the preprocessor and the linker.  So we
+    # add it to the preprocessor flags here.
+    DUNE_ADD_ALL_PKG([GL], [$GL_CFLAGS], [$GL_LDFLAGS], [$GL_LIBS])
   fi
 
   DUNE_ADD_SUMMARY_ENTRY([OpenGL],[$with_opengl])