diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f18bbda --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +BasedOnStyle: webkit diff --git a/Makefile b/Makefile index 2bb6f59..642f58a 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ else endif srcs+=$(wildcard ${src_dir}/*.c ${src_dir}/**/*.c) +headers+=$(wildcard ${src_dir}/*.h ${src_dir}/**/*.h) objs+=$(patsubst %.c,${build_dir}/%.o,${srcs}) .PHONY: all @@ -122,6 +123,14 @@ ${build_dir}/%.o: %.c compile_flags.txt: (echo "${CFLAGS} ${LDFLAGS}" | sed 's/ /\n/g') > compile_flags.txt +.PHONY: format +format: + clang-format -i ${srcs} ${headers} + +.PHONY: check_format +check_format: + clang-format --dry-run --Werror ${srcs} ${headers} + .PHONY: clean clean: ${RM} -r build install