--- configure.orig	2024-10-21 07:31:57.000000000 -0400
+++ configure	2025-03-26 14:42:15.292076000 -0400
@@ -7298,6 +7298,35 @@
     fi
     ;;
 
+*-midnightbsd*)
+    if test -z "$USE_NSPR_THREADS"; then
+        USE_PTHREADS=1
+    fi
+    printf "%s\n" "#define XP_UNIX 1" >>confdefs.h
+
+    printf "%s\n" "#define FREEBSD 1" >>confdefs.h
+    printf "%s\n" "#define MIDNIGHTBSD 1" >>confdefs.h
+
+    printf "%s\n" "#define HAVE_BSD_FLOCK 1" >>confdefs.h
+
+    printf "%s\n" "#define HAVE_SOCKLEN_T 1" >>confdefs.h
+
+    printf "%s\n" "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
+
+    CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
+    MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
+    if test "$MOZ_OBJFORMAT" = "elf"; then
+        DLL_SUFFIX=so
+    else
+        DLL_SUFFIX=so.1.0
+    fi
+    MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
+    DSO_CFLAGS=-fPIC
+    DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
+    MDCPUCFG_H=_freebsd.cfg
+    PR_MD_CSRCS=freebsd.c
+    ;;
+
 *-freebsd*)
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
@@ -8760,7 +8789,7 @@
 	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 	    ac_cv_have_dash_pthread=yes
 		case "$target_os" in
-	    freebsd*)
+	    freebsd*|midnightbsd*)
 # Freebsd doesn't use -pthread for compiles, it uses them for linking
             ;;
 	    *)
@@ -8798,7 +8827,7 @@
             _PTHREAD_LDFLAGS=
         fi
 	    ;;
-    *-freebsd*)
+    *-freebsd*|*-midnightbsd*)
 	    printf "%s\n" "#define _REENTRANT 1" >>confdefs.h
 
 	    printf "%s\n" "#define _THREAD_SAFE 1" >>confdefs.h
@@ -8875,7 +8904,7 @@
         ;;
     esac
     ;;
-*-freebsd*)
+*-freebsd*|*-midnightbsd*)
     if test -n "$USE_NSPR_THREADS"; then
         printf "%s\n" "#define _PR_LOCAL_THREADS_ONLY 1" >>confdefs.h
 
