summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog75
-rw-r--r--lib/chown.c12
-rw-r--r--lib/dirent_.h4
-rw-r--r--lib/dup2.c6
-rw-r--r--lib/fchdir.c4
-rw-r--r--lib/ftruncate.c4
-rw-r--r--lib/getcwd.c2
-rw-r--r--lib/getlogin_r.c6
-rw-r--r--lib/readlink.c5
-rw-r--r--lib/unistd_.h154
-rw-r--r--lib/xgetcwd.c4
-rw-r--r--m4/chown.m48
-rw-r--r--m4/dup2.m411
-rw-r--r--m4/fchdir.m46
-rw-r--r--m4/ftruncate.m49
-rw-r--r--m4/getcwd.m46
-rw-r--r--m4/getlogin_r.m422
-rw-r--r--m4/readlink.m46
-rw-r--r--m4/unistd_h.m450
-rw-r--r--modules/chown2
-rw-r--r--modules/dup22
-rw-r--r--modules/fchdir2
-rw-r--r--modules/ftruncate2
-rw-r--r--modules/getcwd5
-rw-r--r--modules/getlogin_r4
-rw-r--r--modules/readlink3
-rw-r--r--modules/unistd24
27 files changed, 355 insertions, 83 deletions
diff --git a/ChangeLog b/ChangeLog
index 947bb9e5ce..418ea196ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,79 @@
2007-02-18 Bruno Haible <bruno@clisp.org>
+ * lib/readlink.c: Include <unistd.h>.
+ * m4/readlink.m4 (gl_FUNC_READLINK): Require gl_UNISTD_H_DEFAULTS. Set
+ HAVE_READLINK.
+ * modules/readlink (Depends-on): Add unistd.
+ (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+ (Include): Add <unistd.h>.
+
+ * lib/getlogin_r.h: Remove file.
+ * lib/getlogin_r.c: Include <unistd.h> instead of getlogin_r.h.
+ * m4/getlogin_r.m4 (gl_GETLOGIN_R_SUBSTITUTE): Remove macro.
+ (gl_GETLOGIN_R): Inline it here. Require gl_UNISTD_H_DEFAULTS. Set
+ HAVE_DECL_GETLOGIN_R.
+ * modules/getlogin_r (Files): Remove lib/getlogin_r.h.
+ (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+ (Include): Use <unistd.h> instead of getlogin_r.h.
+
+ * lib/getcwd.h: Remove file.
+ * lib/getcwd.c: Include <unistd.h> instead of getcwd.h.
+ * lib/xgetcwd.c: Likewise.
+ * m4/getcwd.m4 (gl_FUNC_GETCWD): Require gl_UNISTD_H_DEFAULTS. Set
+ REPLACE_GETCWD. Don't define __GETCWD_PREFIX.
+ * modules/getcwd (Files): Remove lib/getcwd.h.
+ (Depends-on): Add unistd.
+ (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+ (Include): Use <unistd.h> instad of getcwd.h.
+
+ * lib/ftruncate.c: Include <unistd.h> first.
+ * m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Require gl_UNISTD_H_DEFAULTS.
+ Set HAVE_FTRUNCATE.
+ * modules/ftruncate (Depends-on): Add unistd.
+ (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+
+ * lib/fchdir.c: Include <unistd.h> first.
+ * lib/dirent_.h: Test REPLACE_FCHDIR, not FCHDIR_REPLACEMENT.
+ * m4/fchdir.m4 (gl_FUNC_FCHDIR): Require gl_UNISTD_H_DEFAULTS instead
+ of gl_HEADER_UNISTD_DEFAULTS. Set REPLACE_FCHDIR. Don't set UNISTD_H.
+ * modules/fchdir (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+ (Makefile.am): Substitute also REPLACE_FCHDIR into dirent.h.
+
+ * lib/dup2.c: Include <unistd.h> first.
+ * m4/dup2.m4 (gl_FUNC_DUP2): Require gl_UNISTD_H_DEFAULTS. Set
+ HAVE_DUP2.
+ * modules/dup2 (Depends-on): Add unistd.
+ (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+
+ * lib/chown.c: Include <unistd.h> first. Undefine chown later.
+ * m4/chown.m4 (gl_FUNC_CHOWN): Require gl_UNISTD_H_DEFAULTS. Set
+ REPLACE_CHOWN. Don't define chown as a macro here.
+ * modules/chown (Depends-on): Add unistd.
+ (configure.ac): Invoke gl_UNISTD_MODULE_INDICATOR.
+
+ * lib/unistd_.h: Test HAVE_UNISTD_H determined at configure time.
+ Add definition for GL_LINK_WARNING.
+ (chown, dup2): New declarations.
+ (fchdir): Test REPLACE_FCHDIR, not FCHDIR_REPLACEMENT. Provide optional
+ link warning.
+ (ftruncate): New declaration.
+ (getcwd): New declaration, taken from old getcwd.h.
+ (getlogin_r): New declaration, taken from old getlogin_r.h.
+ (readlink): New declaration.
+ * m4/unistd_h.m4 (gl_UNISTD_H): Renamed from gl_HEADER_UNISTD. Don't
+ set UNISTD_H. Inline gl_PREREQ_UNISTD. Set HAVE_UNISTD_H.
+ (gl_PREREQ_UNISTD): Remove macro.
+ (gl_UNISTD_MODULE_INDICATOR): New macro.
+ (gl_UNISTD_H_DEFAULTS): Renamed from gl_HEADER_UNISTD_DEFAULTS. Set
+ many new variables. Don't set UNISTD_H.
+ * modules/unistd (Description): Change.
+ (Depends-on): Add link-warning.
+ (configure.ac): Update.
+ (Makefile.am): Create unistd.h always. Substitute many new variables
+ into it.
+
+2007-02-18 Bruno Haible <bruno@clisp.org>
+
* lib/stdlib_.h (getsubopt): New declaration, copied from getsubopt.h.
* modules/stdlib (stdlib.h): Also substitute GNULIB_GETSUBOPT and
HAVE_GETSUBOPT.
@@ -61,7 +135,6 @@
* lib/savewd.c: Likewise.
* lib/xsetenv.c: Likewise.
-
* modules/stdlib: New file.
* lib/stdlib_.h: New file, incorporating exit.h, mkdtemp.h, mkstemp.h
and extra comments about mkstemp().
diff --git a/lib/chown.c b/lib/chown.c
index 2da2c80ab4..b7786f6205 100644
--- a/lib/chown.c
+++ b/lib/chown.c
@@ -1,7 +1,7 @@
/* provide consistent interface to chown for systems that don't interpret
an ID of -1 as meaning `don't change the corresponding ID'.
- Copyright (C) 1997, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2004, 2005, 2006, 2007 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
@@ -21,18 +21,18 @@
#include <config.h>
-/* Disable the definition of chown to rpl_chown (from config.h) in this
- file. Otherwise, we'd get conflicting prototypes for rpl_chown on
- most systems. */
-#undef chown
+/* Specification. */
+#include <unistd.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+/* Below we refer to the system's chown(). */
+#undef chown
+
/* The results of open() in this file are not used with fchdir,
therefore save some unnecessary work in fchdir.c. */
#undef open
diff --git a/lib/dirent_.h b/lib/dirent_.h
index cadc267f8a..3fa848058f 100644
--- a/lib/dirent_.h
+++ b/lib/dirent_.h
@@ -1,5 +1,5 @@
/* Wrapper around <dirent.h>.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006-2007 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
@@ -27,7 +27,7 @@
extern "C" {
#endif
-#ifdef FCHDIR_REPLACEMENT
+#if @REPLACE_FCHDIR@
# define opendir rpl_opendir
extern DIR * opendir (const char *);
# define closedir rpl_closedir
diff --git a/lib/dup2.c b/lib/dup2.c
index 5e77204577..88944817cf 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -1,6 +1,6 @@
/* Duplicate an open file descriptor to a specified file descriptor.
- Copyright (C) 1999, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004, 2005, 2006, 2007 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,9 +20,11 @@
#include <config.h>
+/* Specification. */
+#include <unistd.h>
+
#include <errno.h>
#include <fcntl.h>
-#include <unistd.h>
#ifndef F_DUPFD
static int
diff --git a/lib/fchdir.c b/lib/fchdir.c
index f3a9dfd620..e3ec2fcf6d 100644
--- a/lib/fchdir.c
+++ b/lib/fchdir.c
@@ -17,12 +17,14 @@
#include <config.h>
+/* Specification. */
+#include <unistd.h>
+
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
diff --git a/lib/ftruncate.c b/lib/ftruncate.c
index 079fcda0f2..f6a7ea5587 100644
--- a/lib/ftruncate.c
+++ b/lib/ftruncate.c
@@ -3,6 +3,9 @@
#include <config.h>
+/* Specification. */
+#include <unistd.h>
+
#include <sys/types.h>
#include <fcntl.h>
@@ -21,7 +24,6 @@ ftruncate (int fd, off_t length)
# include <sys/stat.h>
# include <errno.h>
-# include <unistd.h>
int
ftruncate (int fd, off_t length)
diff --git a/lib/getcwd.c b/lib/getcwd.c
index 0ac5cdce33..3cdc113916 100644
--- a/lib/getcwd.c
+++ b/lib/getcwd.c
@@ -18,7 +18,7 @@
#if !_LIBC
# include <config.h>
-# include "getcwd.h"
+# include <unistd.h>
#endif
#include <errno.h>
diff --git a/lib/getlogin_r.c b/lib/getlogin_r.c
index 55190f0758..67ad33f21d 100644
--- a/lib/getlogin_r.c
+++ b/lib/getlogin_r.c
@@ -1,6 +1,6 @@
/* Provide a working getlogin_r for systems which lack it.
- Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, 2007 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,11 +20,11 @@
#include <config.h>
-#include "getlogin_r.h"
+/* Specification. */
+#include <unistd.h>
#include <errno.h>
#include <string.h>
-#include <unistd.h>
#if !HAVE_DECL_GETLOGIN
char *getlogin (void);
diff --git a/lib/readlink.c b/lib/readlink.c
index 63b5d5ec79..3cbdc1c2fd 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -1,5 +1,5 @@
/* Stub for readlink().
- Copyright (C) 2003-2006 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007 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
@@ -17,6 +17,9 @@
#include <config.h>
+/* Specification. */
+#include <unistd.h>
+
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/unistd_.h b/lib/unistd_.h
index 36fa673124..77df86116f 100644
--- a/lib/unistd_.h
+++ b/lib/unistd_.h
@@ -1,5 +1,5 @@
/* Substitute for and wrapper around <unistd.h>.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2004-2007 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
@@ -18,32 +18,172 @@
#ifndef _GL_UNISTD_H
#define _GL_UNISTD_H
-#if HAVE_UNISTD_H
+#if @HAVE_UNISTD_H@
# include @ABSOLUTE_UNISTD_H@
#endif
+/* The definition of GL_LINK_WARNING is copied here. */
+
+
/* Declare overridden functions. */
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef FCHDIR_REPLACEMENT
+
+#if @GNULIB_CHOWN@
+# if @REPLACE_CHOWN@
+/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
+ to GID (if GID is not -1).
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/chown.html>. */
+# define chown rpl_chown
+extern int chown (const char *file, uid_t uid, gid_t gid);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef chown
+# define chown(f,u,g) \
+ (GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
+ "doesn't treat a uid or gid of -1 on some systems - " \
+ "use gnulib module chown for portability"), \
+ chown (f, u, g))
+#endif
+
+
+#if @GNULIB_DUP2@
+# if !@HAVE_DUP2@
+/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
+ NEWFD = OLDFD, otherwise close NEWFD first if it is open.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/dup2.html>. */
+extern int dup2 (int oldfd, int newfd);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef dup2
+# define dup2(o,n) \
+ (GL_LINK_WARNING ("dup2 is unportable - " \
+ "use gnulib module dup2 for portability"), \
+ dup2 (o, n))
+#endif
+
+
+#if @GNULIB_FCHDIR@
+# if @REPLACE_FCHDIR@
/* Change the process' current working directory to the directory on which
- the given file descriptor is open. */
+ the given file descriptor is open.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/fchdir.html>. */
extern int fchdir (int /*fd*/);
-# define close rpl_close
+# define close rpl_close
extern int close (int);
-# define dup rpl_dup
+# define dup rpl_dup
extern int dup (int);
-# define dup2 rpl_dup2
+# define dup2 rpl_dup2
extern int dup2 (int, int);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fchdir
+# define fchdir(f) \
+ (GL_LINK_WARNING ("fchdir is unportable - " \
+ "use gnulib module fchdir for portability"), \
+ fchdir (f))
+#endif
+
+
+#if @GNULIB_FTRUNCATE@
+# if !@HAVE_FTRUNCATE@
+/* Change the size of the file to which FD is opened to become equal to LENGTH.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
+extern int ftruncate (int fd, off_t length);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef ftruncate
+# define ftruncate(f,l) \
+ (GL_LINK_WARNING ("ftruncate is unportable - " \
+ "use gnulib module ftruncate for portability"), \
+ ftruncate (f, l))
#endif
+
+#if @GNULIB_GETCWD@
+/* Include the headers that might declare getcwd so that they will not
+ cause confusion if included after this file. */
+# include <stdlib.h>
+# if @REPLACE_GETCWD@
+/* Get the name of the current working directory, and put it in SIZE bytes
+ of BUF.
+ Return BUF if successful, or NULL if the directory couldn't be determined
+ or SIZE was too small.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/getcwd.html>.
+ Additionally, the gnulib module 'getcwd' guarantees the following GNU
+ extension: If BUF is NULL, an array is allocated with 'malloc'; the array
+ is SIZE bytes long, unless SIZE == 0, in which case it is as big as
+ necessary. */
+# define getcwd rpl_getcwd
+extern char * getcwd (char *buf, size_t size);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getcwd
+# define getcwd(b,s) \
+ (GL_LINK_WARNING ("getcwd is unportable - " \
+ "use gnulib module getcwd for portability"), \
+ getcwd (b, s))
+#endif
+
+
+#if @GNULIB_GETLOGIN_R@
+/* Copies the user's login name to NAME.
+ The array pointed to by NAME has room for SIZE bytes.
+
+ Returns 0 if successful. Upon error, an error number is returned, or -1 in
+ the case that the login name cannot be found but no specific error is
+ provided (this case is hopefully rare but is left open by the POSIX spec).
+
+ See <http://www.opengroup.org/susv3xsh/getlogin.html>.
+ */
+# if !@HAVE_DECL_GETLOGIN_R@
+# include <stddef.h>
+extern int getlogin_r (char *name, size_t size);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getlogin_r
+# define getlogin_r(n,s) \
+ (GL_LINK_WARNING ("getlogin_r is unportable - " \
+ "use gnulib module getlogin_r for portability"), \
+ getlogin_r (n, s))
+#endif
+
+
+#if @GNULIB_READLINK@
+/* Read the contents of the symbolic link FILE and place the first BUFSIZE
+ bytes of it into BUF. Return the number of bytes placed into BUF if
+ successful, otherwise -1 and errno set.
+ See the POSIX:2001 specification
+ <http://www.opengroup.org/susv3xsh/readlink.html>. */
+# if !@HAVE_READLINK@
+# include <stddef.h>
+extern int readlink (const char *file, char *buf, size_t bufsize);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef readlink
+# define readlink(f,b,s) \
+ (GL_LINK_WARNING ("readlink is unportable - " \
+ "use gnulib module readlink for portability"), \
+ readlink (f, b, s))
+#endif
+
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/xgetcwd.c b/lib/xgetcwd.c
index db5f2d217d..26ea5da53d 100644
--- a/lib/xgetcwd.c
+++ b/lib/xgetcwd.c
@@ -1,6 +1,6 @@
/* xgetcwd.c -- return current directory with unlimited length
- Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2004, 2006, 2007 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
@@ -23,8 +23,8 @@
#include "xgetcwd.h"
#include <errno.h>
+#include <unistd.h>
-#include "getcwd.h"
#include "xalloc.h"
/* Return the current directory, newly allocated.
diff --git a/m4/chown.m4 b/m4/chown.m4
index d1a7147e55..89761f5ff4 100644
--- a/m4/chown.m4
+++ b/m4/chown.m4
@@ -1,7 +1,7 @@
-#serial 16
+#serial 17
# Determine whether we need the chown wrapper.
-dnl Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free
+dnl Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2007 Free
dnl Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
@@ -16,6 +16,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_CHOWN],
[
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_REQUIRE([AC_TYPE_UID_T])
AC_REQUIRE([AC_FUNC_CHOWN])
AC_REQUIRE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK])
@@ -29,9 +30,8 @@ AC_DEFUN([gl_FUNC_CHOWN],
if test $ac_cv_func_chown_works$gl_cv_func_chown_follows_symlink = yesyes; then
: # no wrapper needed
else
+ REPLACE_CHOWN=1
AC_LIBOBJ(chown)
- AC_DEFINE(chown, rpl_chown,
- [Define to rpl_chown if the replacement function should be used.])
gl_PREREQ_CHOWN
fi
])
diff --git a/m4/dup2.m4 b/m4/dup2.m4
index bf8524e146..054982359e 100644
--- a/m4/dup2.m4
+++ b/m4/dup2.m4
@@ -1,10 +1,15 @@
-#serial 4
-dnl Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+#serial 5
+dnl Copyright (C) 2002, 2005, 2007 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_DUP2],
[
- AC_REPLACE_FUNCS(dup2)
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_CHECK_FUNCS_ONCE([dup2])
+ if test $ac_cv_func_dup2 = no; then
+ HAVE_DUP2=0
+ AC_LIBOBJ([dup2])
+ fi
])
diff --git a/m4/fchdir.m4 b/m4/fchdir.m4
index 6998eae435..58c933cf30 100644
--- a/m4/fchdir.m4
+++ b/m4/fchdir.m4
@@ -1,4 +1,4 @@
-# fchdir.m4 serial 2
+# fchdir.m4 serial 3
dnl Copyright (C) 2006-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -6,9 +6,10 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_FCHDIR],
[
- AC_REQUIRE([gl_HEADER_UNISTD_DEFAULTS])
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_CHECK_FUNCS_ONCE([fchdir])
if test $ac_cv_func_fchdir = no; then
+ REPLACE_FCHDIR=1
AC_LIBOBJ([fchdir])
gl_PREREQ_FCHDIR
AC_DEFINE([FCHDIR_REPLACEMENT], 1,
@@ -16,7 +17,6 @@ AC_DEFUN([gl_FUNC_FCHDIR],
gl_ABSOLUTE_HEADER([dirent.h])
ABSOLUTE_DIRENT_H=\"$gl_cv_absolute_dirent_h\"
DIRENT_H='dirent.h'
- UNISTD_H='unistd.h'
else
DIRENT_H=
fi
diff --git a/m4/ftruncate.m4 b/m4/ftruncate.m4
index e71e99b40b..dd37f2dc80 100644
--- a/m4/ftruncate.m4
+++ b/m4/ftruncate.m4
@@ -1,8 +1,8 @@
-#serial 10
+#serial 11
# See if we need to emulate a missing ftruncate function using fcntl or chsize.
-# Copyright (C) 2000, 2001, 2003-2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2003-2007 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,11 @@
AC_DEFUN([gl_FUNC_FTRUNCATE],
[
- AC_REPLACE_FUNCS(ftruncate)
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_CHECK_FUNCS_ONCE([ftruncate])
if test $ac_cv_func_ftruncate = no; then
+ HAVE_FTRUNCATE=0
+ AC_LIBOBJ([ftruncate])
gl_PREREQ_FTRUNCATE
# If someone lacks ftruncate, make configure fail, and request
# a bug report to inform us about it.
diff --git a/m4/getcwd.m4 b/m4/getcwd.m4
index a1096f2e2c..6ebe2fce4d 100644
--- a/m4/getcwd.m4
+++ b/m4/getcwd.m4
@@ -1,6 +1,6 @@
# getcwd.m4 - check for working getcwd that is compatible with glibc
-# Copyright (C) 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -36,6 +36,7 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
AC_DEFUN([gl_FUNC_GETCWD],
[
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_GETCWD_NULL])
gl_abort_bug=no
@@ -48,9 +49,8 @@ AC_DEFUN([gl_FUNC_GETCWD],
case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max,$gl_abort_bug in
yes,yes,no) ;;
*)
+ REPLACE_GETCWD=1
AC_LIBOBJ([getcwd])
- AC_DEFINE([__GETCWD_PREFIX], [[rpl_]],
- [Define to rpl_ if the getcwd replacement function should be used.])
gl_PREREQ_GETCWD;;
esac
])
diff --git a/m4/getlogin_r.m4 b/m4/getlogin_r.m4
index 589d626a22..8e5a2a3c58 100644
--- a/m4/getlogin_r.m4
+++ b/m4/getlogin_r.m4
@@ -1,6 +1,6 @@
-#serial 3
+#serial 4
-# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -11,23 +11,23 @@ dnl
dnl Provide getlogin_r when the system lacks it.
dnl
-AC_DEFUN([gl_GETLOGIN_R_SUBSTITUTE],
-[
- gl_PREREQ_GETLOGIN_R
- AC_LIBOBJ([getlogin_r])
-])
-
AC_DEFUN([gl_GETLOGIN_R],
[
- AC_REPLACE_FUNCS([getlogin_r])
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_CHECK_FUNCS_ONCE([getlogin_r])
if test $ac_cv_func_getlogin_r = no; then
- gl_GETLOGIN_R_SUBSTITUTE
+ AC_LIBOBJ([getlogin_r])
+ gl_PREREQ_GETLOGIN_R
+ if test $ac_cv_have_decl_getlogin_r = yes; then
+ HAVE_DECL_GETLOGIN_R=1
+ else
+ HAVE_DECL_GETLOGIN_R=0
+ fi
fi
])
AC_DEFUN([gl_PREREQ_GETLOGIN_R],
[
- AC_CHECK_HEADERS_ONCE([unistd.h])
AC_CHECK_DECLS_ONCE([getlogin])
AC_CHECK_DECLS_ONCE([getlogin_r])
])
diff --git a/m4/readlink.m4 b/m4/readlink.m4
index b4a7f55d7a..0834565516 100644
--- a/m4/readlink.m4
+++ b/m4/readlink.m4
@@ -1,13 +1,15 @@
-# readlink.m4 serial 2
-dnl Copyright (C) 2003 Free Software Foundation, Inc.
+# readlink.m4 serial 3
+dnl Copyright (C) 2003, 2007 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_READLINK],
[
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_CHECK_FUNCS(readlink)
if test $ac_cv_func_readlink = no; then
+ HAVE_READLINK=0
AC_LIBOBJ(readlink)
gl_PREREQ_READLINK
fi
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index d38de90fe8..628b818683 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,39 +1,51 @@
-# unistd_h.m4 serial 4
+# unistd_h.m4 serial 5
dnl Copyright (C) 2006-2007 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.
-dnl Written by Simon Josefsson
+dnl Written by Simon Josefsson, Bruno Haible.
-AC_DEFUN([gl_HEADER_UNISTD],
+AC_DEFUN([gl_UNISTD_H],
[
dnl Use AC_REQUIRE here, so that the default behavior below is expanded
dnl once only, before all statements that occur in other macros.
- AC_REQUIRE([gl_HEADER_UNISTD_DEFAULTS])
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
- AC_CHECK_HEADERS([unistd.h], [], [
- UNISTD_H='unistd.h'
- ])
- dnl This module decides to build unistd.h if it is missing.
- dnl The fchdir module decides to build unistd.h if fchdir() is missing.
- dnl Therefore check for the prerequisites of lib/unistd.h always.
- gl_PREREQ_UNISTD
-])
-
-dnl Prerequisites of lib/unistd.h.
-AC_DEFUN([gl_PREREQ_UNISTD],
-[
AC_CHECK_HEADERS_ONCE([unistd.h])
if test $ac_cv_header_unistd_h = yes; then
+ HAVE_UNISTD_H=1
gl_ABSOLUTE_HEADER([unistd.h])
ABSOLUTE_UNISTD_H=\"$gl_cv_absolute_unistd_h\"
+ else
+ HAVE_UNISTD_H=0
fi
+ AC_SUBST([HAVE_UNISTD_H])
AC_SUBST([ABSOLUTE_UNISTD_H])
])
-AC_DEFUN([gl_HEADER_UNISTD_DEFAULTS],
+AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_UNISTD_H_DEFAULTS],
[
- UNISTD_H=
- AC_SUBST(UNISTD_H)
+ GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
+ GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
+ GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
+ GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
+ GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
+ GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
+ GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
+ dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_DUP2=1; AC_SUBST([HAVE_DUP2])
+ HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
+ HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
+ HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
+ REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
+ REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
+ REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
])
diff --git a/modules/chown b/modules/chown
index 23eb3ac468..a8ac9531bb 100644
--- a/modules/chown
+++ b/modules/chown
@@ -7,10 +7,12 @@ lib/fchown-stub.c
m4/chown.m4
Depends-on:
+unistd
sys_stat
configure.ac:
gl_FUNC_CHOWN
+gl_UNISTD_MODULE_INDICATOR([chown])
Makefile.am:
diff --git a/modules/dup2 b/modules/dup2
index db3a1f71c7..b188644e3f 100644
--- a/modules/dup2
+++ b/modules/dup2
@@ -6,9 +6,11 @@ lib/dup2.c
m4/dup2.m4
Depends-on:
+unistd
configure.ac:
gl_FUNC_DUP2
+gl_UNISTD_MODULE_INDICATOR([dup2])
Makefile.am:
diff --git a/modules/fchdir b/modules/fchdir
index 4a501417c5..d647668341 100644
--- a/modules/fchdir
+++ b/modules/fchdir
@@ -17,6 +17,7 @@ strdup
configure.ac:
gl_FUNC_FCHDIR
+gl_UNISTD_MODULE_INDICATOR([fchdir])
Makefile.am:
BUILT_SOURCES += $(DIRENT_H)
@@ -27,6 +28,7 @@ dirent.h: dirent_.h
rm -f $@-t $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''ABSOLUTE_DIRENT_H''@|$(ABSOLUTE_DIRENT_H)|g' \
+ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
< $(srcdir)/dirent_.h; \
} > $@-t
mv $@-t $@
diff --git a/modules/ftruncate b/modules/ftruncate
index ae445f32b8..a90be6ce7f 100644
--- a/modules/ftruncate
+++ b/modules/ftruncate
@@ -6,9 +6,11 @@ lib/ftruncate.c
m4/ftruncate.m4
Depends-on:
+unistd
configure.ac:
gl_FUNC_FTRUNCATE
+gl_UNISTD_MODULE_INDICATOR([ftruncate])
Makefile.am:
diff --git a/modules/getcwd b/modules/getcwd
index 35c6412577..5d85b4d581 100644
--- a/modules/getcwd
+++ b/modules/getcwd
@@ -2,7 +2,6 @@ Description:
Return the current working directory.
Files:
-lib/getcwd.h
lib/getcwd.c
m4/getcwd-abort-bug.m4
m4/getcwd-path-max.m4
@@ -13,14 +12,16 @@ mempcpy
d-ino
extensions
stdbool
+unistd
configure.ac:
gl_FUNC_GETCWD
+gl_UNISTD_MODULE_INDICATOR([getcwd])
Makefile.am:
Include:
-"getcwd.h"
+<unistd.h>
License:
GPL
diff --git a/modules/getlogin_r b/modules/getlogin_r
index 84792502bf..e6d655cd26 100644
--- a/modules/getlogin_r
+++ b/modules/getlogin_r
@@ -2,7 +2,6 @@ Description:
getlogin_r() function: Get user name to a buffer allocated by the caller.
Files:
-lib/getlogin_r.h
lib/getlogin_r.c
m4/getlogin_r.m4
@@ -12,11 +11,12 @@ unistd
configure.ac:
gl_GETLOGIN_R
+gl_UNISTD_MODULE_INDICATOR([getlogin_r])
Makefile.am:
Include:
-"getlogin_r.h"
+<unistd.h>
License:
LGPL
diff --git a/modules/readlink b/modules/readlink
index e2920e9a76..92cc986649 100644
--- a/modules/readlink
+++ b/modules/readlink
@@ -6,13 +6,16 @@ lib/readlink.c
m4/readlink.m4
Depends-on:
+unistd
configure.ac:
gl_FUNC_READLINK
+gl_UNISTD_MODULE_INDICATOR([readlink])
Makefile.am:
Include:
+<unistd.h>
License:
LGPL
diff --git a/modules/unistd b/modules/unistd
index c42a3ac7d2..5108617e81 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -1,5 +1,5 @@
Description:
-A <unistd.h> for systems lacking it.
+A GNU-like <unistd.h>.
Files:
m4/unistd_h.m4
@@ -7,19 +7,35 @@ lib/unistd_.h
Depends-on:
absolute-header
+link-warning
configure.ac:
-gl_HEADER_UNISTD
+gl_UNISTD_H
Makefile.am:
-BUILT_SOURCES += $(UNISTD_H)
+BUILT_SOURCES += unistd.h
# We need the following in order to create an empty placeholder for
# <unistd.h> when the system doesn't have one.
unistd.h: unistd_.h
rm -f $@-t $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''ABSOLUTE_UNISTD_H''@|$(ABSOLUTE_UNISTD_H)|g' \
+ sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
+ -e 's|@''ABSOLUTE_UNISTD_H''@|$(ABSOLUTE_UNISTD_H)|g' \
+ -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
+ -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
+ -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
+ -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
+ -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
+ -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
+ -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
+ -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
+ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
+ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
+ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
+ -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
+ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
+ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
< $(srcdir)/unistd_.h; \
} > $@-t
mv $@-t $@