--- /dev/null
+diff --git a/boottime.c b/boottime.c
+index f75af3e..843aeca 100644
+--- a/boottime.c
++++ b/boottime.c
+@@ -47,6 +47,14 @@
+ # include <sys/sysctl.h>
+ #endif
+
++/* Must be included above "compat.h"!! */
++#if defined(HAVE_GETUTXID)
++#include <utmpx.h>
++#elif defined(HAVE_GETUTID)
++#include <utmp.h>
++#else
++#endif
++
+ #include "compat.h"
+ #include "missing.h"
+
+@@ -102,7 +110,6 @@ get_boottime(tv)
+
+ #elif defined(HAVE_GETUTXID)
+
+-#include <utmpx.h>
+ int
+ get_boottime(tv)
+ struct timeval *tv;
+@@ -121,7 +128,6 @@ get_boottime(tv)
+
+ #elif defined(HAVE_GETUTID)
+
+-#include <utmp.h>
+ int
+ get_boottime(tv)
+ struct timeval *tv;