]> www.infradead.org Git - mtd-utils.git/commitdiff
Makefile: fix "make clean" for old GNU find
authorBrian Norris <computersforpeace@gmail.com>
Fri, 9 Mar 2012 17:49:09 +0000 (09:49 -0800)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Mon, 12 Mar 2012 13:07:27 +0000 (15:07 +0200)
findutils v4.1.x does not have the `-exec CMD {} +' syntax. We can just as
easily use the `-exec CMD {} \;' syntax. However, it will launch a lot more
`rm' processes, so we only use it if the first form fails with an error.
This isn't a perfect solution (`find -exec +' can fail for other reasons)
but it works well enough.

This problem manifests itself in RHEL 4, findutils 4.1.20:

  $ make clean
  rm -f /XXX/mtd-utils/*.o /XXX/mtd-utils/ftl_format  ...
  find: missing argument to `-exec'
  make: *** [clean] Error 1

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Makefile

index 17a12166b013da28f9272604bb947092b4d11ce4..7506ed49d25dad7469c815ac8c75247469702106 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,8 @@ OBJDEPS = $(BUILDDIR)/include/version.h
 
 include common.mk
 
+CLEAN_FIND = find "$(BUILDDIR)/" -xdev '(' -name '*.[ao]' -o -name '.*.c.dep' ')'
+
 clean::
 ifneq ($(BUILDDIR)/.git,)
 ifneq ($(BUILDDIR),.)
@@ -50,10 +52,10 @@ ifneq ($(BUILDDIR),$(CURDIR))
 endif
 endif
 endif
+       # findutils v4.1.x (RHEL 4) do not have '+' syntax
        @if test -d "$(BUILDDIR)/"; then \
-               find $(BUILDDIR)/ -xdev \
-                       '(' -name '*.[ao]' -o -name '.*.c.dep' ')' \
-                       -exec rm -f {} + ; \
+               $(CLEAN_FIND) -exec rm -f {} + 2> /dev/null || \
+               $(CLEAN_FIND) -exec rm -f {} \; ; \
        fi
        rm -f $(BUILDDIR)/include/version.h
        $(MAKE) -C $(TESTS) clean