subdir-% subdir-apps/%:
$(MAKE) -C $(@:subdir-%=%) $(MAKECMDGOALS)
+
+
+C_H_FILES = $(shell git ls-files|grep -e '\.[ch]$$')
+UNCRUSTIFY_CFG = $(dir $(lastword $(MAKEFILE_LIST)))/etc/uncrustify.cfg
+define UNCRUSTIFY_ALL
+$(foreach i,$(C_H_FILES),git show HEAD:$i | uncrustify -c $(UNCRUSTIFY_CFG) -o $i
+)
+endef
+
+# Usage: Run 'make uncrustify' and then 'git add -p' to commit the
+# changes you agree with.
+uncrustify:
+ -git diff --quiet # Check that the tree is clean
+ $(UNCRUSTIFY_ALL)