bug-gnulib
[Top][All Lists]
Advanced

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

gnulib-tool: Support non-recursive-gnulib-prefix-hack with tests


From: Bruno Haible
Subject: gnulib-tool: Support non-recursive-gnulib-prefix-hack with tests
Date: Mon, 13 Dec 2021 02:50:15 +0100

In a project that uses Gnulib
  1) with a lib/ dir that contains the 'non-recursive-gnulib-prefix-hack'
     but not the 'alloca-opt' module,
  2) with a tests/ dir that contains the 'alloca-opt' module,

Automake produces an error:
  tests/Makefile.am:58: error: required file 'lib/alloca.c' not found

The cause is that m4/non-recursive-gnulib-prefix-hack.m4 invokes
AC_CONFIG_LIBOBJ_DIR([lib]), but in the given situation we need
AC_CONFIG_LIBOBJ_DIR([tests]) instead.

This patch fixes it, by moving the AC_CONFIG_LIBOBJ_DIR logic into gnulib-tool.


2021-12-12  Bruno Haible  <bruno@clisp.org>

        gnulib-tool: Support non-recursive-gnulib-prefix-hack with tests.
        * gnulib-tool (func_import): Synthesize an AC_CONFIG_LIBOBJ_DIR
        invocation.
        * m4/non-recursive-gnulib-prefix-hack.m4
        (gl_NON_RECURSIVE_GNULIB_PREFIX_HACK): Don't invoke
        AC_CONFIG_LIBOBJ_DIR.

diff --git a/gnulib-tool b/gnulib-tool
index eb10436b1..878b9588f 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -5837,6 +5837,22 @@ s,//*$,/,'
     echo "# \"Check for header files, types and library functions\"."
     echo "AC_DEFUN([${macro_prefix}_INIT],"
     echo "["
+    # This AC_CONFIG_LIBOBJ_DIR invocation silences an error from the automake
+    # front end:
+    #   error: required file './alloca.c' not found
+    # It is needed because of the last remaining use of AC_LIBSOURCES in
+    # _AC_LIBOBJ_ALLOCA, invoked from AC_FUNC_ALLOCA.
+    # All the m4_pushdef/m4_popdef logic in func_emit_initmacro_start/_end
+    # does not help to avoid this error.
+    if grep '  lib/alloca\.c$' "$tmp"/new-files; then
+      # alloca.c will be present in $sourcebase.
+      echo "  AC_CONFIG_LIBOBJ_DIR([$sourcebase])"
+    else
+      if grep '        tests=lib/alloca\.c$' "$tmp"/new-files; then
+        # alloca.c will be present in $testsbase.
+        echo "  AC_CONFIG_LIBOBJ_DIR([$testsbase])"
+      fi
+    fi
     if test "$libtool" = true; then
       echo "  AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
       echo "  gl_cond_libtool=true"
diff --git a/m4/non-recursive-gnulib-prefix-hack.m4 
b/m4/non-recursive-gnulib-prefix-hack.m4
index bd3bb5262..2eea84c4b 100644
--- a/m4/non-recursive-gnulib-prefix-hack.m4
+++ b/m4/non-recursive-gnulib-prefix-hack.m4
@@ -9,9 +9,6 @@ dnl with a value ending in ".h" to reflect that these files are 
located
 dnl in the directory specified by LIB_DIR.
 AC_DEFUN([gl_NON_RECURSIVE_GNULIB_PREFIX_HACK],
 [
-  # Tell AC_LIBSOURCES where to find source files like alloca.c.
-  AC_CONFIG_LIBOBJ_DIR([$1])
-
   # This hack originated in bison.  It is required when using non-recursive
   # automake rules to build from gnulib-provided lib/ sources.  Hence, LIB_DIR
   # is usually simply "lib".  Those rules use the list of names like "fchdir.o"






reply via email to

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