Browse Source

Makefile: provide CHMOD customization, use it for cleantest

* mk/default.mk (CHMOD): Addtional customization variable for
  chmod (change file permissions).  Explain why we need it for
  git-annex.

* mk/targets.mk (cleantest): If the plain $(RMR) fails, try to make
  directories writable recursively and retry the $(RMR).
  (cleanall, $(CLEANDIRS:%=clean%)): Use "+" instead of ";" to reduce
  the number of execs.
Achim Gratz 9 years ago
parent
commit
bb3dca06a5
2 changed files with 15 additions and 7 deletions
  1. 4 0
      mk/default.mk
  2. 11 7
      mk/targets.mk

+ 4 - 0
mk/default.mk

@@ -150,6 +150,10 @@ RM	= rm -f
 # How to remove files recursively
 RMR	= rm -fr
 
+# How to change file permissions
+# currently only needed for git-annex due to its "lockdown" feature
+CHMOD   = chmod
+
 # How to copy the lisp files and elc files to their destination.
 # CP	= cp -p	# try this if you have no install
 CP	= install -m 644 -p

+ 11 - 7
mk/targets.mk

@@ -37,7 +37,7 @@ endif
 CONF_BASE = EMACS DESTDIR ORGCM ORG_MAKE_DOC
 CONF_DEST = lispdir infodir datadir testdir
 CONF_TEST = BTEST_PRE BTEST_POST BTEST_OB_LANGUAGES BTEST_EXTRA BTEST_RE
-CONF_EXEC = CP MKDIR RM RMR FIND SUDO PDFTEX TEXI2PDF TEXI2HTML MAKEINFO INSTALL_INFO
+CONF_EXEC = CP MKDIR RM RMR FIND CHMOD SUDO PDFTEX TEXI2PDF TEXI2HTML MAKEINFO INSTALL_INFO
 CONF_CALL = BATCH BATCHL ELC ELCDIR NOBATCH BTEST MAKE_LOCAL_MK MAKE_ORG_INSTALL MAKE_ORG_VERSION
 config-eol:: EOL = \#
 config-eol:: config-all
@@ -137,11 +137,11 @@ cleandirs:
 clean:	cleanlisp cleandoc
 
 cleanall: cleandirs cleantest cleanaddcontrib
-	-$(FIND) . \( -name \*~ -o -name \*# -o -name .#\* \) -exec $(RM) {} \;
-	-$(FIND) $(CLEANDIRS) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} \;
+	-$(FIND) . \( -name \*~ -o -name \*# -o -name .#\* \) -exec $(RM) {} +
+	-$(FIND) $(CLEANDIRS) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
 
 $(CLEANDIRS:%=clean%):
-	-$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} \;
+	-$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
 
 cleanelc:
 	$(MAKE) -C lisp $@
@@ -158,6 +158,10 @@ cleandocs:
 	-$(FIND) doc -name \*~ -exec $(RM) {} \;
 
 cleantest:
-# git annex makes files 444, change to user writable so we can delete them
-	if [ -d $(testdir) ] ; then chmod u+w -R $(testdir) ; fi
-	$(RMR) $(testdir)
+# git-annex creates non-writable directories so that the files within
+# them can't be removed; if rm fails, try to recover by making all
+# directories writable
+	-$(RMR) $(testdir) || { \
+	  $(FIND) $(testdir) -type d -exec $(CHMOD) u+w {} + && \
+	  $(RMR) $(testdir) ; \
+	}