diff --git a/src/rusage.c b/src/rusage.c
index 78133d3028ad29f76bb4fc5ee7d8b4769e148961..d6ce21a1b3100e0493ea4bf62375373ceeef448a 100644
--- a/src/rusage.c
+++ b/src/rusage.c
@@ -5,9 +5,13 @@
 \*/
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_SYS_TIME
 #include <sys/time.h>
+#endif
 #include <fcntl.h>
+#ifdef HAVE_TIME
 #include <time.h>
+#endif
 #include <errno.h>
 #include "global.h"
 #include "types.h"