From 93c8ec4e252d5f636af61c2db7f033d415fe1f8c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Tue, 12 Mar 2024 10:35:58 +1300 Subject: [PATCH] makefile: add format target Runs clang-format over all source files and headers. --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 85a49be..8aca88c 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ MANPREFIX = ${PREFIX}/man LUADIR = external/lua +CLANG_FORMAT = clang-format + CC = ${_CC} CFLAGS = ${_CFLAGS} -Iexternal -pedantic -Wall -Wextra CPPFLAGS = -D_DEFAULT_SOURCE ${_CPPFLAGS} @@ -66,6 +68,10 @@ clean: doc: ldoc -s . -q . >/dev/null +format: + find . -maxdepth 1 -iname '*.c' -o -iname '*.h' \ + | xargs ${CLANG_FORMAT} -i + install: mkdir -p "${DESTDIR}${PREFIX}"/bin mkdir -p "${DESTDIR}${PREFIX}"/include/callisto @@ -76,4 +82,4 @@ install: cp -f libcallisto.a "${DESTDIR}${PREFIX}"/lib/ cp -f man/csto.1 "${DESTDIR}${PREFIX}"/share/man/man1/ -.PHONY: all clean doc install +.PHONY: all clean doc format install