Re: Accommodate non-recursive Automake in a less hacky way
Jim Meyering wrote: > I want to switch every package for which I used the hacky way. > Hoping we can remove the 'non-recursive-gnulib-prefix-hack' support > code before too long. coreutils and bison have switched already. Therefore I'm now deprecating the module: 2021-12-19 Bruno Haible non-recursive-gnulib-prefix-hack: Deprecate module. * modules/non-recursive-gnulib-prefix-hack (Status, Notice): New sections. diff --git a/modules/non-recursive-gnulib-prefix-hack b/modules/non-recursive-gnulib-prefix-hack index a4b13736c..c188e93f4 100644 --- a/modules/non-recursive-gnulib-prefix-hack +++ b/modules/non-recursive-gnulib-prefix-hack @@ -2,6 +2,15 @@ Description: Adjust a gnulib-generated gnulib.mk file and configure script so that they are usable in a non-recursive make framework. +Status: +deprecated + +Notice: +This module is deprecated. Instead, + - use the gnulib-tool option '--automake-subdir', + - remove the explicit invocation of build-aux/prefix-gnulib-mk from your build +system. + Files: build-aux/prefix-gnulib-mk m4/non-recursive-gnulib-prefix-hack.m4
Re: Accommodate non-recursive Automake in a less hacky way
Another fix is needed, for the 'libtextstyle-optional' module. Uncovered by the continuous integration. 2021-12-18 Bruno Haible libtextstyle-optional: Fix generation of textstyle.h (regr. 2021-12-15). * m4/libtextstyle-optional.m4 (gl_LIBTEXTSTYLE_OPTIONAL): Invoke gl_CONDITIONAL_HEADER. diff --git a/m4/libtextstyle-optional.m4 b/m4/libtextstyle-optional.m4 index 74a5aeaf2..2b29ae4a5 100644 --- a/m4/libtextstyle-optional.m4 +++ b/m4/libtextstyle-optional.m4 @@ -1,4 +1,4 @@ -# libtextstyle-optional.m4 serial 3 +# libtextstyle-optional.m4 serial 4 dnl Copyright (C) 2019-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -29,4 +29,11 @@ AC_DEFUN([gl_LIBTEXTSTYLE_OPTIONAL], AC_REQUIRE([AC_C_INLINE]) AC_CHECK_FUNCS_ONCE([tcdrain]) fi + + dnl Update the value of the TEXTSTYLE_H variable and the + dnl GL_GENERATE_TEXTSTYLE_H conditional. + dnl In most modules, the gl_CONDITIONAL_HEADER invocation belongs in the + dnl module description, not the .m4 file. But here it's OK, because it does + dnl not make sense to AC_REQUIRE([gl_LIBTEXTSTYLE_OPTIONAL]). + gl_CONDITIONAL_HEADER([textstyle.h]) ])
Re: Accommodate non-recursive Automake in a less hacky way
The first patch handled option --gnu-make in lib/Makefile.in but not in tests/Makefile.in. Fixed as follows: 2021-12-18 Bruno Haible Fix support for --gnu-make in tests (regression 2021-12-15). * gnulib-tool (func_emit_tests_Makefile_am): When producing output for GNU make, eliminate %reldir% tokens. diff --git a/gnulib-tool b/gnulib-tool index 0d2b7e635..d15c79513 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -4156,9 +4156,9 @@ func_emit_tests_Makefile_am () { echo "## begin gnulib module $module" if $gnu_make; then echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))" - convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/' -else - convert_to_gnu_make= + convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1))/' + convert_to_gnu_make_2='s|%reldir%/||g' + convert_to_gnu_make_3='s|%reldir%|.|g' fi echo if test "$cond_dependencies" = true; then @@ -4171,13 +4171,27 @@ func_emit_tests_Makefile_am () fi fi fi -sed "$convert_to_gnu_make" "$tmp"/amsnippet1 +if $gnu_make; then + sed -e "$convert_to_gnu_make_1" \ + -e "$convert_to_gnu_make_2" \ + -e "$convert_to_gnu_make_3" \ + "$tmp"/amsnippet1 +else + cat "$tmp"/amsnippet1 +fi if test "$cond_dependencies" = true; then if func_cond_module_p "$module"; then echo "endif" fi fi -sed "$convert_to_gnu_make" "$tmp"/amsnippet2 +if $gnu_make; then + sed -e "$convert_to_gnu_make_1" \ + -e "$convert_to_gnu_make_2" \ + -e "$convert_to_gnu_make_3" \ + "$tmp"/amsnippet2 +else + cat "$tmp"/amsnippet2 +fi if $gnu_make; then echo "endif" fi
Re: Accommodate non-recursive Automake in a less hacky way
Paul Eggert wrote: > Unless I'm missing something, the "Move .h file names out of the *.m4 > files" patch omitted an "if GL_GENERATE_GEOPT_H" in getopt-posix. I > installed the attached to finish this part up. This was not a regression. The Automake conditional was in fact not used, since the beginning of the getopt-posix and getopt-gnu modules. Apparently we considered this optimization "not worth it". But this optimization is OK. I verified that it works fine on - Linux/glibc, from CentOS 6 to Ubuntu 20.04 - Linux/musl - Hurd - FreeBSD, NetBSD, OpenBSD - macOS 10, 12 - AIX 7.1 - Solaris 9, 10, 11 - IRIX 6.5 Bruno
Re: Accommodate non-recursive Automake in a less hacky way
These patches contained a mistake regarding module 'getopt-posix': On AIX I get a build failure source='../../../getopt-posix/gllib/unistd.c' object='unistd.o' libtool=no DEPDIR=.deps depmode=xlc /bin/sh ../../../getopt-posix/build-aux/depcomp xlc -q64 -qthreaded -qtls -DHAVE_CONFIG_H -I. -I../../../getopt-posix/gllib -I.. -DGNULIB_STRICT_CHECKING=1 -I/home/haible/prefix64/include -D_THREAD_SAFE -g -c -o unistd.o ../../../getopt-posix/gllib/unistd.c "./unistd.h", line 658.11: 1506-296 (S) #include file not found. This patch fixes it. 2021-12-17 Bruno Haible getopt-posix: Fix build on AIX (regression 2021-12-15). * modules/getopt-posix (configure.ac): Arrange to generate getopt-cdefs.h. (Makefile.am): Separate the rules for getopt.h and getopt-cdefs.h. diff --git a/modules/getopt-posix b/modules/getopt-posix index b9caa6a47..ff950f2fa 100644 --- a/modules/getopt-posix +++ b/modules/getopt-posix @@ -23,6 +23,7 @@ snippet/arg-nonnull configure.ac: gl_FUNC_GETOPT_POSIX gl_CONDITIONAL_HEADER([getopt.h]) +gl_CONDITIONAL_HEADER([getopt-cdefs.h]) AC_PROG_MKDIR_P if test $REPLACE_GETOPT = 1; then AC_LIBOBJ([getopt]) @@ -53,7 +54,12 @@ getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) < $(srcdir)/getopt.in.h; \ } > $@-t && \ mv -f $@-t $@ +else +getopt.h: $(top_builddir)/config.status + rm -f $@ +endif +if GL_GENERATE_GETOPT_CDEFS_H getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ @@ -62,7 +68,7 @@ getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status } > $@-t && \ mv -f $@-t $@ else -getopt.h getopt-cdefs.h: $(top_builddir)/config.status +getopt-cdefs.h: $(top_builddir)/config.status rm -f $@ endif
Re: Accommodate non-recursive Automake in a less hacky way
Unless I'm missing something, the "Move .h file names out of the *.m4 files" patch omitted an "if GL_GENERATE_GEOPT_H" in getopt-posix. I installed the attached to finish this part up. Please feel free to revert if I messed up.diff --git a/ChangeLog b/ChangeLog index e1be947a3..6fee602cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2021-12-16 Paul Eggert + getopt-posix: omit unnessary building of getopt.h + * modules/getopt-posix (getopt.h, getopt-cdefs.h): + Build only if GL_GENERATE_GETOPT_H. + stdint: omit duplicate gl_CONFIGURE_HEADER calls * modules/stdint (configure.ac): Omit ‘gl_CONDITIONAL_HEADER([limits.h])’, since stdint depends on diff --git a/modules/getopt-posix b/modules/getopt-posix index bac9dc57c..b9caa6a47 100644 --- a/modules/getopt-posix +++ b/modules/getopt-posix @@ -38,6 +38,7 @@ BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H) # We need the following in order to create when the system # doesn't have one that works with the given compiler. +if GL_GENERATE_GETOPT_H getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) $(AM_V_GEN)rm -f $@-t $@ && \ $(MKDIR_P) '%reldir%' && \ @@ -60,6 +61,10 @@ getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status < $(srcdir)/getopt-cdefs.in.h; \ } > $@-t && \ mv -f $@-t $@ +else +getopt.h getopt-cdefs.h: $(top_builddir)/config.status + rm -f $@ +endif MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t
Re: Accommodate non-recursive Automake in a less hacky way
On 12/16/21 03:42, Bruno Haible wrote: Jim Meyering wrote: I want to switch every package for which I used the hacky way. This patch is all you need for coreutils. Thanks, I installed that.
Re: Accommodate non-recursive Automake in a less hacky way
Jim Meyering wrote: > I want to switch every package for which I used the hacky way. This patch is all you need for coreutils. Bruno diff --git a/bootstrap.conf b/bootstrap.conf index 2b66bc42d..c2f74f406 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -182,7 +182,6 @@ gnulib_modules=" mountlist mpsort netinet_in - non-recursive-gnulib-prefix-hack nproc nstrftime obstack @@ -339,7 +338,7 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\ ' gnulib_tool_option_extras="--tests-base=gnulib-tests --with-tests --symlink\ - --makefile-name=gnulib.mk + --makefile-name=gnulib.mk --automake-subdir " # Build prerequisites @@ -373,9 +372,6 @@ bootstrap_post_import_hook () && chmod a-w $tmp-1 $tmp-2 \ && mv -f $tmp-1 $m4f && mv -f $tmp-2 $mkf) - # Massage lib/gnulib.mk before using it later in the bootstrapping process. - build-aux/prefix-gnulib-mk --lib-name=$gnulib_name lib/$gnulib_mk - # Regenerate src/single-binary.mk (mkf=src/single-binary.mk tmp=single-binary.tmp \ && rm -f $mkf $tmp \
Re: Accommodate non-recursive Automake in a less hacky way
Two additional patches in this area: 2021-12-15 Bruno Haible automake-subdir support: Support the libunistring modules. * m4/libunistring-base.m4 (gl_LIBUNISTRING_LIBHEADER): Use the value of the gl_source_base_prefix variable. 2021-12-15 Bruno Haible automake-subdir support: Look for 'subdir-objects' also in configure.ac. * gnulib-tool: Look for the automake options also in the first argument of the AM_INIT_AUTOMAKE invocation in configure.ac. >From b8124d982f454b8526b5e11934a2f71faac2b600 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 15 Dec 2021 21:49:41 +0100 Subject: [PATCH 1/3] automake-subdir support: Look for 'subdir-objects' also in configure.ac. * gnulib-tool: Look for the automake options also in the first argument of the AM_INIT_AUTOMAKE invocation in configure.ac. --- ChangeLog | 6 ++ gnulib-tool | 20 +--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5048863fa..dafd27b66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-12-15 Bruno Haible + + automake-subdir support: Look for 'subdir-objects' also in configure.ac. + * gnulib-tool: Look for the automake options also in the first argument + of the AM_INIT_AUTOMAKE invocation in configure.ac. + 2021-12-15 Bruno Haible Add simple examples. diff --git a/gnulib-tool b/gnulib-tool index 70ea17a4c..0d2b7e635 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -1594,7 +1594,6 @@ func_determine_path_separator # "autoconf --trace=AC_PREREQ" fails with an error message like this: # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory # autom4te: m4 failed with exit status: 1 -prereqs= my_sed_traces=' s,#.*$,, s,^dnl .*$,, @@ -1621,10 +1620,25 @@ func_determine_path_separator # Determine whether --automake-subdir is supported. if $automake_subdir; then found_subdir_objects=false +if test -n "$configure_ac"; then + my_sed_traces=' +s,#.*$,, +s,^dnl .*$,, +s, dnl .*$,, +/AM_INIT_AUTOMAKE/ { + s,^.*AM_INIT_AUTOMAKE([[ ]*\([^])]*\).*$,\1,p +}' + automake_options=`sed -n -e "$my_sed_traces" < "$configure_ac"` + for option in $automake_options; do +case "$option" in + subdir-objects ) found_subdir_objects=true ;; +esac + done +fi if test -f "${destdir:-.}"/Makefile.am; then automake_options=`sed -n -e 's/^AUTOMAKE_OPTIONS[ ]*=\(.*\)$/\1/p' "${destdir:-.}"/Makefile.am` - for arg in $automake_options; do -case "$arg" in + for option in $automake_options; do +case "$option" in subdir-objects ) found_subdir_objects=true ;; esac done -- 2.25.1 >From aa4780cde60b76252e47bc6b00c111afbd2a9110 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 15 Dec 2021 23:24:48 +0100 Subject: [PATCH 3/3] automake-subdir support: Support the libunistring modules. * m4/libunistring-base.m4 (gl_LIBUNISTRING_LIBHEADER): Use the value of the gl_source_base_prefix variable. --- ChangeLog | 6 ++ m4/libunistring-base.m4 | 8 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 197d497f8..1a8a8e79a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-12-15 Bruno Haible + + automake-subdir support: Support the libunistring modules. + * m4/libunistring-base.m4 (gl_LIBUNISTRING_LIBHEADER): Use the value of + the gl_source_base_prefix variable. + 2021-12-15 Bruno Haible automake-subdir support: Support arbitrary --source-base value. diff --git a/m4/libunistring-base.m4 b/m4/libunistring-base.m4 index 657bc0ded..1c2063f57 100644 --- a/m4/libunistring-base.m4 +++ b/m4/libunistring-base.m4 @@ -1,4 +1,4 @@ -# libunistring-base.m4 serial 5 +# libunistring-base.m4 serial 6 dnl Copyright (C) 2010-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -51,7 +51,11 @@ AC_DEFUN([gl_LIBUNISTRING_LIBHEADER], dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from dnl gl_LIBUNISTRING_CORE if that macro has been run. if gl_LIBUNISTRING_VERSION_CMP([$1]); then -LIBUNISTRING_[]AS_TR_CPP([$2])='$2' +dnl It is OK to use a .h file in lib/ from within tests/, but not vice +dnl versa. +if test -z "$LIBUNISTRING_[]AS_TR_CPP([$2])"; then + LIBUNISTRING_[]AS_TR_CPP([$2])="${gl_source_base_prefix}$2" +fi else LIBUNISTRING_[]AS_TR_CPP([$2])= fi -- 2.25.1
Re: Accommodate non-recursive Automake in a less hacky way
Jim Meyering wrote: > Thanks a lot! The core of the processing is still the build-aux/prefix-gnulib-mk that you wrote. I dared to document it and thus declare it "supported", because if people encounter problems with specific modules, we can fix them - either by recognizing more patterns in prefix-gnulib-mk, - or by making use of %reldir%. In theory we could remove prefix-gnulib-mk entirely and instead place thousands of %reldir% and %canon_reldir% in the Makefile.am section of the modules. This would grossly hamper maintainability. But it shows that a combination of prefix-gnulib-mk (for general patterns) and %reldir% (for special cases) will be sufficient to handle problem reports. > I want to switch every package for which I used the hacky way. I'd like to hear about it, since then we can deprecate the 'non-recursive-gnulib-prefix-hack' module. > Hoping we can remove the 'non-recursive-gnulib-prefix-hack' support > code before too long. As usual, before removing something, I plan to deprecate it (i.e. gnulib-tool will emit a deprecation message when it is used) and then wait for 1 or 2 years. Bruno
Re: Accommodate non-recursive Automake in a less hacky way
On Wed, Dec 15, 2021 at 11:38 AM Ben Pfaff wrote: > On Wed, Dec 15, 2021 at 11:31 AM Bruno Haible wrote: > > With the attached patches, 'gnulib-tool' gains the functionality to > > generate a "non-recursive" Automake Makefile.am snippet, similar to > > what the 'non-recursive-gnulib-prefix-hack' module does. > > Thank you! I favor nonrecursive Makefiles and I intend to try this out in GNU > PSPP when I find the time. Thanks a lot! I want to switch every package for which I used the hacky way. Hoping we can remove the 'non-recursive-gnulib-prefix-hack' support code before too long.
Re: Accommodate non-recursive Automake in a less hacky way
On Wed, Dec 15, 2021 at 11:31 AM Bruno Haible wrote: > With the attached patches, 'gnulib-tool' gains the functionality to > generate a "non-recursive" Automake Makefile.am snippet, similar to > what the 'non-recursive-gnulib-prefix-hack' module does. Thank you! I favor nonrecursive Makefiles and I intend to try this out in GNU PSPP when I find the time.