glibc declares getdomainname in <unistd.h>. gnulib should do the same. I'm applying this patch, to this effect.
2008-10-18 Bruno Haible <[EMAIL PROTECTED]> * lib/xgetdomainname.c: Include <unistd.h> instead of getdomainname.h. Move the getdomainname() declaration to <unistd.h>. * lib/getdomainname.h: Remove file. * lib/unistd.in.h (getdomainname): New declaration. * lib/getdomainname.c: Include <unistd.h> instead of getdomainname.h. * m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME): Require gl_UNISTD_H_DEFAULTS and AC_USE_SYSTEM_EXTENSIONS. Set HAVE_GETDOMAINNAME. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GETDOMAINNAME and HAVE_GETDOMAINNAME. * modules/getdomainname (Files): Remove lib/getdomainname.h. (Depends-on): Add unistd, extensions. (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR. (Includes): Specify <unistd.h> instead of getdomainname.h. * modules/unistd (Makefile.am): Substitute GNULIB_GETDOMAINNAME and HAVE_GETDOMAINNAME. * NEWS: Mention the change. --- NEWS.orig 2008-10-19 03:26:57.000000000 +0200 +++ NEWS 2008-10-19 03:26:52.000000000 +0200 @@ -6,6 +6,9 @@ Date Modules Changes +2008-10-18 getdomainname The include file is changed from "getdomainname.h" + to <unistd.h>. + 2008-09-28 sockets When using this module, you now need to link with $(LIBSOCKET). --- lib/getdomainname.c.orig 2008-10-19 03:26:57.000000000 +0200 +++ lib/getdomainname.c 2008-10-19 03:20:07.000000000 +0200 @@ -1,6 +1,6 @@ /* getdomainname emulation for systems that doesn't have it. - Copyright (C) 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2006, 2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ #include <config.h> /* Specification. */ -#include "getdomainname.h" +#include <unistd.h> #include <string.h> #include <errno.h> --- lib/unistd.in.h.orig 2008-10-19 03:26:57.000000000 +0200 +++ lib/unistd.in.h 2008-10-19 03:14:32.000000000 +0200 @@ -1,5 +1,5 @@ /* Substitute for and wrapper around <unistd.h>. - Copyright (C) 2004-2008 Free Software Foundation, Inc. + Copyright (C) 2003-2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -220,6 +220,29 @@ #endif +#if @GNULIB_GETDOMAINNAME@ +/* Return the NIS domain name of the machine. + WARNING! The NIS domain name is unrelated to the fully qualified host name + of the machine. It is also unrelated to email addresses. + WARNING! The NIS domain name is usually the empty string or "(none)" when + not using NIS. + + Put up to LEN bytes of the NIS domain name into NAME. + Null terminate it if the name is shorter than LEN. + If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. + Return 0 if successful, otherwise set errno and return -1. */ +# if [EMAIL PROTECTED]@ +extern int getdomainname(char *name, size_t len); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getdomainname +# define getdomainname(n,l) \ + (GL_LINK_WARNING ("getdomainname is unportable - " \ + "use gnulib module getdomainname for portability"), \ + getdomainname (n, l)) +#endif + + #if @GNULIB_GETDTABLESIZE@ # if [EMAIL PROTECTED]@ /* Return the maximum number of file descriptors in the current process. */ --- lib/xgetdomainname.c.orig 2008-10-19 03:26:57.000000000 +0200 +++ lib/xgetdomainname.c 2008-10-19 03:21:23.000000000 +0200 @@ -1,5 +1,5 @@ /* xgetdomainname.c -- Return the NIS domain name, without size limitations. - Copyright (C) 1992, 1996, 2000, 2001, 2003, 2004, 2006 Free Software + Copyright (C) 1992, 1996, 2000-2001, 2003-2004, 2006, 2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ #include "xgetdomainname.h" /* Get getdomainname. */ -#include "getdomainname.h" +#include <unistd.h> /* Get errno. */ #include <errno.h> --- m4/getdomainname.m4.orig 2008-10-19 03:26:57.000000000 +0200 +++ m4/getdomainname.m4 2008-10-19 03:19:30.000000000 +0200 @@ -1,13 +1,19 @@ -# getdomainname.m4 serial 2 -dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# getdomainname.m4 serial 3 +dnl Copyright (C) 2002-2003, 2008 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_DEFUN([gl_FUNC_GETDOMAINNAME], [ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + + dnl Persuade glibc <unistd.h> to declare getdomainname(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_REPLACE_FUNCS(getdomainname) if test $ac_cv_func_getdomainname = no; then + HAVE_GETDOMAINNAME=0 gl_PREREQ_GETDOMAINNAME fi ]) --- m4/unistd_h.m4.orig 2008-10-19 03:26:57.000000000 +0200 +++ m4/unistd_h.m4 2008-10-19 03:16:34.000000000 +0200 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 14 +# unistd_h.m4 serial 15 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -40,6 +40,7 @@ GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC]) GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) + GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME]) GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE]) GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) @@ -53,6 +54,7 @@ HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) + HAVE_GETDOMAINNAME=1; AC_SUBST([HAVE_GETDOMAINNAME]) HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) --- modules/getdomainname.orig 2008-10-19 03:26:57.000000000 +0200 +++ modules/getdomainname 2008-10-19 03:19:50.000000000 +0200 @@ -2,19 +2,21 @@ getdomainname() function: Return machine's NIS domain name. Files: -lib/getdomainname.h lib/getdomainname.c m4/getdomainname.m4 Depends-on: +unistd +extensions configure.ac: gl_FUNC_GETDOMAINNAME +gl_UNISTD_MODULE_INDICATOR([getdomainname]) Makefile.am: Include: -"getdomainname.h" +<unistd.h> License: GPL --- modules/unistd.orig 2008-10-19 03:26:57.000000000 +0200 +++ modules/unistd 2008-10-19 03:15:43.000000000 +0200 @@ -32,6 +32,7 @@ -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \ -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ + -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \ -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \ -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ @@ -44,6 +45,7 @@ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ + -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \