]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - Makefile
Add configuration for uncrustify
[pes-rpp/rpp-lib.git] / Makefile
index 7d0ea518758347baf1b37889fe4ba7909395aaa2..10ce7fe871bb7bfb414e50afda5207d860802e9b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,3 +25,17 @@ doc: # Build API documentation (Doxygen)
 
 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)