diff --git a/ChangeLog b/ChangeLog
index f8b55a18d1fd5e411a9d01fc4d0e83957331e26d..f1ce1a39f14306ea63ee5e9325f57e53768c1d54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-16  Benno Schulenberg  <bensberg@justemail.net>
+	* configure.ac: For the sake of statically linked systems, make sure
+	the compiler also links against libz, which is used by libmagic.
+	This fixes Savannah bug #38378, reported by Alan Hourihane.
+
 2014-06-14  Mark Majeres  <mark@engine12.com>
 	* src/nano.h, src/text.c (undo_cut, update_undo): When undoing a
 	backwards cut, put the cursor back in front of it, where it was.
diff --git a/configure.ac b/configure.ac
index c76cd09fbac9295b88a42477aa53fec3e01d04ae..9baa198713ff6e3fef33c31c861060fececc077b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -649,6 +649,8 @@ AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
 AS_IF([test "x$enable_libmagic" != "xno"], [
   AC_CHECK_HEADERS_ONCE([magic.h])
   AC_CHECK_LIB(magic, magic_open)
+  AC_CHECK_HEADERS_ONCE([zlib.h])
+  AC_CHECK_LIB(z, inflate)
 ])
 
 # Check for groff html support.