Patchwork [(mtd-utils)] Makefile: fix "make clean" for old GNU find

login
register
mail settings
Submitter Brian Norris
Date March 2, 2012, 10:17 p.m.
Message ID <1330726673-9860-1-git-send-email-computersforpeace@gmail.com>
Download mbox | patch
Permalink /patch/144365/
State New
Headers show

Comments

Brian Norris - March 2, 2012, 10:17 p.m.
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...

RHEL 4 still uses findutils 4.1.20 and gets errors like this:

  $ 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>
---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Mike Frysinger - March 8, 2012, 4:54 p.m.
On Fri, Mar 2, 2012 at 17:17, 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.

really it's a workaround for old tools that don't adhere to the new POSIX spec

> However, it will launch a lot more `rm' processes...

indeed, that does suck.  you could do this, but it kind of sucks too ...
CLEAN_FIND = find "$(BUILDDIR)/" -xdev '(' -name '*.[ao]' -o -name
'.*.c.dep' ')'
...
    @if test -d "$(BUILDDIR)/"; then
        $(CLEAN_FIND) -exec rm -f {} + 2>/dev/null || \
        $(CLEAN_FIND) -exec rm -f {} \; ; \
    fi
...
-mike
Brian Norris - March 8, 2012, 5:52 p.m.
On Thu, Mar 8, 2012 at 8:54 AM, Mike Frysinger <vapier.adi@gmail.com> wrote:
> On Fri, Mar 2, 2012 at 17:17, Brian Norris <computersforpeace@gmail.com> wrote:
>> However, it will launch a lot more `rm' processes...
>
> indeed, that does suck.  you could do this, but it kind of sucks too ...
> CLEAN_FIND = find "$(BUILDDIR)/" -xdev '(' -name '*.[ao]' -o -name
> '.*.c.dep' ')'
> ...
>    @if test -d "$(BUILDDIR)/"; then
>        $(CLEAN_FIND) -exec rm -f {} + 2>/dev/null || \
>        $(CLEAN_FIND) -exec rm -f {} \; ; \
>    fi

I'm fine with that too. It's a little uglier, but it's not quite as
bad for systems that have a modern `find', I think. I'll resend with
your suggestion if there are no better suggestions.

Brian
Artem Bityutskiy - March 9, 2012, 9:41 a.m.
On Thu, 2012-03-08 at 09:52 -0800, Brian Norris wrote:
> On Thu, Mar 8, 2012 at 8:54 AM, Mike Frysinger <vapier.adi@gmail.com> wrote:
> > On Fri, Mar 2, 2012 at 17:17, Brian Norris <computersforpeace@gmail.com> wrote:
> >> However, it will launch a lot more `rm' processes...
> >
> > indeed, that does suck.  you could do this, but it kind of sucks too ...
> > CLEAN_FIND = find "$(BUILDDIR)/" -xdev '(' -name '*.[ao]' -o -name
> > '.*.c.dep' ')'
> > ...
> >    @if test -d "$(BUILDDIR)/"; then
> >        $(CLEAN_FIND) -exec rm -f {} + 2>/dev/null || \
> >        $(CLEAN_FIND) -exec rm -f {} \; ; \
> >    fi
> 
> I'm fine with that too. It's a little uglier, but it's not quite as
> bad for systems that have a modern `find', I think. I'll resend with
> your suggestion if there are no better suggestions.

May be adding a one-line comment like "work-around for ancient find
utils not supporting '+'" would also be a good idea?
Brian Norris - March 9, 2012, 5:46 p.m.
On Fri, Mar 9, 2012 at 1:41 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> May be adding a one-line comment like "work-around for ancient find
> utils not supporting '+'" would also be a good idea?

Already have something similar in my patch. Will send now.

Brian

Patch

diff --git a/Makefile b/Makefile
index 17a1216..0cbbecc 100644
--- a/Makefile
+++ b/Makefile
@@ -53,7 +53,7 @@  endif
 	@if test -d "$(BUILDDIR)/"; then \
 		find $(BUILDDIR)/ -xdev \
 			'(' -name '*.[ao]' -o -name '.*.c.dep' ')' \
-			-exec rm -f {} + ; \
+			-exec rm -f {} \; ; \
 	fi
 	rm -f $(BUILDDIR)/include/version.h
 	$(MAKE) -C $(TESTS) clean