In a testdir created through ./gnulib-tool --create-testdir --dir=/tmp/testdir --single-configure mbrtowc acl argmatch backup-rename backupfile closein closeout copy-file csharpcomp csharpexec dfa exclude fnmatch fnmatch-gnu fnmatch-posix glob human javacomp javaexec javaversion mbfile mbiter mbmemcasecmp mbmemcasecoll mbrlen mbscasecmp mbscasestr mbschr mbscspn mbsinit mbslen mbsncasecmp mbsnlen mbsnrtowcs mbspbrk mbspcasecmp mbsrchr mbsrtowcs mbssep mbsspn mbsstr mbstok_r mbswidth mbuiter mkdir-p propername quote quotearg quotearg-simple regex-quote rpmatch sh-quote system-quote trim unistdio/ulc-asnprintf unistdio/ulc-fprintf unistdio/ulc-vasnprintf unistdio/ulc-vasprintf unistdio/ulc-vfprintf unistdio/ulc-vsnprintf unistdio/ulc-vsprintf xfreopen xmemcoll yesno
I'm getting a compilation failure on AIX: depbase=`echo openat-proc.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; gcc -std=gnu11 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gllib -I.. -DGNULIB_STRICT_CHECKING=1 -I/home/haible/prefix32/include -Wall -D_THREAD_SAFE -g -O2 -MT openat-proc.o -MD -MP -MF $depbase.Tpo -c -o openat-proc.o ../../gllib/openat-proc.c && mv -f $depbase.Tpo $depbase.Po In file included from /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.1/include-fixed/fcntl.h:234:0, from ./fcntl.h:67, from ../../gllib/openat-proc.c:26: ./unistd.h:619:27: fatal error: getopt-cdefs.h: No such file or directory # include <getopt-cdefs.h> ^ compilation terminated. The cause is that the gltests directory contains module 'getopt-posix' (through the dependency chain xstrtol-tests -> xstrtol-error -> getopt-gnu -> getopt-posix or argp-version-etc-tests -> argp -> getopt-gnu -> getopt-posix ), and this module arranges to modify unistd.h. But unistd.h is in gllib/ and therefore its use within the gllib/ directory cannot include files that are in gltests/. This patch fixes it. It makes uses of a module indicator @GNULIB_GETOPT_POSIX@, which expands to IN_GNULIB_TESTS, i.e. to 0 inside the gllib/ directory but 1 inside the gltests/ directory. 2020-01-03 Bruno Haible <br...@clisp.org> getopt-posix: Fix compilation failure in testdirs. * lib/unistd.in.h: Include <getopt-cdefs.h> and <getopt-pfx-core.h> only when the gnulib module 'getopt-posix' is enabled. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_GETOPT_POSIX. * modules/getopt-posix (configure.ac): Set GNULIB_GETOPT_POSIX as a module indicator. * modules/unistd (Makefile.am): Substitute GNULIB_GETOPT_POSIX. diff --git a/lib/unistd.in.h b/lib/unistd.in.h index ecf8fbe..6db7ff2 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -141,7 +141,7 @@ /* Get getopt(), optarg, optind, opterr, optopt. */ -#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT +#if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT # include <getopt-cdefs.h> # include <getopt-pfx-core.h> #endif diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 7453866..ea2bb01 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 76 +# unistd_h.m4 serial 77 dnl Copyright (C) 2006-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -84,6 +84,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME]) GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN]) GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) + GNULIB_GETOPT_POSIX=0; AC_SUBST([GNULIB_GETOPT_POSIX]) GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) GNULIB_GETPASS=0; AC_SUBST([GNULIB_GETPASS]) GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL]) diff --git a/modules/getopt-posix b/modules/getopt-posix index 5ee7bfd..cbcfff5 100644 --- a/modules/getopt-posix +++ b/modules/getopt-posix @@ -29,6 +29,7 @@ if test $REPLACE_GETOPT = 1; then GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT=1 fi AC_SUBST([GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT]) +gl_UNISTD_MODULE_INDICATOR([getopt-posix]) Makefile.am: BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H) diff --git a/modules/unistd b/modules/unistd index b68029d..3c28f36 100644 --- a/modules/unistd +++ b/modules/unistd @@ -59,6 +59,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \ -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \ -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \ + -e 's/@''GNULIB_GETOPT_POSIX''@/$(GNULIB_GETOPT_POSIX)/g' \ -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \ -e 's/@''GNULIB_GETPASS''@/$(GNULIB_GETPASS)/g' \ -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \