Skip to contentSkip to conversation

Makefile: fix "make clean" for old GNU find

PATCH Superseded Brian Norris 3 participants 5 messages Mar 2, 2012 – Mar 9, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: fix "make clean" for old GNU find

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
---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
index 17a1216..0cbbecc 100644
@@ -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
#1 lore raw
Quoted 2 lines · Brian Norris

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

Quoted 1 line

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

#2 lore raw
Quoted 11 lines · Mike Frysinger
Quoted 1 line · Brian Norris

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

#3 lore raw
Quoted 13 lines · Brian Norris
Quoted 11 lines · Mike Frysinger
Quoted 1 line · Brian Norris

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

Quoted 3 lines

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?

Signature · 2 lines
Best Regards,
Artem Bityutskiy
#4 lore raw
Quoted 2 lines · Artem Bityutskiy

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