diff --git a/libs/gst/check/libcheck/check.c b/libs/gst/check/libcheck/check.c
index 95de673..731e522 100644
--- a/libs/gst/check/libcheck/check.c
+++ b/libs/gst/check/libcheck/check.c
@@ -18,14 +18,13 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <math.h>
-#include <time.h>
 
 #include "check.h"
 #include "check_error.h"
@@ -33,10 +32,6 @@
 #include "check_impl.h"
 #include "check_msg.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>             /* for _POSIX_VERSION */
-#endif
-
 #ifndef DEFAULT_TIMEOUT
 #define DEFAULT_TIMEOUT 4
 #endif
diff --git a/libs/gst/check/libcheck/check.h.in b/libs/gst/check/libcheck/check.h.in
index a40a92f..4524c6c 100644
--- a/libs/gst/check/libcheck/check.h.in
+++ b/libs/gst/check/libcheck/check.h.in
@@ -25,6 +25,8 @@
 #include <stddef.h>
 #include <string.h>
 
+#include <check_stdint.h>
+
 /* Check: a unit test framework for C
 
    Check is a unit test framework for C. It features a simple
diff --git a/libs/gst/check/libcheck/check_error.c b/libs/gst/check/libcheck/check_error.c
index 7f676dc..52cbc18 100644
--- a/libs/gst/check/libcheck/check_error.c
+++ b/libs/gst/check/libcheck/check_error.c
@@ -18,7 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <stdarg.h>
 #include <stdlib.h>
diff --git a/libs/gst/check/libcheck/check_error.h b/libs/gst/check/libcheck/check_error.h
index 8dd069b..0176553 100644
--- a/libs/gst/check/libcheck/check_error.h
+++ b/libs/gst/check/libcheck/check_error.h
@@ -21,8 +21,9 @@
 #ifndef ERROR_H
 #define ERROR_H
 
+#include "../lib/libcompat.h"
 #include <setjmp.h>
-#include "check.h"
+
 extern jmp_buf error_jmp_buffer;
 
 /* Include stdlib.h beforehand */
@@ -30,9 +31,10 @@ extern jmp_buf error_jmp_buffer;
 /* Print error message and die
    If fmt ends in colon, include system error information */
 void
-eprintf (const char *fmt, const char *file, int line, ...) CK_ATTRIBUTE_NORETURN;
+eprintf (const char *fmt, const char *file, int line, ...)
+    CK_ATTRIBUTE_NORETURN;
 /* malloc or die */
-void *emalloc (size_t n);
-void *erealloc (void *, size_t n);
+     void *emalloc (size_t n);
+     void *erealloc (void *, size_t n);
 
 #endif /*ERROR_H */
diff --git a/libs/gst/check/libcheck/check_list.c b/libs/gst/check/libcheck/check_list.c
index fd4131f..e8ab863 100644
--- a/libs/gst/check/libcheck/check_list.c
+++ b/libs/gst/check/libcheck/check_list.c
@@ -18,7 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/libs/gst/check/libcheck/check_log.c b/libs/gst/check/libcheck/check_log.c
index affc42a..26c4e7a 100644
--- a/libs/gst/check/libcheck/check_log.c
+++ b/libs/gst/check/libcheck/check_log.c
@@ -18,14 +18,10 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <stdlib.h>
 #include <stdio.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#include <time.h>
 #include <check.h>
 #if ENABLE_SUBUNIT
 #include <subunit/child.h>
@@ -38,20 +34,6 @@
 #include "check_print.h"
 #include "check_str.h"
 
-/* localtime_r is apparently not available on Windows */
-#ifndef HAVE_LOCALTIME_R
-static struct tm *
-localtime_r (const time_t * clock, struct tm *result)
-{
-  struct tm *now = localtime (clock);
-  if (now == NULL) {
-    return NULL;
-  } else {
-    *result = *now;
-  }
-  return result;
-}
-#endif /* HAVE_DECL_LOCALTIME_R */
 
 static void srunner_send_evt (SRunner * sr, void *obj, enum cl_event evt);
 
diff --git a/libs/gst/check/libcheck/check_msg.c b/libs/gst/check/libcheck/check_msg.c
index c6a1d4d..a1f9238 100644
--- a/libs/gst/check/libcheck/check_msg.c
+++ b/libs/gst/check/libcheck/check_msg.c
@@ -18,12 +18,9 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <stdio.h>
diff --git a/libs/gst/check/libcheck/check_pack.c b/libs/gst/check/libcheck/check_pack.c
index 8d23f9d..c506971 100644
--- a/libs/gst/check/libcheck/check_pack.c
+++ b/libs/gst/check/libcheck/check_pack.c
@@ -18,28 +18,19 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include "_stdint.h"
-
 #include "check.h"
 #include "check_error.h"
 #include "check_list.h"
 #include "check_impl.h"
 #include "check_pack.h"
 
-#ifdef HAVE_PTHREAD
-#include <pthread.h>
-pthread_mutex_t lock_mutex = PTHREAD_MUTEX_INITIALIZER;
-#else
+#ifndef HAVE_PTHREAD
 #define pthread_mutex_lock(arg)
 #define pthread_mutex_unlock(arg)
 #define pthread_cleanup_push(f,a) {
diff --git a/libs/gst/check/libcheck/check_print.c b/libs/gst/check/libcheck/check_print.c
index 21f43a0..93a08c7 100644
--- a/libs/gst/check/libcheck/check_print.c
+++ b/libs/gst/check/libcheck/check_print.c
@@ -18,7 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/libs/gst/check/libcheck/check_run.c b/libs/gst/check/libcheck/check_run.c
index cd34da6..297de2b 100644
--- a/libs/gst/check/libcheck/check_run.c
+++ b/libs/gst/check/libcheck/check_run.c
@@ -18,15 +18,9 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <sys/types.h>
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <time.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/libs/gst/check/libcheck/check_str.c b/libs/gst/check/libcheck/check_str.c
index 65f413b..c1a82f8 100644
--- a/libs/gst/check/libcheck/check_str.c
+++ b/libs/gst/check/libcheck/check_str.c
@@ -18,7 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include "config.h"
+#include "../lib/libcompat.h"
 
 #include <stdio.h>
 #include <stdarg.h>
