Skip to content

Commit 020c75c

Browse files
committed
Add reformat target for consistent code formatting.
Signed-off-by: Victor Toni <[email protected]>
1 parent f47644d commit 020c75c

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.clang-format

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
BasedOnStyle: LLVM
2+
Language: Cpp
3+
4+
IndentWidth: 4
5+
ContinuationIndentWidth: 8
6+
7+
ColumnLimit: 120
8+
9+
MaxEmptyLinesToKeep: 2
10+
11+
AllowShortFunctionsOnASingleLine: Empty
12+
AlwaysBreakBeforeMultilineStrings: true

Makefile.am

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ ChangeLog:
88
AUTHORS: ChangeLog
99
( echo "Authors and contributors, in alphabetical order: "; echo; \
1010
sed -r "s/^Author: (.*)/\1/;t;d" $< | sort -u ) > $@
11+
12+
if HAVE_CLANG_FORMAT
13+
14+
.PHONY: reformat
15+
16+
reformat:
17+
@echo "Reformatting header files..."
18+
@CLANG_FORMAT@ -style=file -i `find . -name "*.h"`
19+
@echo "Reformatting C files..."
20+
@CLANG_FORMAT@ -style=file -i `find . -name "*.c"`
21+
22+
endif

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ AC_CONFIG_SRCDIR([src/igmpproxy.c])
55
AC_CONFIG_HEADERS([config.h])
66
AC_PROG_CC_C99
77

8+
AC_CHECK_PROGS(
9+
[CLANG_FORMAT], [clang-format clang-format-4.0 clang-format-3.9],
10+
[AC_MSG_ERROR([clang-format was not not found during configure.])]
11+
)
12+
AM_CONDITIONAL([HAVE_CLANG_FORMAT], [test -n "$CLANG_FORMAT"])
13+
814
AC_CANONICAL_HOST
915
case $host_os in
1016
linux*|uclinux*) os=linux;;

0 commit comments

Comments
 (0)