bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unistd.h and getopt.h (was: Re: libidn 1.23)


From: Bruno Haible
Subject: unistd.h and getopt.h (was: Re: libidn 1.23)
Date: Sat, 26 Nov 2011 21:09:42 +0100
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

[Followup to 
<http://lists.gnu.org/archive/html/help-libidn/2011-11/msg00010.html>]

Simon Josefsson wrote:
> > Making check in lib/gltests
> > ...
> >   CC     putenv.o
> > "./unistd.h", line 121.11: 1506-296 (S) #include file <getopt.h> not found.
> > make: 1254-004 The error code from the last command is 1.
> >
> > The build directory contains the files
> >
> >   lib/gltests/unistd.h
> >   win32/include/unistd.h
> >   gl/unistd.h
> >
> >   gl/getopt.h
> >
> > The complete command line is
> >
> > xlc -D_ALL_SOURCE -O -DHAVE_CONFIG_H -I. -I../..  
> > -DIN_LIBIDN_GNULIB_TESTS=1 -I. -I. -I../.. -I./../.. -I../../lib/gl 
> > -I./../../lib/gl -D_THREAD_SAFE -I/home/haible/prefix-aix51-cc/include  -g 
> > -c -o putenv.o putenv.c
> > "./unistd.h", line 121.11: 1506-296 (S) #include file <getopt.h> not found.
> > gmake[3]: *** [putenv.o] Error 1
> >
> > As you can see, a -I../../gl option is missing.
> 
> The Makefile.am there is generated by gnulib.  The problem here was
> caused by the self-tests for the gnulib instance in lib/ is pulling in
> unistd.h and the gnulib instance in ./ needs unistd+getopt.  So the
> unistd.h copy in lib/gltests/ ends up including getopt.h (since it
> shares the same m4 code), even though it is not needed there, and
> getopt.h wasn't copied into lib/gltests/.

Thanks for the analysis. To summarize:
You have 2 gnulib-tool invocations in the scope of a single configure.ac file.
  - One gnulib-tool invocation asks for 'unistd'.
  - A second gnulib-tool invocation asks for 'unistd' and 'getopt'.
The latter causes the m4 macros to set the GNULIB_UNISTD_H_GETOPT variable
to 1. So code in the directory for the first gnulib-tool invocation tries
to include <getopt.h>, which does not exist.

This patch fixes it at the gnulib level. (Tested on AIX 5.1.) You can remove
the workaround that you added yesterday.


2011-11-26  Bruno Haible  <address@hidden>

        Fix conflict between two instantiations of module 'unistd'.
        * gnulib-tool (func_emit_autoconf_snippet): Substitute
        ${include_guard_prefix} also in the autoconf snippet.
        * m4/getopt.m4 (gl_FUNC_GETOPT_POSIX): Don't set GNULIB_UNISTD_H_GETOPT.
        * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Don't initialize
        GNULIB_UNISTD_H_GETOPT.
        * modules/getopt-posix (configure.ac): Set the
        GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT variable.
        * modules/getopt-gnu (configure.ac): Likewise.
        * modules/unistd (Makefile.am): Change the substitution value of
        GNULIB_UNISTD_H_GETOPT to depend on the include guard prefix.
        Reported by Simon Josefsson.

--- gnulib-tool.orig    Sat Nov 26 21:02:28 2011
+++ gnulib-tool Sat Nov 26 19:53:40 2011
@@ -3852,6 +3852,8 @@
 # - local_gnulib_dir  from --local-dir
 # - modcache          true or false, from --cache-modules/--no-cache-modules
 # - sed_replace_build_aux  sed expression that replaces reference to build-aux
+# - sed_replace_include_guard_prefix
+#                     sed expression for resolving ${gl_include_guard_prefix}
 # - module            the module name
 # - toplevel          true or false. 'false' means a subordinate use of
 #                     gnulib-tool.
@@ -3874,6 +3876,7 @@
     func_get_autoconf_snippet "$module" \
       | sed -e '/^$/d;' -e "s/^/$indentation/" \
             -e "$sed_replace_build_aux" \
+            -e "$sed_replace_include_guard_prefix" \
       | { if $disable_libtool; then
             sed -e 's/\$gl_cond_libtool/false/g' \
                 -e 's/gl_libdeps/gltests_libdeps/g' \
@@ -3903,6 +3906,8 @@
 # - local_gnulib_dir  from --local-dir
 # - modcache          true or false, from --cache-modules/--no-cache-modules
 # - sed_replace_build_aux  sed expression that replaces reference to build-aux
+# - sed_replace_include_guard_prefix
+#                     sed expression for resolving ${gl_include_guard_prefix}
 # - modules           the list of modules.
 # - verifier          one of func_verify_module, func_verify_nontests_module,
 #                     func_verify_tests_module. It selects the subset of
--- m4/getopt.m4.orig   Sat Nov 26 21:02:28 2011
+++ m4/getopt.m4        Sat Nov 26 19:49:35 2011
@@ -1,4 +1,4 @@
-# getopt.m4 serial 38
+# getopt.m4 serial 39
 dnl Copyright (C) 2002-2006, 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,
@@ -25,8 +25,6 @@
   if test $REPLACE_GETOPT = 1; then
     dnl Arrange for getopt.h to be created.
     gl_GETOPT_SUBSTITUTE_HEADER
-    dnl Arrange for unistd.h to include getopt.h.
-    GNULIB_UNISTD_H_GETOPT=1
   fi
 ])
 
--- m4/unistd_h.m4.orig Sat Nov 26 21:02:28 2011
+++ m4/unistd_h.m4      Sat Nov 26 19:49:20 2011
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 61
+# unistd_h.m4 serial 62
 dnl Copyright (C) 2006-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,
@@ -98,7 +98,6 @@
   GNULIB_SYMLINK=0;              AC_SUBST([GNULIB_SYMLINK])
   GNULIB_SYMLINKAT=0;            AC_SUBST([GNULIB_SYMLINKAT])
   GNULIB_TTYNAME_R=0;            AC_SUBST([GNULIB_TTYNAME_R])
-  GNULIB_UNISTD_H_GETOPT=0;      AC_SUBST([GNULIB_UNISTD_H_GETOPT])
   GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
   GNULIB_UNISTD_H_SIGPIPE=0;     AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
   GNULIB_UNLINK=0;               AC_SUBST([GNULIB_UNLINK])
--- modules/getopt-gnu.orig     Sat Nov 26 21:02:28 2011
+++ modules/getopt-gnu  Sat Nov 26 20:58:43 2011
@@ -14,7 +14,10 @@
   AC_LIBOBJ([getopt])
   AC_LIBOBJ([getopt1])
   gl_PREREQ_GETOPT
+  dnl Arrange for unistd.h to include getopt.h.
+  GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT=1
 fi
+AC_SUBST([GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT])
 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
 
 Makefile.am:
--- modules/getopt-posix.orig   Sat Nov 26 21:02:28 2011
+++ modules/getopt-posix        Sat Nov 26 20:58:39 2011
@@ -21,7 +21,10 @@
   AC_LIBOBJ([getopt])
   AC_LIBOBJ([getopt1])
   gl_PREREQ_GETOPT
+  dnl Arrange for unistd.h to include getopt.h.
+  GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT=1
 fi
+AC_SUBST([GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT])
 
 Makefile.am:
 BUILT_SOURCES += $(GETOPT_H)
--- modules/unistd.orig Sat Nov 26 21:02:28 2011
+++ modules/unistd      Sat Nov 26 20:59:36 2011
@@ -70,7 +70,7 @@
              -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \
              -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \
              -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \
-             -e 's/@''GNULIB_UNISTD_H_GETOPT''@/$(GNULIB_UNISTD_H_GETOPT)/g' \
+             -e 
's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT)/g'
 \
              -e 
's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \
              -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' 
\
              -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \

-- 
In memoriam Gavriel Holtzberg <http://en.wikipedia.org/wiki/Gavriel_Holtzberg>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]