diff --git a/src/configure.in b/src/configure.in
index a2a383c075c16578354df501edf374950a082296..c7a64cf97658cb6c6a44eb2356323e6d3b17f8a5 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -228,7 +228,7 @@ AC_HEADER_TIME
 AC_HEADER_STDC
 AC_CHECK_HEADERS(sys/rusage.h time.h sys/time.h unistd.h stdlib.h memory.h \
 values.h string.h fcntl.h sys/filio.h sys/sockio.h crypt.h locale.h \
-sys/resource.h sys/select.h sys/mman.h)
+sys/resource.h sys/select.h sys/mman.h setjmp.h)
 
 AC_SIZEOF_TYPE(char *)
 AC_SIZEOF_TYPE(long)
diff --git a/src/error.h b/src/error.h
index 6934591dc88980e22740a574f7e212a00ae0de2f..e10d27037916da4ba1e48bf8f7ab589d536c6250 100644
--- a/src/error.h
+++ b/src/error.h
@@ -6,9 +6,15 @@
 #ifndef ERROR_H
 #define ERROR_H
 
+#include "machine.h"
+
+#ifdef HAVE_SETJMP_H
 #include <setjmp.h>
+#undef HAVE_SETJMP_H
+#endif
+
 #include <stdarg.h>
-#include "machine.h"
+
 #include "svalue.h"