Parallelize clean rules using GNU make features
authorGlenn Morris <rgm@gnu.org>
Sun, 15 Jun 2014 00:17:21 +0000 (17:17 -0700)
committerGlenn Morris <rgm@gnu.org>
Sun, 15 Jun 2014 00:17:21 +0000 (17:17 -0700)
* Makefile.in: (submake_template): New definition.
(mostlyclean_dirs, clean_dirs, distclean_dirs, maintainer_clean_dirs):
New variables.
(mostlyclean, clean, distclean, bootstrap-clean, maintainer-clean)
(extraclean): Define using each subdirectory as a prequisite.

* lib/Makefile.am (bootstrap-clean):
* doc/emacs/Makefile.in (bootstrap-clean):
* doc/lispintro/Makefile.in (bootstrap-clean):
* doc/lispref/Makefile.in (bootstrap-clean):
* doc/misc/Makefile.in (bootstrap-clean):
* lib-src/Makefile.in (bootstrap-clean):
* lwlib/Makefile.in (bootstrap-clean):
* nextstep/Makefile.in (bootstrap-clean):
* nt/Makefile.in (bootstrap-clean):
* oldXMenu/Makefile.in (bootstrap-clean):
New rules, for symmetry/simplicity.

* lwlib/Makefile.in (mostlyclean, clean, distclean, maintainer-clean):
* oldXMenu/Makefile.in (mostlyclean, clean, distclean, maintainer-clean, tags):
Declare as PHONY.

21 files changed:
ChangeLog
Makefile.in
doc/emacs/ChangeLog
doc/emacs/Makefile.in
doc/lispintro/ChangeLog
doc/lispintro/Makefile.in
doc/lispref/ChangeLog
doc/lispref/Makefile.in
doc/misc/ChangeLog
doc/misc/Makefile.in
lib-src/ChangeLog
lib-src/Makefile.in
lib/Makefile.am
lwlib/ChangeLog
lwlib/Makefile.in
nextstep/ChangeLog
nextstep/Makefile.in
nt/ChangeLog
nt/Makefile.in
oldXMenu/ChangeLog
oldXMenu/Makefile.in

index 2c3e6c7..5bb156f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in: Parallelize clean rules using GNU make features.
+       (submake_template): New definition.
+       (mostlyclean_dirs, clean_dirs, distclean_dirs, maintainer_clean_dirs):
+       New variables.
+       (mostlyclean, clean, distclean, bootstrap-clean, maintainer-clean)
+       (extraclean): Define using each subdirectory as a prequisite.
+       * lib/Makefile.am (bootstrap-clean): New.
+
 2014-06-15  Paul Eggert  <eggert@cs.ucla.edu>
 
        Port part of the AIX fix to Solaris (Bug#17598).
index f9bfa08..d908bf1 100644 (file)
@@ -770,22 +770,27 @@ uninstall-nt:
 
 .PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean extraclean
 
+## Eg:
+## src_clean:
+##     make -C src clean
+define submake_template
+.PHONY: $(1)_$(2)
+$(1)_$(2):
+       $$(MAKE) -C $(1) $(2)
+endef
+
 ### `mostlyclean'
 ###      Like `clean', but may refrain from deleting a few files that people
 ###      normally don't want to recompile.  For example, the `mostlyclean'
 ###      target for GCC does not delete `libgcc.a', because recompiling it
 ###      is rarely necessary and takes a lot of time.
-mostlyclean:
-       cd src      && $(MAKE) mostlyclean
-       cd oldXMenu && $(MAKE) mostlyclean
-       cd lwlib    && $(MAKE) mostlyclean
-       cd lib      && $(MAKE) mostlyclean
-       cd lib-src  && $(MAKE) mostlyclean
-       cd nt       && $(MAKE) mostlyclean
-       -cd doc/emacs     && $(MAKE) mostlyclean
-       -cd doc/misc      && $(MAKE) mostlyclean
-       -cd doc/lispref   && $(MAKE) mostlyclean
-       -cd doc/lispintro && $(MAKE) mostlyclean
+mostlyclean_dirs = src oldXMenu lwlib lib lib-src nt doc/emacs doc/misc \
+  doc/lispref doc/lispintro
+
+$(foreach dir,$(mostlyclean_dirs),$(eval $(call submake_template,$(dir),mostlyclean)))
+
+mostlyclean: $(mostlyclean_dirs:=_mostlyclean)
+
 
 ### `clean'
 ###      Delete all files from the current directory that are normally
@@ -795,24 +800,18 @@ mostlyclean:
 ###      with them.
 ###
 ###      Delete `.dvi' files here if they are not part of the distribution.
-clean:
+clean_dirs = $(mostlyclean_dirs) nextstep
+
+$(foreach dir,$(clean_dirs),$(eval $(call submake_template,$(dir),clean)))
+
+clean: $(clean_dirs:=_clean)
        -rm -f etc/emacs.tmpdesktop
-       cd src      && $(MAKE) clean
-       cd oldXMenu && $(MAKE) clean
-       cd lwlib    && $(MAKE) clean
-       cd lib      && $(MAKE) clean
-       cd lib-src  && $(MAKE) clean
-       cd nt       && $(MAKE) clean
-       -cd doc/emacs     && $(MAKE) clean
-       -cd doc/misc      && $(MAKE) clean
-       -cd doc/lispref   && $(MAKE) clean
-       -cd doc/lispintro && $(MAKE) clean
-       cd nextstep && $(MAKE) clean
 
 ### `bootclean'
 ###      Delete all files that need to be remade for a clean bootstrap.
 top_bootclean=\
        rm -f config.cache config.log
+
 ### `distclean'
 ###      Delete all files from the current directory that are created by
 ###      configuring or building the program.  If you have unpacked the
@@ -822,44 +821,25 @@ top_bootclean=\
 top_distclean=\
        ${top_bootclean}; \
        rm -f config.status config.log~ Makefile stamp-h1 ${SUBDIR_MAKEFILES}
-distclean:
-       cd src      && $(MAKE) distclean
-       cd oldXMenu && $(MAKE) distclean
-       cd lwlib    && $(MAKE) distclean
-       cd lib      && $(MAKE) distclean
-       cd lib-src  && $(MAKE) distclean
-       cd nt       && $(MAKE) distclean
-       cd doc/emacs     && $(MAKE) distclean
-       cd doc/misc      && $(MAKE) distclean
-       cd doc/lispref   && $(MAKE) distclean
-       cd doc/lispintro && $(MAKE) distclean
-       cd leim     && $(MAKE) distclean
-       cd lisp     && $(MAKE) distclean
-       cd nextstep && $(MAKE) distclean
+
+distclean_dirs = $(clean_dirs) leim lisp
+
+$(foreach dir,$(distclean_dirs),$(eval $(call submake_template,$(dir),distclean)))
+
+distclean: $(distclean_dirs:=_distclean)
        for dir in test/automated admin/grammars admin/unidata; do \
-         [ ! -d $$dir ] || (cd $$dir && $(MAKE) distclean); \
+         [ ! -d $$dir ] || $(MAKE) -C $$dir distclean; \
        done
        ${top_distclean}
 
 ### `bootstrap-clean'
 ###      Delete everything that can be reconstructed by `make' and that
 ###      needs to be deleted in order to force a bootstrap from a clean state.
-bootstrap-clean:
-       cd src      && $(MAKE) bootstrap-clean
-       cd oldXMenu && $(MAKE) maintainer-clean
-       cd lwlib    && $(MAKE) maintainer-clean
-       cd lib      && $(MAKE) maintainer-clean
-       cd lib-src  && $(MAKE) maintainer-clean
-       cd nt       && $(MAKE) maintainer-clean
-       -cd doc/emacs     && $(MAKE) maintainer-clean
-       -cd doc/misc      && $(MAKE) maintainer-clean
-       -cd doc/lispref   && $(MAKE) maintainer-clean
-       -cd doc/lispintro && $(MAKE) maintainer-clean
-       cd leim     && $(MAKE) bootstrap-clean
-       cd lisp     && $(MAKE) bootstrap-clean
-       cd nextstep && $(MAKE) maintainer-clean
+$(foreach dir,$(distclean_dirs),$(eval $(call submake_template,$(dir),bootstrap-clean)))
+
+bootstrap-clean: $(distclean_dirs:=_bootstrap-clean)
        for dir in test/automated admin/grammars admin/unidata; do \
-         [ ! -d $$dir ] || (cd $$dir && $(MAKE) bootstrap-clean); \
+         [ ! -d $$dir ] || $(MAKE) -C $$dir bootstrap-clean; \
        done
        [ ! -f config.log ] || mv -f config.log config.log~
        rm -rf ${srcdir}/info
@@ -879,12 +859,14 @@ bootstrap-clean:
 top_maintainer_clean=\
        ${top_distclean}; \
        rm -fr autom4te.cache
-maintainer-clean: bootstrap-clean
-       cd src  && $(MAKE) maintainer-clean
-       cd leim && $(MAKE) maintainer-clean
-       cd lisp && $(MAKE) maintainer-clean
+
+maintainer_clean_dirs = src leim lisp
+
+$(foreach dir,$(maintainer_clean_dirs),$(eval $(call submake_template,$(dir),maintainer-clean)))
+
+maintainer-clean: bootstrap-clean $(maintainer_clean_dirs:=_maintainer-clean)
        for dir in test/automated admin/grammars admin/unidata; do \
-         [ ! -d $$dir ] || (cd $$dir && $(MAKE) maintainer-clean); \
+         [ ! -d $$dir ] || $(MAKE) -C $$dir maintainer-clean; \
        done
        ${top_maintainer_clean}
 
@@ -892,8 +874,12 @@ maintainer-clean: bootstrap-clean
 ### says GCC supports it, and that's where the configuration part of
 ### the coding standards seem to come from.  It's like distclean, but
 ### it deletes backup and autosave files too.
-extraclean:
-       for i in ${SUBDIR}; do (cd $$i; $(MAKE) extraclean); done
+### Note that we abuse this in some subdirectories (eg leim),
+### to delete some generated files that are slow to rebuild.
+$(foreach dir,$(SUBDIR),$(eval $(call submake_template,$(dir),extraclean)))
+
+## FIXME this is busted because most of these do not have extraclean rules.
+extraclean: $(SUBDIR:=_extraclean)
        ${top_maintainer_clean}
        -rm -f config-tmp-*
        -rm -f *~ \#*
index b2b4b37..c7fe1df 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (bootstrap-clean): New.
+
 2014-06-10  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in (INFO_EXT): Remove and replace by ".info" throughout.
index 6bf8302..ffbfda7 100644 (file)
@@ -181,7 +181,7 @@ emacs-xtra.dvi: $(EMACS_XTRA)
 emacs-xtra.pdf: $(EMACS_XTRA)
        $(ENVADD) $(TEXI2PDF) ${srcdir}/emacs-xtra.texi
 
-.PHONY: mostlyclean clean distclean maintainer-clean infoclean
+.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean infoclean
 
 ## Temp files.
 mostlyclean:
@@ -203,7 +203,7 @@ infoclean:
          $(buildinfodir)/emacs.info-[1-9] \
          $(buildinfodir)/emacs.info-[1-9][0-9]
 
-maintainer-clean: distclean infoclean
+bootstrap-clean maintainer-clean: distclean infoclean
 
 .PHONY: dist
 
index 4c549f9..318daf3 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (bootstrap-clean): New.
+
 2014-06-10  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in (INFO_EXT): Remove and replace by ".info" throughout.
index 0055408..08506cf 100644 (file)
@@ -101,7 +101,7 @@ emacs-lisp-intro.pdf: ${srcs}
 emacs-lisp-intro.html: ${srcs}
        $(MAKEINFO) $(MAKEINFO_OPTS) $(HTML_OPTS) -o $@ ${srcdir}/emacs-lisp-intro.texi
 
-.PHONY: mostlyclean clean distclean maintainer-clean infoclean
+.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean infoclean
 
 mostlyclean:
        rm -f *.aux *.log *.toc *.cp *.cps *.fn *.fns *.ky *.kys \
@@ -119,7 +119,7 @@ infoclean:
          $(buildinfodir)/eintr.info \
          $(buildinfodir)/eintr.info-[1-9]
 
-maintainer-clean: distclean infoclean
+bootstrap-clean maintainer-clean: distclean infoclean
 
 .PHONY: dist
 
index f7c0d14..4089068 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (bootstrap-clean): New.
+
 2014-06-15  Eli Zaretskii  <eliz@gnu.org>
 
        * commands.texi (Accessing Mouse): Improve the wording of the
index 2fbba4d..c97ce97 100644 (file)
@@ -153,7 +153,7 @@ elisp.html: $(srcs)
 elisp.pdf: $(srcs)
        $(ENVADD) $(TEXI2PDF) $(srcdir)/elisp.texi
 
-.PHONY: mostlyclean clean distclean maintainer-clean infoclean
+.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean infoclean
 
 ## [12] stuff is from two-volume.make.
 mostlyclean:
@@ -175,7 +175,7 @@ infoclean:
          $(buildinfodir)/elisp.info-[1-9] \
          $(buildinfodir)/elisp.info-[1-9][0-9]
 
-maintainer-clean: distclean infoclean
+bootstrap-clean maintainer-clean: distclean infoclean
 
 .PHONY: dist
 
index 2ded889..6e641f1 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (bootstrap-clean): New.
+
 2014-06-12  Vincent Belaïche  <vincentb1@users.sourceforge.net>
 
        * ses.texi: Adding documentation for SES local printer functions.
index 9e036c4..d191534 100644 (file)
@@ -209,7 +209,7 @@ ${buildinfodir}/tramp.info tramp.html: EXTRA_OPTS = -D emacs
 ${buildinfodir}/tramp.info tramp.html: ${srcdir}/trampver.texi
 
 
-.PHONY: mostlyclean clean distclean maintainer-clean
+.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean
 
 mostlyclean:
        rm -f *.aux *.log *.toc *.c[mp] *.c[mp]s *.fn *.fns \
@@ -235,7 +235,7 @@ infoclean:
            $(buildinfodir)/$${file}-[1-9][0-9]; \
        done
 
-maintainer-clean: distclean infoclean
+bootstrap-clean maintainer-clean: distclean infoclean
 
 dist:
        rm -rf emacs-misc-${version}
index 2586cfd..74cdf05 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (bootstrap-clean): New.
+
 2014-06-13  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in (../lib/libgnu.a):
index c7183fe..2de6411 100644 (file)
@@ -255,7 +255,7 @@ $(DESTDIR)${archlibdir}: all
        fi
 
 .PHONY: install uninstall mostlyclean clean distclean maintainer-clean
-.PHONY: extraclean check tags
+.PHONY: bootstrap-clean extraclean check tags
 
 install: $(DESTDIR)${archlibdir}
        @echo
@@ -289,7 +289,7 @@ distclean: clean
        -rm -f TAGS
        -rm -f Makefile blessmail
 
-maintainer-clean: distclean
+bootstrap-clean maintainer-clean: distclean
        true
 
 extraclean: maintainer-clean
index f76d0d3..cda9681 100644 (file)
@@ -16,3 +16,7 @@ include gnulib.mk
 
 libgnu_a_SOURCES += openat-die.c save-cwd.c
 endif
+
+.PHONY: bootstrap-clean
+
+bootstrap-clean: maintainer-clean
index c62b72a..6af0b41 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (mostlyclean, clean, distclean, maintainer-clean):
+       Declare as PHONY.
+       (bootstrap-clean): New.
+
 2014-06-13  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in ($(globals_h)):
index 145f6ec..f8f6fe2 100644 (file)
@@ -91,13 +91,16 @@ lwlib-Xm.o:    $(src_h) lwlib-Xm.c lwlib-Xm.h lwlib.h lwlib-int.h lwlib-utils.h
 xlwmenu.o:     $(src_h) xlwmenu.c xlwmenu.h lwlib.h xlwmenuP.h \
   $(srcdir)/../src/xterm.h
 
-mostlyclean:
+
+.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean
+
+clean mostlyclean:
        rm -f *.o liblw.a \#*
 
-clean: mostlyclean
 distclean: clean
        rm -f Makefile
-maintainer-clean: distclean
+
+bootstrap-clean maintainer-clean: distclean
        rm -f TAGS
 
 
index ad869f1..a3d9b3a 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (bootstrap-clean): New.
+
 2014-03-13  Glenn Morris  <rgm@gnu.org>
 
        * templates/Info.plist.in: Make it strictly valid xml.  (Bug#17002)
index fe570d1..4198fb2 100644 (file)
@@ -52,7 +52,7 @@ ${ns_appbindir}/Emacs: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT}
 all: ${ns_appdir} ${ns_appbindir}/Emacs
 
 
-.PHONY: clean distclean maintainer-clean
+.PHONY: clean distclean bootstrap-clean maintainer-clean
 
 clean:
        rm -rf ${ns_appdir}
@@ -64,6 +64,6 @@ distclean: clean
          Cocoa/Emacs.base/Contents/Info.plist \
          Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings
 
-maintainer-clean: distclean
+bootstrap-clean maintainer-clean: distclean
 
 ### Makefile.in ends here
index cbbb581..87274b3 100644 (file)
@@ -1,3 +1,7 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (bootstrap-clean): New.
+
 2014-06-05  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * inc/ms-w32.h (POLL_FOR_INPUT): Define with HAVE_WINDOW_SYSTEM.
index a7fc110..86d313a 100644 (file)
@@ -162,7 +162,7 @@ $(DESTDIR)${archlibdir}: all
         fi
 
 .PHONY: install uninstall mostlyclean clean distclean maintainer-clean
-.PHONY: extraclean check tags
+.PHONY: bootstrap-clean extraclean check tags
 
 install: $(DESTDIR)${archlibdir}
        @echo
@@ -193,7 +193,7 @@ distclean: clean
        -rm -f TAGS
        -rm -f Makefile
 
-maintainer-clean: distclean
+bootstrap-clean maintainer-clean: distclean
        true
 
 extraclean: maintainer-clean
index 906fe22..f3736cd 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-15  Glenn Morris  <rgm@gnu.org>
+
+       * Makefile.in (mostlyclean, clean, distclean, maintainer-clean, tags):
+       Declare as PHONY.
+       (boostrap-clean): New.
+
 2013-10-24  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in (abs_top_srcdir): New, set by configure.
index c1fdd82..537be82 100644 (file)
@@ -134,14 +134,17 @@ XDestAssoc.o: XDestAssoc.c X10.h
 XMakeAssoc.o: XMakeAssoc.c X10.h
 insque.o: insque.c
 
-FRC.mostlyclean:
-mostlyclean: FRC.mostlyclean
+.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean
+
+mostlyclean:
        rm -f libXMenu11.a ${OBJS} ${EXTRA}
+
 clean: mostlyclean
-distclean: clean
+
+boostrap-clean maintainer-clean distclean: clean
        rm -f Makefile
-maintainer-clean: distclean
 
+.PHONY: tags
 tags:
        $(TAGS) -t *.[ch]
-.PHONY: tags
+