diff --git a/.astyle.options b/.astyle.options new file mode 100644 index 0000000000000000000000000000000000000000..0a17526e3b244fb1a78380cd1479dc95b40fad54 --- /dev/null +++ b/.astyle.options @@ -0,0 +1 @@ +-n --indent=spaces=2 --keep-one-line-statements --keep-one-line-blocks diff --git a/Makefile b/Makefile index 47ea922b1b57cd2496f5e75e2de1e5c522cb0e70..c7302fac59995188dcb9fc73a64754a16822d888 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,12 @@ endif SRCDIRS := src test -SUBDIRS := $(SRCDIRS) user-doc developer-doc regtest macports vim +SUBDIRS := $(SRCDIRS) user-doc developer-doc regtest macports vim astyle SUBDIRSCLEAN:=$(addsuffix .clean,$(SUBDIRS)) -.PHONY: all lib clean $(SRCDIRS) doc docclean check cppcheck distclean all_plus_docs macports codecheck plumedcheck +.PHONY: all lib clean $(SRCDIRS) doc docclean check cppcheck distclean all_plus_docs macports codecheck plumedcheck astyle # if machine dependent configuration has been found: ifdef GCCDEP @@ -111,5 +111,8 @@ stamp-h: sourceme.sh.in Makefile.conf.in config.status config.status: configure ./config.status --recheck +astyle: + $(MAKE) -C astyle + $(MAKE) -C src astyle diff --git a/astyle/.gitignore b/astyle/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..dbd60edda5c57a80c41481b0e4f5f3814c86e079 --- /dev/null +++ b/astyle/.gitignore @@ -0,0 +1 @@ +astyle diff --git a/astyle/Makefile b/astyle/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..cb01f9b336759eba1757fd0c936eb908f302fbc4 --- /dev/null +++ b/astyle/Makefile @@ -0,0 +1,9 @@ +.PHONY: astyle + +astyle: + $(MAKE) -C build/gcc + ln -fs build/gcc/bin/astyle . + +clean: + $(MAKE) -C build/gcc clean + rm -f astyle diff --git a/src/.gitignore b/src/.gitignore index 668919a380d45fbf691c1a9233024ec4a1e62c5e..399e65c9ef2fbbeb2d7fafc2c666f2289a86b6d7 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -15,8 +15,6 @@ !/function !/generic !/gridtools -!/header.sh -!/release.sh !/imd !/lapack !/lib @@ -33,6 +31,9 @@ !/vatom !/vesselbase !/wrapper +!/header.sh +!/release.sh +!/astyle.sh # And just ignore these files *.xxd diff --git a/src/Makefile b/src/Makefile index 3a7e14bf2bd5ad10c3086ec0a5aa5514f3d2a05e..66b3159276b7be0fb0ab4715316582429c5c591f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ -.PHONY: all clean lib install uninstall install-html +.PHONY: all clean lib install uninstall install-html astyle # by default we compile the lib directory, which in turn requests all the needeed modules all: lib @@ -49,4 +49,8 @@ help: @echo " cppcheck: check source (requires cppcheck and gawk installed)" @echo " plumedcheck: check source (requires gawk installed)" +astyle: + $(MAKE) -C ../astyle + ./astyle.sh + diff --git a/src/astyle.sh b/src/astyle.sh new file mode 100755 index 0000000000000000000000000000000000000000..308b30ae65ca926b00ad2aaf3cea63849374ef9e --- /dev/null +++ b/src/astyle.sh @@ -0,0 +1,46 @@ +#! /bin/bash + +DIRS=$1 + +# remove trailing "/" +DIRS=${DIRS%%/*} + +test -z "$DIRS" && DIRS=* + +for dir in $DIRS +do +test -d "$dir" || continue + +test "$dir" = lapack && continue +test "$dir" = blas && continue +test "$dir" = molfile && continue + +cd $dir + + +for file in *.c *.cpp *.h *.inc.in +do + +test -f "$file" || continue + +echo -n "astyle $file" + +../../astyle/astyle --options=../../.astyle.options < $file > $file.tmp && { +if cmp -s $file $file.tmp ; then + echo +else + cp $file.tmp $file + echo " +++ PATCHED" + git add $file +fi +} + +rm $file.tmp + +done + +cd - + +done + +