diff --git a/main/asterisk.c b/main/asterisk.c
index ccacc6aa6d1b0e78f34db1c17ac6f8cc603ca78f..9b8b3f78a1e322d7cdc98dad36fac7a51b6de552 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -81,8 +81,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #elif defined(HAVE_SYSCTL)
 #include <sys/param.h>
 #include <sys/sysctl.h>
+#if defined(HAVE_SWAPCTL)
 #include <sys/swap.h>
 #endif
+#endif
 #include <regex.h>
 
 #if defined(SOLARIS)