Bruno Haible <br...@clisp.org> writes:

> Neither of these two is what I propose for the short term.
>
> What I propose is to have fts.in.h being preprocessed into fts_.h.
> So that
>   - we follow the naming scheme *.in.h of other header files in gnulib,
>   - packages like coreutils and findutils are not broken.

Sure. I pushed the attached patch to do that.

Collin

>From 3e75d0af1ab449840da0d04a1ca1ac13264c9c5f Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 10 May 2025 17:39:26 -0700
Subject: [PATCH] fts: Generate fts_.h.

Suggested by Bruno Haible in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00134.html>.

* lib/fts_.h: Remove file.
* lib/fts.in.h: New file.
* m4/fts.m4 (gl_FUNC_FTS_CORE): Use gl_CHECK_HEADER_SYS_CDEFS_H instead
of AC_CHECK_HEADERS_ONCE.
* modules/fts (Files): Remove lib/fts_.h. Add lib/fts.in.h and
m4/sys_cdefs_h.m4.
(Depends-on): Add gen-header.
(Makefile.am): Add fts_.h to BUILT_SOURCES. Generate fts_.h using
fts.in.h while replacing @HAVE_SYS_CDEFS_H@. Add fts_.h and fts_.h-t to
MOSTLYCLEANFILES.
---
 ChangeLog                | 16 ++++++++++++++++
 lib/{fts_.h => fts.in.h} |  2 +-
 m4/fts.m4                |  4 ++--
 modules/fts              | 13 ++++++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)
 rename lib/{fts_.h => fts.in.h} (99%)

diff --git a/ChangeLog b/ChangeLog
index 4910d5a264..2b951317ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2025-05-11  Collin Funk  <collin.fu...@gmail.com>
+
+	fts: Generate fts_.h.
+	Suggested by Bruno Haible in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00134.html>.
+	* lib/fts_.h: Remove file.
+	* lib/fts.in.h: New file.
+	* m4/fts.m4 (gl_FUNC_FTS_CORE): Use gl_CHECK_HEADER_SYS_CDEFS_H instead
+	of AC_CHECK_HEADERS_ONCE.
+	* modules/fts (Files): Remove lib/fts_.h. Add lib/fts.in.h and
+	m4/sys_cdefs_h.m4.
+	(Depends-on): Add gen-header.
+	(Makefile.am): Add fts_.h to BUILT_SOURCES. Generate fts_.h using
+	fts.in.h while replacing @HAVE_SYS_CDEFS_H@. Add fts_.h and fts_.h-t to
+	MOSTLYCLEANFILES.
+
 2025-05-11  Bruno Haible  <br...@clisp.org>
 
 	string-h, wchar-h: Fix some g++ -Wsystem-headers warnings.
diff --git a/lib/fts_.h b/lib/fts.in.h
similarity index 99%
rename from lib/fts_.h
rename to lib/fts.in.h
index aa5b88f19c..9acc445039 100644
--- a/lib/fts_.h
+++ b/lib/fts.in.h
@@ -62,7 +62,7 @@
 #   define __FLEXIBLE_ARRAY_MEMBER
 #  endif
 # else
-#  if HAVE_SYS_CDEFS_H
+#  if @HAVE_SYS_CDEFS_H@
 #   include <sys/cdefs.h>
 #  endif
 #  define __FLEXIBLE_ARRAY_MEMBER FLEXIBLE_ARRAY_MEMBER
diff --git a/m4/fts.m4 b/m4/fts.m4
index 1d3a32f52e..c5bdc6eac9 100644
--- a/m4/fts.m4
+++ b/m4/fts.m4
@@ -1,5 +1,5 @@
 # fts.m4
-# serial 25
+# serial 26
 dnl Copyright (C) 2005-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,7 @@ AC_DEFUN([gl_FUNC_FTS_CORE]
 [
   dnl Prerequisites of lib/fts.c.
   gl_FUNC_OPENAT
-  AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
+  gl_CHECK_HEADER_SYS_CDEFS_H
 
   AC_CHECK_FUNCS_ONCE([fstatfs])
   AC_CHECK_HEADERS_ONCE([sys/param.h sys/vfs.h])dnl
diff --git a/modules/fts b/modules/fts
index a50bd958b9..80e1dae2bc 100644
--- a/modules/fts
+++ b/modules/fts
@@ -2,12 +2,14 @@ Description:
 Traverse a file hierarchy.
 
 Files:
-lib/fts_.h
+lib/fts.in.h
 lib/fts.c
 lib/fts-cycle.c
 m4/fts.m4
+m4/sys_cdefs_h.m4
 
 Depends-on:
+gen-header
 alignasof
 attribute
 c99
@@ -45,10 +47,19 @@ dnl NetBSD versions have bugs and/or unnecessary limitations.
 gl_CONDITIONAL([GL_COND_OBJ_FTS], [true])
 
 Makefile.am:
+BUILT_SOURCES += fts_.h
 if GL_COND_OBJ_FTS
 lib_SOURCES += fts.c
 endif
 
+fts_.h: fts.in.h
+@NMD@	$(AM_V_GEN)$(MKDIR_P) '%reldir%'
+	$(gl_V_at)$(SED_HEADER_STDOUT) \
+	      -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
+	      $(srcdir)/fts.in.h > $@-t
+	$(AM_V_at)mv $@-t $@
+MOSTLYCLEANFILES += fts_.h fts_.h-t
+
 Include:
 "fts_.h"
 
-- 
2.49.0

Reply via email to