diff --git a/config.guess b/config.guess
index 31e01ef..c1feb09 100755
--- a/config.guess
+++ b/config.guess
@@ -1401,6 +1401,16 @@ EOF
     amd64:Isilon\ OneFS:*:*)
 	echo x86_64-unknown-onefs
 	exit ;;
+    *:MidnightBSD:*:*)
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
+	case ${UNAME_PROCESSOR} in
+	    amd64)
+		UNAME_PROCESSOR=x86_64 ;;
+	    i386)
+		UNAME_PROCESSOR=i586 ;;
+	esac
+	echo ${UNAME_PROCESSOR}-unknown-midnightbsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit ;;
 esac
 
 echo "$0: unable to guess system type" >&2
diff --git a/config.sub b/config.sub
index 00f68b8..6ca42a5 100755
--- a/config.sub
+++ b/config.sub
@@ -1416,7 +1416,8 @@ case $os in
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
 	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
-	      | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*)
+	      | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* \
+	      | -midnightbsd* )
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
