gbranden pushed a commit to branch master
in repository groff.

commit baac1d37e9cbf38c786a89e34201bd9cce0ec19f
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jul 2 12:12:37 2026 -0500

    [eqn,pic,refer]: Clean out-of-source build trees.
    
    ...better.
    
    * src/preproc/eqn/eqn.am:
    * src/preproc/pic/pic.am:
    * src/preproc/refer/refer.am: Improve clean behavior, deleting YACC/
      Bison-generated files _only_ from an out-of-source build tree.
      Because they are shipped in the distribution archive, only the
      "maintainer-clean" target should remove them from the source tree.
      Add new macros `GROFF_{EQN,PIC,REFER}_YACC_FILES` to track these
      artifacts.  Redefine `MAINTAINERCLEANFILES` in terms of these new
      macros.  Add `mostlyclean-{eqn,pic,refer}` targets to perform the
      cleaning.  Add these new targets as dependencies of
      `mostlyclean-local`.
    
    With this commit, the only files left behind after a command sequence
    like this...
    
    rm -r build
    mkdir build
    cd build
    ../configure
    make
    make clean
    
    ...are a bunch of ".dirstamp" and/or ".Po" files, which are GNU
    Automake's business to deal with.
---
 ChangeLog                  | 14 ++++++++++++++
 src/preproc/eqn/eqn.am     | 12 +++++++++++-
 src/preproc/pic/pic.am     | 12 +++++++++++-
 src/preproc/refer/refer.am | 12 +++++++++++-
 4 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 93a5fd90c..187eedc93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2026-07-02  G. Branden Robinson <[email protected]>
+
+       * src/preproc/eqn/eqn.am:
+       * src/preproc/pic/pic.am:
+       * src/preproc/refer/refer.am: Improve clean behavior, deleting
+       YACC/Bison-generated files _only_ from an out-of-source build
+       tree.  Because they are shipped in the distribution archive,
+       only the "maintainer-clean" target should remove them from the
+       source tree.  Add new macros `GROFF_{EQN,PIC,REFER}_YACC_FILES`
+       to track these artifacts.  Redefine `MAINTAINERCLEANFILES` in
+       terms of these new macros.  Add `mostlyclean-{eqn,pic,refer}`
+       targets to perform the cleaning.  Add these new targets as
+       dependencies of `mostlyclean-local`.
+
 2026-07-03  G. Branden Robinson <[email protected]>
 
        * doc/doc.am: Improve "maintainer-clean" target.
diff --git a/src/preproc/eqn/eqn.am b/src/preproc/eqn/eqn.am
index 2da17525f..0c353c2a9 100644
--- a/src/preproc/eqn/eqn.am
+++ b/src/preproc/eqn/eqn.am
@@ -66,11 +66,21 @@ neqn: $(top_srcdir)/src/preproc/eqn/neqn.sh 
$(SH_DEPS_SED_SCRIPT)
        && chmod +x [email protected] \
        && mv [email protected] $@
 
-MAINTAINERCLEANFILES += \
+GROFF_EQN_YACC_FILES = \
   src/preproc/eqn/eqn.hpp \
   src/preproc/eqn/eqn.cpp \
   src/preproc/eqn/eqn.output
 
+# When doing a "plain" clean, remove YACC/Bison-generated files _only_
+# from an out-of-source build tree.
+mostlyclean-local: mostlyclean-eqn
+mostlyclean-eqn:
+       if test "$(top_builddir)" != "$(top_srcdir)"; then \
+         $(RM) $(GROFF_EQN_YACC_FILES); \
+       fi
+
+MAINTAINERCLEANFILES += $(GROFF_EQN_YACC_FILES)
+
 maintainer-clean-local: maintainer-clean-eqn
 
 .PHONY: maintainer-clean-eqn
diff --git a/src/preproc/pic/pic.am b/src/preproc/pic/pic.am
index 748e3f533..e5a69d30a 100644
--- a/src/preproc/pic/pic.am
+++ b/src/preproc/pic/pic.am
@@ -47,11 +47,21 @@ EXTRA_DIST += \
 # Since pic_CPPFLAGS was set, all .o files have a 'pic-' prefix.
 src/preproc/pic/pic-lex.$(OBJEXT): src/preproc/pic/pic.hpp
 
-MAINTAINERCLEANFILES += \
+GROFF_PIC_YACC_FILES = \
   src/preproc/pic/pic.cpp \
   src/preproc/pic/pic.hpp \
   src/preproc/pic/pic.output
 
+# When doing a "plain" clean, remove YACC/Bison-generated files _only_
+# from an out-of-source build tree.
+mostlyclean-local: mostlyclean-pic
+mostlyclean-pic:
+       if test "$(top_builddir)" != "$(top_srcdir)"; then \
+         $(RM) $(GROFF_PIC_YACC_FILES); \
+       fi
+
+MAINTAINERCLEANFILES += $(GROFF_PIC_YACC_FILES)
+
 maintainer-clean-local: maintainer-clean-pic
 
 .PHONY: maintainer-clean-pic
diff --git a/src/preproc/refer/refer.am b/src/preproc/refer/refer.am
index a9b337d2c..86e5c0af6 100644
--- a/src/preproc/refer/refer.am
+++ b/src/preproc/refer/refer.am
@@ -45,11 +45,21 @@ src/preproc/refer/refer-refer.$(OBJEXT): defs.h
 src/preproc/refer/refer-token.$(OBJEXT): defs.h
 src/preproc/refer/refer-label.$(OBJEXT): defs.h
 
-MAINTAINERCLEANFILES += \
+GROFF_REFER_YACC_FILES = \
   src/preproc/refer/label.cpp \
   src/preproc/refer/label.hpp \
   src/preproc/refer/label.output
 
+# When doing a "plain" clean, remove YACC/Bison-generated files _only_
+# from an out-of-source build tree.
+mostlyclean-local: mostlyclean-refer
+mostlyclean-refer:
+       if test "$(top_builddir)" != "$(top_srcdir)"; then \
+         $(RM) $(GROFF_REFER_YACC_FILES); \
+       fi
+
+MAINTAINERCLEANFILES += $(GROFF_REFER_YACC_FILES)
+
 maintainer-clean-local: maintainer-clean-refer
 
 .PHONY: maintainer-clean-refer

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to