public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2] Makefile: fix "make clean" for old GNU find
@ 2012-03-09 17:49 Brian Norris
  2012-03-09 21:14 ` Mike Frysinger
  2012-03-12 13:08 ` Artem Bityutskiy
  0 siblings, 2 replies; 3+ messages in thread
From: Brian Norris @ 2012-03-09 17:49 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: Brian Norris, linux-mtd, Mike Frysinger

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>
Cc: Mike Frysinger <vapier.adi@gmail.com>
---
v2: try '+' syntax, then fall back to old format

 Makefile |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 17a1216..7506ed4 100644
--- 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
-- 
1.7.5.4.2.g519b1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Makefile: fix "make clean" for old GNU find
  2012-03-09 17:49 [PATCH v2] Makefile: fix "make clean" for old GNU find Brian Norris
@ 2012-03-09 21:14 ` Mike Frysinger
  2012-03-12 13:08 ` Artem Bityutskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2012-03-09 21:14 UTC (permalink / raw)
  To: Brian Norris; +Cc: linux-mtd, Artem Bityutskiy

On Fri, Mar 9, 2012 at 12:49, Brian Norris <computersforpeace@gmail.com> wrote:
> 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:

Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Makefile: fix "make clean" for old GNU find
  2012-03-09 17:49 [PATCH v2] Makefile: fix "make clean" for old GNU find Brian Norris
  2012-03-09 21:14 ` Mike Frysinger
@ 2012-03-12 13:08 ` Artem Bityutskiy
  1 sibling, 0 replies; 3+ messages in thread
From: Artem Bityutskiy @ 2012-03-12 13:08 UTC (permalink / raw)
  To: Brian Norris; +Cc: linux-mtd, Mike Frysinger

On Fri, 2012-03-09 at 09:49 -0800, Brian Norris wrote:
> 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:

Pushed, thanks you!

-- 
Best Regards,
Artem Bityutskiy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-12 13:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-09 17:49 [PATCH v2] Makefile: fix "make clean" for old GNU find Brian Norris
2012-03-09 21:14 ` Mike Frysinger
2012-03-12 13:08 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox