Re: [bug-gnulib] Re: build failures: string.h vs. HP-UX

2007-03-03 Thread Bruno Haible
Paul Eggert wrote on 2007-01-29:
> > The problem is that regex.h is defining "__restrict" to be "restrict"!
> > ...
> > And of course config.h is defining "restrict" to be "__restrict".
> >
> >   #define restrict __restrict
> >
> > That combination is obviously not good.
> 
> Thanks for reporting that.  I installed this, which I hope fixes
> things for you.  I suspect other modules have a similar problem, but
> let's verify that this fix works first.
> 
> 2007-01-28  Paul Eggert  <[EMAIL PROTECTED]>
> 
>   * lib/regex.h (_Restrict_): Renamed from __restrict, to avoid
>   a circularity problem with HP-UX ia64 reported by Bob Proulx in
>   .
>   All uses changed.
>   (_Restrict_arr_): Renamed from __restrict_arr, for similar reasons.
>   All uses changed.
>   * lib/regcomp.c, lib/regexec.c: Change all uses from __restrict
>   to _Restrict_.
>   * lib/regexec.c (regexec): Declare pmatch with _Restrict_arr_, so that
>   the parameter matches the prototype.

The problem indeed exists also for the 'glob' module. On MacOS X it fails
like this:

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT glob.o -MD -MP -MF .deps/glob.Tpo 
-c -o glob.o glob.c
In file included from glob.c:111:
string.h:85: error: parse error before "__dest"
make[1]: *** [glob.o] Error 1

The reasons are the same, except that the definition of __restrict comes
from glob.h. I'm applying this fix. Let's hope, like for regex.h, that
the patch is acceptable for glibc.

2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* lib/glob-libc.h (_Restrict_): New macro, copied from lib/regex.h.
All uses of __restrict changed to _Restrict_.
* lib/glob_.h (__restrict): Remove macro.

*** lib/glob-libc.h 10 Jan 2006 21:49:07 -  1.2
--- lib/glob-libc.h 3 Mar 2007 12:31:07 -
***
*** 1,4 
! /* Copyright (C) 1991,92,95-98,2000,2001,2004-2006 Free Software Foundation, 
Inc.
 This file is part of the GNU C Library.
  
 The GNU C Library is free software; you can redistribute it and/or
--- 1,4 
! /* Copyright (C) 1991,92,95-98,2000,2001,2004-2007 Free Software Foundation, 
Inc.
 This file is part of the GNU C Library.
  
 The GNU C Library is free software; you can redistribute it and/or
***
*** 23,28 
--- 23,43 
  # include 
  #endif
  
+ /* GCC 2.95 and later have "__restrict"; C99 compilers have
+"restrict", and "configure" may have defined "restrict".
+Other compilers use __restrict, __restrict__, and _Restrict, and
+'configure' might #define 'restrict' to those words, so pick a
+different name.  */
+ #ifndef _Restrict_
+ # if 199901L <= __STDC_VERSION__
+ #  define _Restrict_ restrict
+ # elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
+ #  define _Restrict_ __restrict
+ # else
+ #  define _Restrict_
+ # endif
+ #endif
+ 
  __BEGIN_DECLS
  
  /* We need `size_t' for the following definitions.  */
***
*** 106,116 
  #endif
  void *(*gl_opendir) (const char *);
  #ifdef __USE_GNU
! int (*gl_lstat) (const char *__restrict, struct stat *__restrict);
! int (*gl_stat) (const char *__restrict, struct stat *__restrict);
  #else
! int (*gl_lstat) (const char *__restrict, void *__restrict);
! int (*gl_stat) (const char *__restrict, void *__restrict);
  #endif
} glob_t;
  
--- 121,131 
  #endif
  void *(*gl_opendir) (const char *);
  #ifdef __USE_GNU
! int (*gl_lstat) (const char *_Restrict_, struct stat *_Restrict_);
! int (*gl_stat) (const char *_Restrict_, struct stat *_Restrict_);
  #else
! int (*gl_lstat) (const char *_Restrict_, void *_Restrict_);
! int (*gl_stat) (const char *_Restrict_, void *_Restrict_);
  #endif
} glob_t;
  
***
*** 135,145 
  # endif
  void *(*gl_opendir) (const char *);
  # ifdef __USE_GNU
! int (*gl_lstat) (const char *__restrict, struct stat64 *__restrict);
! int (*gl_stat) (const char *__restrict, struct stat64 *__restrict);
  # else
! int (*gl_lstat) (const char *__restrict, void *__restrict);
! int (*gl_stat) (const char *__restrict, void *__restrict);
  # endif
} glob64_t;
  #endif
--- 150,160 
  # endif
  void *(*gl_opendir) (const char *);
  # ifdef __USE_GNU
! int (*gl_lstat) (const char *_Restrict_, struct stat64 *_Restrict_);
! int (*gl_stat) (const char *_Restrict_, struct stat64 *_Restrict_);
  # else
! int (*gl_lstat) (const char *_Restrict_, void *_Restrict_);
! int (*gl_stat) (const char *_Restrict_, void *_Restrict_);
  # endif
} glob64_t;
  #endif
***
*** 158,182 
 If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
 Otherwise, `glob' returns zero.  */
  #if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 || defined __GLOB_GNULIB
! extern int glob (const char *__restrict __pattern, int __flags,
 int (*__errfunc) (const

Re: sys_socket module: make self-contained

2007-03-03 Thread Simon Josefsson
Bruno Haible <[EMAIL PROTECTED]> writes:

> Hi Simon,
>
> In the  test that I added a few weeks ago, I assumed - like
> specified in POSIX:2001 - a self-contained . However, the
> current sys_socket module says that I should include  before
> it. And indeed, without  before , the test
> fails on MacOS X:

Looks good, thanks.

/Simon




Re: netinet_in module: make self-contained

2007-03-03 Thread Simon Josefsson
Eric Blake <[EMAIL PROTECTED]> writes:

> Bruno Haible  clisp.org> writes:
>
>> 
>> Hi Simon,
>> 
>> Like for ,  should be self-contained according
>> to POSIX, and the test verifies this. It fails on MacOS X, because it
>> needs  to be included first. Here's a proposed change to
>> create an overridden netinet/in.h also in this case.
>> 
>> + 
>> + dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
>> + dnl the check for those headers unconditional; yet cygwin reports
>> + dnl that the headers are present but cannot be compiled (since on
>> + dnl cygwin, all socket information should come from netinet/in.h).
>> + 
>> + AC_CHECK_HEADERS([netinet/in.h])
>
> _Too much_ copy-n-paste from the sys/socket module.  It is true that you 
> cannot 
> do AC_CHECK_HEADERS_ONCE([winsock2.h ws2tcpip.h]) on cygwin, since those are 
> Windows API headers and conflict with POSIX API.  But for sys/socket.h and 
> netinet/in.h, there is nothing wrong with AC_CHECK_HEADERS_ONCE.  You need to 
> simplify this .m4 down to only what is really needed (since on cygwin, 
> netinet/in.h is self-contained, so the replacement should not need to 
> trigger).

I agree with this objection, but other than that, the general approach
that Bruno proposed seems like the right thing to me.

/Simon




sys_select module (was: Re: netinet_in module: make self-contained)

2007-03-03 Thread Bruno Haible
Eric Blake wrote:
> _Too much_ copy-n-paste from the sys/socket module.

Yes... Still copy&paste is the right technique since the same problem
deserves the same solution.

It occurs also for the sys_select module: MacOS X  is not
self-contained:

gcc -DHAVE_CONFIG_H -I.  -I. -I. -I.. -I./.. -I../gllib -I./../gllib   -g -O2 
-MT test-sys_select.o -MD -MP -MF .deps/test-sys_select.Tpo -c -o 
test-sys_select.o test-sys_select.c
In file included from /usr/include/sys/select.h:71,
 from test-sys_select.c:22:
/usr/include/sys/event.h:66: error: parse error before "uintptr_t"
/usr/include/sys/event.h:68: error: parse error before "flags"
/usr/include/sys/event.h:69: error: parse error before "fflags"
/usr/include/sys/event.h:70: error: parse error before "data"
/usr/include/sys/event.h:72: error: parse error before '}' token
In file included from test-sys_select.c:22:
/usr/include/sys/select.h:88: error: parse error before "u_int"
make[4]: *** [test-sys_select.o] Error 1

This proposed patch fixes it (copy&pasted :-)).


2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* lib/sys_select_.h: New file.
* m4/sys_socket_h.m4 (gl_HEADER_SYS_SELECT): Test whether sys/select.h
is self-contained. Set ABSOLUTE_SYS_SELECT_H, HAVE_SYS_SELECT_H.
* modules/sys_select (Files): Add lib/sys_select_.h.
(Depends-on): Add absolute-header.
(Makefile.am): Substitute ABSOLUTE_SYS_SELECT_H, HAVE_SYS_SELECT_H
into sys/select.h.

*** m4/sys_select_h.m4  27 Jun 2006 21:21:13 -  1.1
--- m4/sys_select_h.m4  3 Mar 2007 13:40:52 -
***
*** 1,18 
! # sys_select_h.m4 serial 1
! dnl Copyright (C) 2006 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 Adapted from arpa_inet.m4, written by Simon Josefsson.
- 
  AC_DEFUN([gl_HEADER_SYS_SELECT],
  [
!   AC_CHECK_HEADERS_ONCE([sys/select.h])
!   if test $ac_cv_header_sys_select_h = yes; then
  SYS_SELECT_H=''
else
  SYS_SELECT_H='sys/select.h'
fi
!   AC_SUBST(SYS_SELECT_H)
  ])
--- 1,32 
! # sys_select_h.m4 serial 2
! 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.
  
  AC_DEFUN([gl_HEADER_SYS_SELECT],
  [
!   AC_CACHE_CHECK([whether  is self-contained],
! [gl_cv_header_sys_select_h_selfcontained],
! [
!   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [])],
! [gl_cv_header_sys_select_h_selfcontained=yes],
! [gl_cv_header_sys_select_h_selfcontained=no])
! ])
!   if test $gl_cv_header_sys_select_h_selfcontained = yes; then
  SYS_SELECT_H=''
else
  SYS_SELECT_H='sys/select.h'
+ AC_CHECK_HEADERS([sys/select.h])
+ gl_ABSOLUTE_HEADER([sys/select.h])
+ ABSOLUTE_SYS_SELECT_H=\"$gl_cv_absolute_sys_select_h\"
+ AC_SUBST([ABSOLUTE_SYS_SELECT_H])
+ if test $ac_cv_header_sys_select_h = yes; then
+   HAVE_SYS_SELECT_H=1
+ else
+   HAVE_SYS_SELECT_H=0
+ fi
+ AC_SUBST([HAVE_SYS_SELECT_H])
fi
!   AC_SUBST([SYS_SELECT_H])
  ])
*** modules/sys_select  22 Jan 2007 23:07:42 -  1.7
--- modules/sys_select  3 Mar 2007 13:40:52 -
***
*** 1,10 
  Description:
! A  for systems lacking it (e.g., Mingw).
  
  Files:
  m4/sys_select_h.m4
  
  Depends-on:
  sys_socket
  
  configure.ac:
--- 1,12 
  Description:
! A  for systems lacking it.
  
  Files:
+ lib/sys_select_.h
  m4/sys_select_h.m4
  
  Depends-on:
+ absolute-header
  sys_socket
  
  configure.ac:
***
*** 20,26 
@MKDIR_P@ sys
rm -f [EMAIL PROTECTED] $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
! echo '#include '; \
} > [EMAIL PROTECTED]
mv [EMAIL PROTECTED] $@
  MOSTLYCLEANFILES += sys/select.h sys/select.h-t
--- 22,30 
@MKDIR_P@ sys
rm -f [EMAIL PROTECTED] $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
! sed -e 's|@''ABSOLUTE_SYS_SELECT_H''@|$(ABSOLUTE_SYS_SELECT_H)|g' \
! -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \
! < $(srcdir)/sys_select_.h; \
} > [EMAIL PROTECTED]
mv [EMAIL PROTECTED] $@
  MOSTLYCLEANFILES += sys/select.h sys/select.h-t





Re: test-getaddrinfo

2007-03-03 Thread Simon Josefsson
Bruno Haible <[EMAIL PROTECTED]> writes:

> Hi Simon,
>
> "make check" with the getaddrinfo-tests module yields a lot of output:
...
> Can you make this test silent when it succeeds? For example, write the
> output into a temporary file, and print the contents of that file or not,
> depending whether the test program exited with a failure code or successfully?

Hi!  I think there are two independent problems here:

1) The self-test requires network connectivity.

2) The self-test is noisy.

For now, I think we can ignore 1), but it might make sense to consider
a non-networked self test in the future.

For the second, I kind of prefer having self-tests be noisy, even when
they succeed.  Having that output present in build logs etc can help
understand a platform or code better.  For example, if we'd ever see
an IP address which is byte-swapped compared to the one that is
correct, we can guess that it is an endian problem.  However, making
the self-test check the return IP address for a well-known address
seems like a bad idea -- IP addresses change over time.  This is just
an example of problems with hiding the output can cause.  I'm moving
from silent self tests in most of my projects to noisy self tests, and
I suspect I had other reasons for doing so too.

But I don't feel strongly about this.  To help me understand better,
why do you consider noisy self tests a problem?

/Simon




Re: sys_socket module: make self-contained

2007-03-03 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 3/2/2007 6:33 PM:
> Since our goal is to allow people to program against the POSIX specifications,
> here is a proposed patch. It causes lib/sys/socket.h to be created on
> systems like MacOS X. Tested on Linux, MacOS X, mingw.

OK, except:

> !   if test $gl_cv_header_sys_socket_h_selfcontained = yes; then
>   SYS_SOCKET_H=''
> else
> + SYS_SOCKET_H='sys/socket.h'
> + 
>   dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
>   dnl the check for those headers unconditional; yet cygwin reports
>   dnl that the headers are present but cannot be compiled (since on
>   dnl cygwin, all socket information should come from sys/socket.h).

This comment...

> ! 
> ! AC_CHECK_HEADERS([sys/socket.h])
> ! gl_ABSOLUTE_HEADER([sys/socket.h])
> ! ABSOLUTE_SYS_SOCKET_H=\"$gl_cv_absolute_sys_socket_h\"
> ! AC_SUBST([ABSOLUTE_SYS_SOCKET_H])
> ! if test $ac_cv_header_sys_socket_h = yes; then
> !   HAVE_SYS_SOCKET_H=1
> !   HAVE_WINSOCK2_H=0
> !   HAVE_WS2TCPIP_H=0
> ! else
> !   HAVE_SYS_SOCKET_H=0

...should be moved here (and perhaps reworded a bit), to avoid future
copy-n-paste confusion :)

> !   AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
> !   if test $ac_cv_header_winsock2_h = yes; then

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF6YVU84KuGfSFAYARAummAKC3fk25dZYgiUALfcDQqYInONWuxgCg0nKi
0/hdhXoLJh2BDUzZpHuNekM=
=F/if
-END PGP SIGNATURE-




Re: test-getaddrinfo

2007-03-03 Thread Bruno Haible
Hi Simon,

> 1) The self-test requires network connectivity.
> 
> For now, I think we can ignore 1), but it might make sense to consider
> a non-networked self test in the future.

Yes. The test currently fails after 7 minutes when there is no internet
connection:

PASS: test-arpa_inet
Finding www.gnu.org service http...
res -3: Temporary failure in name resolution
Finding www.ibm.com service https...
res -3: Temporary failure in name resolution
Finding microsoft.com service http...
res -3: Temporary failure in name resolution
Finding google.org service ldap...
res -3: Temporary failure in name resolution
FAIL: test-getaddrinfo
PASS: test-netinet_in
PASS: test-stdbool
PASS: test-stdio
PASS: test-string
PASS: test-sys_socket
===
1 of 7 tests failed
===
make[4]: *** [check-TESTS] Fehler 1

real7m29.216s
user0m0.811s
sys 0m0.136s

> For the second, I kind of prefer having self-tests be noisy, even when
> they succeed.

I think it's ok for them to be noisy if they find something suspicious,
or when the test has to be skipped. (The "Skipping test because ..."
messages already showed me a few portability problems that I wouldn't
have seen otherwise.)

> why do you consider noisy self tests a problem?

Someday, I would like to use "gnulib-tool --with-tests" in the gettext builds.
So that people notice and inform me when some internals that gettext relies
upon is unreliable on some platform. There will be ca. 100 tests or so, and
if many of them output more than 1 or 2 lines when they succeed,
  - the output will be hard to read and understand (yes, I do have problems
reading the coreutils "make check" output),
  - the communication with the user who reports test failures will be harder.

Bruno





relocatable-lib fix

2007-03-03 Thread Bruno Haible
The module relocatable-lib includes relocatable.h, which uses
ENABLE_RELOCATABLE. So it needs to be defined in m4/relocatable-lib.m4.


2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* m4/relocatable-lib.m4 (gl_RELOCATABLE_LIBRARY): Define
ENABLE_RELOCATABLE here.
* m4/relocatable.m4 (gl_RELOCATABLE_BODY): Don't define it here.

--- m4/relocatable-lib.m4   1 Mar 2007 02:14:05 -   1.1
+++ m4/relocatable-lib.m4   3 Mar 2007 17:45:19 -
@@ -1,5 +1,5 @@
-# relocatable-lib.m4 serial 1
-dnl Copyright (C) 2003, 2005-2006, 2007 Free Software Foundation, Inc.
+# relocatable-lib.m4 serial 2
+dnl Copyright (C) 2003, 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.
@@ -18,6 +18,10 @@
   fi
   AC_DEFINE_UNQUOTED([INSTALLPREFIX], ["${reloc_final_prefix}"],
 [Define to the value of ${prefix}, as a string.])
+  if test $RELOCATABLE = yes; then
+AC_DEFINE([ENABLE_RELOCATABLE], 1,
+  [Define to 1 if the package shall run at any location in the 
filesystem.])
+  fi
 ])
 
 dnl Support for relocatable packages for which it is a nop.
--- m4/relocatable.m4   1 Mar 2007 02:14:05 -   1.2
+++ m4/relocatable.m4   3 Mar 2007 17:45:19 -
@@ -1,5 +1,5 @@
-# relocatable.m4 serial 8
-dnl Copyright (C) 2003, 2005-2006, 2007 Free Software Foundation, Inc.
+# relocatable.m4 serial 9
+dnl Copyright (C) 2003, 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.
@@ -38,8 +38,6 @@
   if test $RELOCATABLE = yes; then
 # --enable-relocatable implies --disable-rpath
 enable_rpath=no
-AC_DEFINE([ENABLE_RELOCATABLE], 1,
-  [Define to 1 if the package shall run at any location in the 
filesystem.])
 AC_CHECK_HEADERS([mach-o/dyld.h])
 AC_CHECK_FUNCS([_NSGetExecutablePath])
 case "$host_os" in





m4/setenv.m4 reorganization

2007-03-03 Thread Bruno Haible
For the use of m4/setenv.m4 by the relocatable stuff, it is better if
the 'setenv' part and the 'unsetenv' part are separate (because the
wrapper program needs to set environment variables like LD_LIBRARY_PATH,
but never unsets them).


2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* m4/setenv.m4 (gl_FUNC_SETENV, gl_FUNC_UNSETENV): New macros,
extracted from gt_FUNC_SETENV.
(gt_FUNC_SETENV): Remove macro.
* modules/setenv (configure.ac): Add gl_FUNC_SETENV, gl_FUNC_UNSETENV,
remove gt_FUNC_SETENV.

*** m4/setenv.m417 Jun 2006 16:10:06 -  1.6
--- m4/setenv.m43 Mar 2007 19:04:52 -
***
*** 1,16 
! # setenv.m4 serial 6
! dnl Copyright (C) 2001-2004, 2006 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([gt_FUNC_SETENV],
  [
!   AC_REPLACE_FUNCS(setenv unsetenv)
if test $ac_cv_func_setenv = no; then
  gl_PREREQ_SETENV
fi
if test $ac_cv_func_unsetenv = no; then
  gl_PREREQ_UNSETENV
else
  AC_CACHE_CHECK([for unsetenv() return type], gt_cv_func_unsetenv_ret,
--- 1,23 
! # setenv.m4 serial 7
! dnl Copyright (C) 2001-2004, 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.
  
! AC_DEFUN([gl_FUNC_SETENV],
  [
!   AC_CHECK_FUNCS_ONCE([setenv])
if test $ac_cv_func_setenv = no; then
+ AC_LIBOBJ([setenv])
  gl_PREREQ_SETENV
fi
+ ])
+ 
+ AC_DEFUN([gl_FUNC_UNSETENV],
+ [
+   AC_CHECK_FUNCS([unsetenv])
if test $ac_cv_func_unsetenv = no; then
+ AC_LIBOBJ([unsetenv])
  gl_PREREQ_UNSETENV
else
  AC_CACHE_CHECK([for unsetenv() return type], gt_cv_func_unsetenv_ret,
*** modules/setenv  13 Oct 2006 12:40:23 -  1.11
--- modules/setenv  3 Mar 2007 19:04:52 -
***
*** 14,20 
  unistd
  
  configure.ac:
! gt_FUNC_SETENV
  
  Makefile.am:
  
--- 14,21 
  unistd
  
  configure.ac:
! gl_FUNC_SETENV
! gl_FUNC_UNSETENV
  
  Makefile.am:
  





xreadlink can assume unistd

2007-03-03 Thread Bruno Haible
The 'relocatable' module now assumes the 'unistd' module (as well as
'stdbool' and others), therefore xreadlink.c can assume it as well.
And the module description should be clear about this requirement.

2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* lib/xreadlink.c: Include  unconditionally.
* modules/xreadlink (Depends-on): Add unistd.
* modules/xreadlink-with-size (Depends-on): Likewise.

*** lib/xreadlink.c 1 Mar 2007 00:07:34 -   1.25
--- lib/xreadlink.c 3 Mar 2007 19:15:44 -
***
*** 31,39 
  #include 
  #include 
  #include 
! #if HAVE_UNISTD_H
! # include 
! #endif
  
  #ifndef SIZE_MAX
  # define SIZE_MAX ((size_t) -1)
--- 31,37 
  #include 
  #include 
  #include 
! #include 
  
  #ifndef SIZE_MAX
  # define SIZE_MAX ((size_t) -1)
*** modules/xreadlink   1 Mar 2007 07:34:20 -   1.14
--- modules/xreadlink   3 Mar 2007 19:15:44 -
***
*** 8,13 
--- 8,14 
  Depends-on:
  readlink
  ssize_t
+ unistd
  xalloc
  
  configure.ac:
*** modules/xreadlink-with-size 1 Mar 2007 07:34:20 -   1.3
--- modules/xreadlink-with-size 3 Mar 2007 19:15:44 -
***
*** 8,13 
--- 8,14 
  Depends-on:
  readlink
  ssize_t
+ unistd
  xalloc
  
  configure.ac:





canonicalize-lgpl: update for relocatable

2007-03-03 Thread Bruno Haible
The install-reloc script, when creating a wrapper program, compiles a few
selected source files directly. Whereas the program not necessarily needs
these as object files. For example, GNU hello doesn't need an
  AC_LIBOBJ([canonicalize-lgpl])
but the install-reloc script compiles canonicalize-lgpl.c.

This leads to a few new autoconf macros. Here is the first one:


2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* m4/canonicalize-lgpl.m4 (gl_CANONICALIZE_LGPL_SEPARATE): New macro.

*** m4/canonicalize-lgpl.m4 6 Nov 2006 18:21:35 -   1.1
--- m4/canonicalize-lgpl.m4 3 Mar 2007 19:22:06 -
***
*** 1,5 
! # canonicalize-lgpl.m4 serial 3
! dnl Copyright (C) 2003, 2006 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.
--- 1,5 
! # canonicalize-lgpl.m4 serial 4
! dnl Copyright (C) 2003, 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.
***
*** 18,23 
--- 18,32 
fi
  ])
  
+ # Like gl_CANONICALIZE_LGPL, except prepare for separate compilation
+ # (no AC_LIBOBJ).
+ AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE],
+ [
+   AC_CHECK_DECLS_ONCE(canonicalize_file_name)
+   AC_CHECK_FUNCS_ONCE(canonicalize_file_name)
+   gl_PREREQ_CANONICALIZE_LGPL
+ ])
+ 
  # Prerequisites of lib/canonicalize-lgpl.c.
  AC_DEFUN([gl_PREREQ_CANONICALIZE_LGPL],
  [





readlink: update for relocatable

2007-03-03 Thread Bruno Haible
Likewise for 'readlink':

2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* m4/readlink.m4 (gl_FUNC_READLINK_SEPARATE): New macro.
(gl_FUNC_READLINK): Update.

*** m4/readlink.m4  19 Feb 2007 02:24:42 -  1.4
--- m4/readlink.m4  3 Mar 2007 19:29:51 -
***
*** 1,4 
! # 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,
--- 1,4 
! # readlink.m4 serial 4
  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,
***
*** 7,13 
  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)
--- 7,13 
  AC_DEFUN([gl_FUNC_READLINK],
  [
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
!   AC_CHECK_FUNCS_ONCE([readlink])
if test $ac_cv_func_readlink = no; then
  HAVE_READLINK=0
  AC_LIBOBJ(readlink)
***
*** 15,20 
--- 15,27 
fi
  ])
  
+ # Like gl_FUNC_READLINK, except prepare for separate compilation (no 
AC_LIBOBJ).
+ AC_DEFUN([gl_FUNC_READLINK_SEPARATE],
+ [
+   AC_CHECK_FUNCS_ONCE([readlink])
+   gl_PREREQ_READLINK
+ ])
+ 
  # Prerequisites of lib/readlink.c.
  AC_DEFUN([gl_PREREQ_READLINK],
  [





setenv: update for relocatable

2007-03-03 Thread Bruno Haible
Likewise for setenv.

2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* m4/setenv.m4 (gl_FUNC_SETENV_SEPARATE): New macro.
* lib/setenv.c: Compile the file only if _LIBC || !HAVE_SETENV.

*** m4/setenv.m43 Mar 2007 19:10:05 -   1.7
--- m4/setenv.m43 Mar 2007 19:38:57 -
***
*** 1,4 
! # setenv.m4 serial 7
  dnl Copyright (C) 2001-2004, 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,
--- 1,4 
! # setenv.m4 serial 8
  dnl Copyright (C) 2001-2004, 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,
***
*** 13,18 
--- 13,25 
fi
  ])
  
+ # Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
+ AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
+ [
+   AC_CHECK_FUNCS_ONCE([setenv])
+   gl_PREREQ_SETENV
+ ])
+ 
  AC_DEFUN([gl_FUNC_UNSETENV],
  [
AC_CHECK_FUNCS([unsetenv])
*** lib/setenv.c13 Sep 2006 22:38:14 -  1.18
--- lib/setenv.c3 Mar 2007 19:38:57 -
***
*** 1,4 
! /* Copyright (C) 1992,1995-1999,2000-2003,2005,2006 Free Software Foundation, 
Inc.
 This file is part of the GNU C Library.
  
 This program is free software; you can redistribute it and/or modify
--- 1,4 
! /* Copyright (C) 1992,1995-1999,2000-2003,2005-2007 Free Software Foundation, 
Inc.
 This file is part of the GNU C Library.
  
 This program is free software; you can redistribute it and/or modify
***
*** 31,36 
--- 32,39 
  # include 
  #endif
  
+ #if _LIBC || !HAVE_SETENV
+ 
  #if !_LIBC
  # include "allocsa.h"
  #endif
***
*** 326,328 
--- 329,333 
  weak_alias (__setenv, setenv)
  weak_alias (__clearenv, clearenv)
  #endif
+ 
+ #endif /* _LIBC || !HAVE_SETENV */





strerror: update for relocatable

2007-03-03 Thread Bruno Haible
Likewise for strerror.

2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* m4/strerror.m4 (gl_FUNC_STRERROR_SEPARATE): New macro.
(gl_FUNC_STRERROR): Nop.
* lib/strerror.c: Compile the file only if !HAVE_STRERROR.

*** m4/strerror.m4  23 Jan 2005 08:06:57 -  1.3
--- m4/strerror.m4  3 Mar 2007 19:44:35 -
***
*** 1,17 
! # strerror.m4 serial 2
! dnl Copyright (C) 2002 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_STRERROR],
  [
!   AC_REPLACE_FUNCS(strerror)
if test $ac_cv_func_strerror = no; then
  gl_PREREQ_STRERROR
fi
  ])
  
  # Prerequisites of lib/strerror.c.
  AC_DEFUN([gl_PREREQ_STRERROR], [
:
--- 1,25 
! # strerror.m4 serial 3
! dnl Copyright (C) 2002, 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_STRERROR],
  [
!   AC_CHECK_FUNCS_ONCE([strerror])
if test $ac_cv_func_strerror = no; then
+ AC_LIBOBJ([strerror])
  gl_PREREQ_STRERROR
fi
  ])
  
+ # Like gl_FUNC_STRERROR, except prepare for separate compilation (no 
AC_LIBOBJ).
+ AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
+ [
+   AC_CHECK_FUNCS_ONCE([strerror])
+   gl_PREREQ_STRERROR
+ ])
+ 
  # Prerequisites of lib/strerror.c.
  AC_DEFUN([gl_PREREQ_STRERROR], [
:
*** lib/strerror.c  13 Sep 2006 22:38:14 -  1.5
--- lib/strerror.c  3 Mar 2007 19:44:35 -
***
*** 1,6 
  /* strerror.c --- ANSI C compatible system error routine
  
!Copyright (C) 1986, 1988, 1989, 1991, 2002, 2003, 2006 Free
 Software Foundation, Inc.
  
 This program is free software; you can redistribute it and/or modify
--- 1,6 
  /* strerror.c --- ANSI C compatible system error routine
  
!Copyright (C) 1986, 1988, 1989, 1991, 2002, 2003, 2006, 2007 Free
 Software Foundation, Inc.
  
 This program is free software; you can redistribute it and/or modify
***
*** 21,26 
--- 21,28 
  
  #include 
  
+ #if !HAVE_STRERROR
+ 
  /* Don't include , since it may or may not declare
 sys_errlist and its declarations may collide with ours.  Just
 declare the stuff that we need directly.  Standard hosted C89
***
*** 45,47 
--- 47,51 
else
  return sys_errlist[n];
  }
+ 
+ #endif /* !HAVE_STRERROR */





reorganize relocwrapper dependencies

2007-03-03 Thread Bruno Haible
Hi Ben,

I think it's useful to separate the object files that end up in a relocatable
program from the object files that make up the relocatable wrapper (on
non-glibc systems). Reasons:
  - The size of the wrapper should be kept small, which means no xalloc
in particular.
  - The CPPFLAGS that the user sets for his compilations may hurt when
applied to progreloc.c.
  - It's useless for GNU hello's libgnu.a to contain xreadlink.o and similar,
since these functions are not used by GNU hello itself.

For this reason, AC_LIBOBJ should be avoided here. This implies the use
of different autoconf macros, and therefore the direct use of e.g. xreadlink.c
without going through module 'xreadlink'.


2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* modules/relocatable-prog-wrapper: New file.
* modules/relocatable (Depends-on): Add it. Remove all other
dependencies except progname.
(Files): Remove build-aux/install-reloc, lib/relocwrapper.c.

== modules/relocatable-prog-wrapper ===
Description:
Source for the wrapper program that is required for making programs relocatable
that depend on shared libraries installed with the same installation prefix.

Files:
build-aux/install-reloc
lib/relocwrapper.c
lib/progname.h
lib/progname.c
lib/progreloc.c
lib/xreadlink.h
lib/xreadlink.c
lib/readlink.h
lib/readlink.c
lib/canonicalize.h
lib/canonicalize-lgpl.c
lib/allocsa.h
lib/allocsa.c
lib/relocatable.h
lib/relocatable.c
lib/setenv.h
lib/setenv.c
lib/strerror.c
lib/c-ctype.h
lib/c-ctype.c
m4/allocsa.m4
m4/canonicalize-lgpl.m4
m4/eealloc.m4
m4/longlong.m4
m4/longdouble.m4
m4/readlink.m4
m4/relocatable-lib.m4
m4/setenv.m4
m4/strerror.m4

Depends-on:
alloca-opt
pathmax
ssize_t
stdbool
unistd

configure.ac:
gl_FUNC_READLINK_SEPARATE
gl_CANONICALIZE_LGPL_SEPARATE
gl_ALLOCSA
gl_RELOCATABLE_LIBRARY
gl_FUNC_SETENV_SEPARATE
gl_FUNC_STRERROR_SEPARATE

Makefile.am:

Include:

License:
GPL

Maintainer:
Bruno Haible, Ben Pfaff

===
*** modules/relocatable 1 Mar 2007 03:04:56 -   1.2
--- modules/relocatable 3 Mar 2007 19:59:39 -
***
*** 4,27 
  
  Files:
  build-aux/config.libpath
- build-aux/install-reloc
  build-aux/reloc-ldflags
  doc/relocatable.texi
  lib/relocatable.h
  lib/relocatable.c
  lib/progreloc.c
- lib/relocwrapper.c
  m4/relocatable.m4
  m4/relocatable-lib.m4
  
  Depends-on:
! canonicalize
! c-ctype
  progname
- setenv
- strerror
- unistd
- xalloc
  
  configure.ac:
  gl_RELOCATABLE([$gl_source_base])
--- 4,20 
  
  Files:
  build-aux/config.libpath
  build-aux/reloc-ldflags
  doc/relocatable.texi
  lib/relocatable.h
  lib/relocatable.c
  lib/progreloc.c
  m4/relocatable.m4
  m4/relocatable-lib.m4
  
  Depends-on:
! relocatable-prog-wrapper
  progname
  
  configure.ac:
  gl_RELOCATABLE([$gl_source_base])





Re: reorganize relocwrapper dependencies

2007-03-03 Thread Ben Pfaff
Bruno Haible <[EMAIL PROTECTED]> writes:

> I think it's useful to separate the object files that end up in a relocatable
> program from the object files that make up the relocatable wrapper (on
> non-glibc systems). Reasons:
[...]
> For this reason, AC_LIBOBJ should be avoided here. This implies the use
> of different autoconf macros, and therefore the direct use of e.g. xreadlink.c
> without going through module 'xreadlink'.

OK.  This makes sense.

Thanks for doing this work.
-- 
"The sound of peacocks being shredded can't possibly be
 any worse than the sound of peacocks not being shredded."
Tanuki the Raccoon-dog in the Monastery





relocatable-script: minimize dependencies

2007-03-03 Thread Bruno Haible
A package that needs relocatable-script does not need the gl_RELOCATABLE
machinery for relocatable _programs_, nor does it need any AC_DEFINEs.
Therefore I'm simplifying the dependencies like this:

2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* modules/relocatable-script (Files): Add doc/relocatable.texi,
m4/relocatable-lib.m4.
(Depends-on): Remove 'relocatable'.
(configure.ac): Add gl_RELOCATABLE_NOP.

--- modules/relocatable-script  1 Mar 2007 02:09:07 -   1.1
+++ modules/relocatable-script  3 Mar 2007 20:22:30 -
@@ -3,12 +3,14 @@
 function properly when copied to an arbitrary directory.
 
 Files:
+doc/relocatable.texi
 build-aux/relocatable.sh.in
+m4/relocatable-lib.m4
 
 Depends-on:
-relocatable
 
 configure.ac:
+AC_REQUIRE([gl_RELOCATABLE_NOP])
 relocatable_sh=$ac_aux_dir/relocatable.sh.in
 AC_SUBST_FILE([relocatable_sh])
 





module 'relocatable' renamed to 'relocatable-prog'

2007-03-03 Thread Bruno Haible
Since this module is by far the most complex (compared to 'relocatable-lib'
and 'relocatable-script'), and since users may have packages that install
libraries or scripts, but no programs, there is no point in a naming
convention that suggests that 'relocatable' is the most basic among the
three modules. I am therefore renaming it:

2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* modules/relocatable-prog: Renamed from modules/relocatable.
* doc/relocatable-maint.texi: Talk about module 'relocatable-prog'.

--- doc/relocatable-maint.texi  2 Mar 2007 01:53:11 -   1.2
+++ doc/relocatable-maint.texi  3 Mar 2007 20:35:19 -
@@ -20,17 +20,17 @@
 possible to do the same thing with a hard link @emph{only} if the hard
 link file is in the same directory as the real program.
 
-The @code{relocatable} module aims to ease the process of making a GNU
-program relocatable.  It helps overcome two obstacles.  First, it aids
+The @code{relocatable-prog} module aims to ease the process of making a
+GNU program relocatable.  It helps overcome two obstacles.  First, it aids
 with relocating the hard-coded references to absolute file names that
 GNU programs often contain.  These references must be fixed up at
 runtime if a program is to be successfully relocated.  The
[EMAIL PROTECTED] module provides a function @code{relocate} that
[EMAIL PROTECTED] module provides a function @code{relocate} that
 does this job.
 
 Second, the loader must be able to find shared libraries linked to
 relocatable executables or referenced by other shared libraries linked
-to relocatable executables.  The @code{relocatable} module helps out
+to relocatable executables.  The @code{relocatable-prog} module helps out
 here in a platform-specific way:
 
 @itemize
@@ -58,7 +58,7 @@
 
 @enumerate
 @item
-Import the @code{relocatable} module.
+Import the @code{relocatable-prog} module.
 
 @item
 In every program, add to @code{main} as the first statement (even





Re: byteswap test failure

2007-03-03 Thread Paul Eggert
Bruno Haible <[EMAIL PROTECTED]> writes:

> 2007-03-02  Bruno Haible  <[EMAIL PROTECTED]>
>
>   * lib/byteswap_.h (bswap_32): Fix formula.

Thanks.  That patch fixes such an obvious typo that I'd install it if
Oskar doesn't object in a day or two.




relocatable-lib and relocatable-lib-lgpl

2007-03-03 Thread Bruno Haible
There are libraries under GPL, which can use xalloc, and libraries under
LGPL, which cannot. I'm creating a module description for each case. The
code is the same.

2007-03-03  Bruno Haible  <[EMAIL PROTECTED]>

* modules/relocatable-lib-lgpl: Renamed from modules/relocatable-lib.
* modules/relocatable-lib: New file.

--- modules/relocatable-lib-lgpl2007-03-01 03:04:48.0 +0100
+++ modules/relocatable-lib 2007-03-04 00:29:15.0 +0100
@@ -9,18 +9,18 @@
 m4/relocatable-lib.m4
 
 Depends-on:
+xalloc
 
 configure.ac:
 
 Makefile.am:
-DEFS += -DNO_XMALLOC
 lib_SOURCES += relocatable.c
 
 Include:
 "relocatable.h"
 
 License:
-LGPL
+GPL
 
 Maintainer:
 Bruno Haible, Ben Pfaff





url in GPL

2007-03-03 Thread Karl Berry
Eric and all,

rms has accepted the idea of adding a url (http://www.gnu.org/licenses
is what I suggested) to the canonical notice at the top of source files.
I hope he will have it in the next GPLv3 draft.

Thanks,
Karl