This patch moves some more AC_LIBOBJ invocations to the module descriptions,
following the principle that source file names don't belong in *.m4 files.

It's a preparation for the next patch, which will eliminate these AC_LIBOBJ
invocations from the module descriptions.

Some AC_LIBOBJ invocations still exist in the m4/*printf*.m4 files, but they
are more hairy to clean up.


2022-01-09  Bruno Haible  <br...@clisp.org>

        obstack: Move AC_LIBOBJ invocation to the module description.
        * m4/obstack.m4 (gl_FUNC_OBSTACK): Renamed from AC_FUNC_OBSTACK. Don't
        invoke AC_LIBSOURCES nor AC_LIBOBJ.
        * modules/obstack (configure.ac): Update. Invoke AC_LIBOBJ here.

2022-01-09  Bruno Haible  <br...@clisp.org>

        stdio: Move AC_LIBOBJ invocations to the module description.
        * m4/stdio_h.m4 (gl_STDIO_H): Don't invoke AC_LIBOBJ.
        * modules/stdio (configure.ac): Invoke AC_LIBOBJ here.

2022-01-09  Bruno Haible  <br...@clisp.org>

        fchdir: Move AC_LIBOBJ invocation to the module description.
        * m4/fchdir.m4 (gl_FUNC_FCHDIR): Don't invoke AC_LIBOBJ and
        gl_PREREQ_FCHDIR.
        * modules/fchdir (configure.ac): Invoke AC_LIBOBJ and gl_PREREQ_FCHDIR.

>From af976e7799ddeabba5e2ec18dcb2339c8b11f5a7 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 9 Jan 2022 15:40:14 +0100
Subject: [PATCH 1/3] fchdir: Move AC_LIBOBJ invocation to the module
 description.

* m4/fchdir.m4 (gl_FUNC_FCHDIR): Don't invoke AC_LIBOBJ and
gl_PREREQ_FCHDIR.
* modules/fchdir (configure.ac): Invoke AC_LIBOBJ and gl_PREREQ_FCHDIR.
---
 ChangeLog      | 7 +++++++
 m4/fchdir.m4   | 4 +---
 modules/fchdir | 4 ++++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e330c90f70..b8b0b0fc3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-01-09  Bruno Haible  <br...@clisp.org>
+
+	fchdir: Move AC_LIBOBJ invocation to the module description.
+	* m4/fchdir.m4 (gl_FUNC_FCHDIR): Don't invoke AC_LIBOBJ and
+	gl_PREREQ_FCHDIR.
+	* modules/fchdir (configure.ac): Invoke AC_LIBOBJ and gl_PREREQ_FCHDIR.
+
 2022-01-09  Bruno Haible  <br...@clisp.org>
 
 	Remove influence of Automake conditionals on conditional dependencies.
diff --git a/m4/fchdir.m4 b/m4/fchdir.m4
index ae5e1d3361..f85549a3ed 100644
--- a/m4/fchdir.m4
+++ b/m4/fchdir.m4
@@ -1,4 +1,4 @@
-# fchdir.m4 serial 26
+# fchdir.m4 serial 27
 dnl Copyright (C) 2006-2022 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,8 +17,6 @@ AC_DEFUN([gl_FUNC_FCHDIR],
 
   AC_REQUIRE([gl_TEST_FCHDIR])
   if test $HAVE_FCHDIR = 0; then
-    AC_LIBOBJ([fchdir])
-    gl_PREREQ_FCHDIR
     AC_DEFINE([REPLACE_FCHDIR], [1],
       [Define to 1 if gnulib's fchdir() replacement is used.])
     dnl We must also replace anything that can manipulate a directory fd,
diff --git a/modules/fchdir b/modules/fchdir
index e58c73523a..967e648b06 100644
--- a/modules/fchdir
+++ b/modules/fchdir
@@ -30,6 +30,10 @@ sys_stat         [test $HAVE_FCHDIR = 0]
 
 configure.ac:
 gl_FUNC_FCHDIR
+if test $HAVE_FCHDIR = 0; then
+  AC_LIBOBJ([fchdir])
+  gl_PREREQ_FCHDIR
+fi
 gl_UNISTD_MODULE_INDICATOR([fchdir])
 
 Makefile.am:
-- 
2.25.1

>From ff028b4093b396029978a39d30137ab5ac91926f Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 9 Jan 2022 15:40:18 +0100
Subject: [PATCH 2/3] stdio: Move AC_LIBOBJ invocations to the module
 description.

* m4/stdio_h.m4 (gl_STDIO_H): Don't invoke AC_LIBOBJ.
* modules/stdio (configure.ac): Invoke AC_LIBOBJ here.
---
 ChangeLog     | 6 ++++++
 m4/stdio_h.m4 | 5 +----
 modules/stdio | 6 ++++++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b8b0b0fc3b..2397dd79b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-01-09  Bruno Haible  <br...@clisp.org>
+
+	stdio: Move AC_LIBOBJ invocations to the module description.
+	* m4/stdio_h.m4 (gl_STDIO_H): Don't invoke AC_LIBOBJ.
+	* modules/stdio (configure.ac): Invoke AC_LIBOBJ here.
+
 2022-01-09  Bruno Haible  <br...@clisp.org>
 
 	fchdir: Move AC_LIBOBJ invocation to the module description.
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index cc80e77365..09f56be544 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 57
+# stdio_h.m4 serial 58
 dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -49,7 +49,6 @@ AC_DEFUN_ONCE([gl_STDIO_H],
     gl_NONBLOCKING_IO
     if test $gl_cv_have_nonblocking != yes; then
       REPLACE_STDIO_READ_FUNCS=1
-      AC_LIBOBJ([stdio-read])
     fi
   ])
 
@@ -62,7 +61,6 @@ AC_DEFUN_ONCE([gl_STDIO_H],
     gl_SIGNAL_SIGPIPE
     if test $gl_cv_header_signal_h_SIGPIPE != yes; then
       REPLACE_STDIO_WRITE_FUNCS=1
-      AC_LIBOBJ([stdio-write])
     fi
   ])
   dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
@@ -74,7 +72,6 @@ AC_DEFUN_ONCE([gl_STDIO_H],
     gl_NONBLOCKING_IO
     if test $gl_cv_have_nonblocking != yes; then
       REPLACE_STDIO_WRITE_FUNCS=1
-      AC_LIBOBJ([stdio-write])
     fi
   ])
 
diff --git a/modules/stdio b/modules/stdio
index 0f250558dc..61b89e0c86 100644
--- a/modules/stdio
+++ b/modules/stdio
@@ -20,6 +20,12 @@ configure.ac:
 gl_STDIO_H
 gl_STDIO_H_REQUIRE_DEFAULTS
 AC_PROG_MKDIR_P
+if test $REPLACE_STDIO_READ_FUNCS = 1; then
+  AC_LIBOBJ([stdio-read])
+fi
+if test $REPLACE_STDIO_WRITE_FUNCS = 1; then
+  AC_LIBOBJ([stdio-write])
+fi
 
 dnl No need to create extra modules for these functions. Everyone who uses
 dnl <stdio.h> likely needs them.
-- 
2.25.1

>From 0045109bfaebdd0c12a303fd58a431eedda6a39a Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 9 Jan 2022 15:40:22 +0100
Subject: [PATCH 3/3] obstack: Move AC_LIBOBJ invocation to the module
 description.

* m4/obstack.m4 (gl_FUNC_OBSTACK): Renamed from AC_FUNC_OBSTACK. Don't
invoke AC_LIBSOURCES nor AC_LIBOBJ.
* modules/obstack (configure.ac): Update. Invoke AC_LIBOBJ here.
---
 ChangeLog       |  7 +++++++
 m4/obstack.m4   | 50 ++++++++++++++++++++++++-------------------------
 modules/obstack |  6 ++++--
 3 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2397dd79b6..3db6389801 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-01-09  Bruno Haible  <br...@clisp.org>
+
+	obstack: Move AC_LIBOBJ invocation to the module description.
+	* m4/obstack.m4 (gl_FUNC_OBSTACK): Renamed from AC_FUNC_OBSTACK. Don't
+	invoke AC_LIBSOURCES nor AC_LIBOBJ.
+	* modules/obstack (configure.ac): Update. Invoke AC_LIBOBJ here.
+
 2022-01-09  Bruno Haible  <br...@clisp.org>
 
 	stdio: Move AC_LIBOBJ invocations to the module description.
diff --git a/m4/obstack.m4 b/m4/obstack.m4
index 007b2f0281..3a26cba4b9 100644
--- a/m4/obstack.m4
+++ b/m4/obstack.m4
@@ -5,31 +5,29 @@ 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 This replaces Autoconf's AC_FUNC_OBSTACK.
-dnl The Autoconf version should be marked obsolete at some point.
+dnl Autoconf's AC_FUNC_OBSTACK is marked obsolete since version 2.70.
+dnl We provide our own macro here.
 
-AC_DEFUN([AC_FUNC_OBSTACK],
-  [AC_LIBSOURCES([obstack.h, obstack.c])dnl
-   AC_CACHE_CHECK([for obstacks that work with any size object],
-     [ac_cv_func_obstack],
-     [AC_LINK_IFELSE(
-        [AC_LANG_PROGRAM(
-           [[#include "obstack.h"
-             void *obstack_chunk_alloc (size_t n) { return 0; }
-             void obstack_chunk_free (void *p) { }
-             /* Check that an internal function returns size_t, not int.  */
-             size_t _obstack_memory_used (struct obstack *);
-            ]],
-           [[struct obstack mem;
-             obstack_init (&mem);
-             obstack_free (&mem, 0);
-           ]])],
-        [ac_cv_func_obstack=yes],
-        [ac_cv_func_obstack=no])])
-   if test "$ac_cv_func_obstack" = yes; then
-     AC_DEFINE([HAVE_OBSTACK], 1,
-       [Define to 1 if the system has obstacks that work with any size object.])
-   else
-     AC_LIBOBJ([obstack])
-   fi
+AC_DEFUN([gl_FUNC_OBSTACK],
+[
+  AC_CACHE_CHECK([for obstacks that work with any size object],
+    [gl_cv_func_obstack],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include "obstack.h"
+            void *obstack_chunk_alloc (size_t n) { return 0; }
+            void obstack_chunk_free (void *p) { }
+            /* Check that an internal function returns size_t, not int.  */
+            size_t _obstack_memory_used (struct obstack *);
+           ]],
+          [[struct obstack mem;
+            obstack_init (&mem);
+            obstack_free (&mem, 0);
+          ]])],
+       [gl_cv_func_obstack=yes],
+       [gl_cv_func_obstack=no])])
+  if test "$gl_cv_func_obstack" = yes; then
+    AC_DEFINE([HAVE_OBSTACK], 1,
+      [Define to 1 if the system has obstacks that work with any size object.])
+  fi
 ])
diff --git a/modules/obstack b/modules/obstack
index e0b528e418..c8bb548a77 100644
--- a/modules/obstack
+++ b/modules/obstack
@@ -14,8 +14,10 @@ stdint
 stdlib
 
 configure.ac:
-AC_FUNC_OBSTACK
-dnl Note: AC_FUNC_OBSTACK does AC_LIBSOURCES([obstack.h, obstack.c]).
+gl_FUNC_OBSTACK
+if test "$gl_cv_func_obstack" != yes; then
+  AC_LIBOBJ([obstack])
+fi
 
 Makefile.am:
 
-- 
2.25.1

Reply via email to