diff --git a/Makefile b/Makefile index 9affd9e4..1531d7af 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ MAKEFLAGS += --no-print-directory endif YAMLFILES := $(shell find . -name 'irq.yaml') +STYLECHECKFILES := $(shell find . -name '*.[ch]') all: build @@ -88,7 +89,7 @@ install: lib doc: $(Q)$(MAKE) -C doc html -clean: $(YAMLFILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) doc.clean +clean: $(YAMLFILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) doc.clean styleclean %.clean: $(Q)if [ -d $* ]; then \ @@ -96,12 +97,23 @@ clean: $(YAMLFILES:=.cleanhdr) $(LIB_DIRS:=.clean) $(EXAMPLE_DIRS:=.clean) doc.c $(MAKE) -C $* clean SRCLIBDIR=$(SRCLIBDIR) || exit $?; \ fi; -stylecheck: - $(Q)for i in `find . -name '*.[ch]'` ; do \ - if ! grep -q "* It was generated by the irq2nvic_h script." $$i ; then \ - $(STYLECHECK) $(STYLECHECKFLAGS) $$i; \ - fi ; \ - done -.PHONY: build lib $(LIB_DIRS) install doc clean stylecheck +stylecheck: $(STYLECHECKFILES:=.stylecheck) +styleclean: $(STYLECHECKFILES:=.styleclean) + +# the cat is due to multithreaded nature - we like to have consistent chunks of text on the output +%.stylecheck: + $(Q)if ! grep -q "* It was generated by the irq2nvic_h script." $* ; then \ + $(STYLECHECK) $(STYLECHECKFLAGS) $* > $*.stylecheck; \ + if [ -s $*.stylecheck ]; then \ + cat $*.stylecheck; \ + else \ + rm -f $*.stylecheck; \ + fi; \ + fi; + +%.styleclean: + $(Q)rm -f $*.stylecheck; + +.PHONY: build lib $(LIB_DIRS) install doc clean stylecheck styleclean