+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/debian/patches/series b/debian/patches/series
+index f008915..6015402 100644
+--- a/debian/patches/series
++++ b/debian/patches/series
+@@ -1,2 +1 @@
+-getdtablesize-missing.diff
+ zless-LESSOPEN.diff
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/lib/Makefile.in b/lib/Makefile.in
-index 1b42ddb..d71b78f 100644
---- a/lib/Makefile.in
-+++ b/lib/Makefile.in
-@@ -95,6 +95,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
- $(top_srcdir)/m4/ftello.m4 \
- $(top_srcdir)/m4/getcwd-abort-bug.m4 \
- $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \
-+ $(top_srcdir)/m4/getdtablesize.m4 \
- $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettime.m4 \
- $(top_srcdir)/m4/gettimeofday.m4 $(top_srcdir)/m4/glibc21.m4 \
- $(top_srcdir)/m4/gnu-make.m4 $(top_srcdir)/m4/gnulib-common.m4 \
-@@ -901,7 +902,7 @@ EXTRA_DIST = alloca.in.h $(top_srcdir)/build-aux/announce-gen \
- fpucw.h fpurge.c stdio-impl.h freadahead.h stdio-impl.h \
- freading.h stdio-impl.h frexp.c frexp.c frexpl.c fseeko.c \
- stdio-impl.h fseterr.h stdio-impl.h ftello.c \
-- $(top_srcdir)/build-aux/gendocs.sh getcwd.c getopt.c \
-+ $(top_srcdir)/build-aux/gendocs.sh getcwd.c getopt.c getdtablesize.c \
- getopt.in.h getopt1.c getopt_int.h gettime.c gettimeofday.c \
- $(top_srcdir)/build-aux/git-version-gen \
- $(top_srcdir)/build-aux/gitlog-to-changelog \
-@@ -975,6 +976,7 @@ EXTRA_libgzip_a_SOURCES = calloc.c calloc.c chdir-long.c chown.c \
- error.c exitfail.c fchdir.c fclose.c fcntl.c creat-safer.c \
- open-safer.c fdopendir.c openat-proc.c fflush.c fpending.c \
- fprintf.c fpurge.c frexp.c frexp.c frexpl.c fseeko.c ftello.c \
-+ getdtablesize.c \
- getcwd.c getopt.c getopt1.c gettime.c gettimeofday.c isnan.c \
- isnand.c isnan.c isnanf.c isnan.c isnanl.c lchown.c lseek.c \
- lstat.c malloc.c malloc.c mbrtowc.c mbsinit.c memchr.c \
-diff --git a/gzip/m4/getdtablesize.m4 b/gzip/m4/getdtablesize.m4
+diff --git a/m4/.gitignore b/m4/.gitignore
+index a5c3278..e03f2bc 100644
+--- a/m4/.gitignore
++++ b/m4/.gitignore
+@@ -1,7 +1,6 @@
+ /asm-underscore.m4
+ /cloexec.m4
+ /configmake.m4
+-/getdtablesize.m4
+ /gnulib-comp.m4
+ /gnulib-tool.m4
+ /wchar_h.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
+])