--- gettext-tools/configure.orig	2013-08-15 12:31:08.000000000 -0400
+++ gettext-tools/configure	2013-11-27 17:30:32.972893462 -0500
@@ -8478,7 +8478,7 @@
     # need special flags to disable these optimizations. For example, the
     # definition of 'errno' in <errno.h>.
     case "$host_os" in
-      aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
+      aix* | freebsd* | midnightbsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
       solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
     esac
   fi
@@ -9773,7 +9773,7 @@
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly* | midnightbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -10205,7 +10205,7 @@
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | dragonfly*)
+freebsd* | dragonfly* | midnightbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
@@ -14375,7 +14375,7 @@
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly*)
+    freebsd* | dragonfly* | midnightbsd*)
       archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec='-R$libdir'
       hardcode_direct=yes
@@ -15339,7 +15339,7 @@
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
-freebsd* | dragonfly*)
+freebsd* | dragonfly* | midnightbsd*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
   if test -x /usr/bin/objformat; then
@@ -27579,7 +27579,7 @@
   if test "$cross_compiling" = yes; then :
   case "$host_os" in
           # Guess yes on platforms where we know the result.
-          *-gnu* | freebsd* | netbsd* | openbsd* \
+          *-gnu* | midnightbsd* | freebsd* | netbsd* | openbsd* \
           | hpux* | solaris* | cygwin* | mingw*)
             ac_cv_func_malloc_0_nonnull=yes ;;
           # If we don't know, assume the worst.
@@ -29493,7 +29493,7 @@
            *-gnu*)               gl_cv_func_snprintf_retval_c99="guessing yes";;
                                  # Guess yes on FreeBSD >= 5.
            freebsd[1-4]*)        gl_cv_func_snprintf_retval_c99="guessing no";;
-           freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
+           midnightbsd* | freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
                                  # Guess yes on Mac OS X >= 10.3.
            darwin[1-6].*)        gl_cv_func_snprintf_retval_c99="guessing no";;
            darwin*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
@@ -35546,7 +35546,7 @@
            linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
                    # closed fd may yield -EBADF instead of -1 / errno=EBADF.
              gl_cv_func_dup2_works="guessing no" ;;
-           freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
+           midnightbsd* | freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
              gl_cv_func_dup2_works="guessing no" ;;
            haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
              gl_cv_func_dup2_works="guessing no" ;;
@@ -36020,7 +36020,7 @@
     aix* | beos* | openbsd* | mirbsd* | irix*)
       FLOAT_H=float.h
       ;;
-    freebsd*)
+    midnightbsd* | freebsd*)
       case "$host_cpu" in
         i[34567]86 )
           FLOAT_H=float.h
@@ -36054,7 +36054,7 @@
       ;;
   esac
   case "$host_os" in
-    aix* | freebsd* | linux*)
+    aix* | midnightbsd* | freebsd* | linux*)
       if test -n "$FLOAT_H"; then
         REPLACE_FLOAT_LDBL=1
       fi
@@ -41773,7 +41773,7 @@
           if test "$cross_compiling" = yes; then :
 
              case "$host_os" in
-               freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
+               midnightbsd* | freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
                  gl_cv_func_open_slash="guessing no" ;;
                *)
                  gl_cv_func_open_slash="guessing yes" ;;
@@ -56203,7 +56203,7 @@
     aix* | beos* | openbsd* | mirbsd* | irix*)
       FLOAT_H=float.h
       ;;
-    freebsd*)
+    midnightbsd* | freebsd*)
       case "$host_cpu" in
         i[34567]86 )
           FLOAT_H=float.h
@@ -56237,7 +56237,7 @@
       ;;
   esac
   case "$host_os" in
-    aix* | freebsd* | linux*)
+    aix* | midnightbsd* | freebsd* | linux*)
       if test -n "$FLOAT_H"; then
         REPLACE_FLOAT_LDBL=1
       fi
@@ -58284,7 +58284,7 @@
           if test "$cross_compiling" = yes; then :
 
              case "$host_os" in
-               freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
+               midnightbsd* | freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
                  gl_cv_func_open_slash="guessing no" ;;
                *)
                  gl_cv_func_open_slash="guessing yes" ;;
@@ -62754,6 +62754,17 @@
 
 
 case "$host_os" in
+  midnightbsd*)
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BSDXML 1
+#define HAVE_LIBEXPAT 1
+_ACEOF
+
+    LIBEXPAT="-lbsdxml"
+    LTLIBEXPAT="-lbsdxml"
+
+    ;;
   linux*)
 
 $as_echo "#define DYNLOAD_LIBEXPAT 1" >>confdefs.h
@@ -65851,7 +65862,7 @@
         archive_cmds_need_lc_CXX=no
         ;;
 
-      freebsd* | dragonfly*)
+      midnightbsd* | freebsd* | dragonfly*)
         # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
         # conventions
         ld_shlibs_CXX=yes
@@ -66838,7 +66849,7 @@
 	    ;;
 	esac
 	;;
-      freebsd* | dragonfly*)
+      midnightbsd* | freebsd* | dragonfly*)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
@@ -67706,7 +67717,7 @@
   shlibpath_var=LD_LIBRARY_PATH
   ;;
 
-freebsd* | dragonfly*)
+midnightbsd* | freebsd* | dragonfly*)
   # DragonFly does not have aout.  When/if they implement a new
   # versioning mechanism, adjust this.
   if test -x /usr/bin/objformat; then
@@ -67724,7 +67735,7 @@
       need_version=no
       need_lib_prefix=no
       ;;
-    freebsd-*)
+    midnightbsd-* | freebsd-*)
       library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
       need_version=yes
       ;;
