+diff --git a/configure.ac b/configure.ac
+index 818dbd9..0919132 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -129,6 +129,12 @@ if test "$gl_gcc_warnings" = yes; then
+ AC_SUBST([GNULIB_WARN_CFLAGS])
+ fi
+
++gl_FUNC_GETDTABLESIZE
++if test $HAVE_GETDTABLESIZE = 0; then
++ AC_LIBOBJ([getdtablesize])
++fi
++gl_UNISTD_MODULE_INDICATOR([getdtablesize])
++
+ # cc -E produces incorrect asm files on SVR4, so postprocess it.
+ ASCPPPOST="sed '/^ *#/d; s,//.*,,; s/% /%/g; s/\\. /./g'"
+ AC_SUBST([ASCPPPOST])
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
new file mode 100644
-index 0000000..a565a2d
+index 0000000..60e7f5a
--- /dev/null
-+++ b/gzip/lib/getdtablesize.c
++++ b/lib/getdtablesize.c
@@ -0,0 +1,63 @@
+/* getdtablesize() function for platforms that don't have it.
-+ Copyright (C) 2008-2010 Free Software Foundation, Inc.
++ Copyright (C) 2008-2011 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+ This program is free software: you can redistribute it and/or modify
+}
+
+#endif
-diff --git a/gzip/m4/getdtablesize.m4 b/gzip/m4/getdtablesize.m4
+diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4
new file mode 100644
-index 0000000..d238628
+index 0000000..40a598b
--- /dev/null
-+++ b/gzip/m4/getdtablesize.m4
-@@ -0,0 +1,15 @@
-+# getdtablesize.m4 serial 1
-+dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
++++ b/m4/getdtablesize.m4
+@@ -0,0 +1,14 @@
++# getdtablesize.m4 serial 2
++dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+ AC_CHECK_FUNCS_ONCE([getdtablesize])
+ if test $ac_cv_func_getdtablesize != yes; then
+ HAVE_GETDTABLESIZE=0
-+ AC_LIBOBJ([getdtablesize])
+ fi
+])