aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-04-30 17:19:18 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-04-30 17:19:18 +0300
commitc229680ada76ee98f424980cc6a41dc86b2632d0 (patch)
tree65769396f51fdbd1e1dcb0c205a8564c8e4c4989
parent191eaea25cf569ad9c5fb12b8755ae6400750e58 (diff)
downloadgran-c229680ada76ee98f424980cc6a41dc86b2632d0.tar.gz
gran-c229680ada76ee98f424980cc6a41dc86b2632d0.zip
add linting
-rw-r--r--Makefile6
-rwxr-xr-xscripts/gen-deps5
2 files changed, 11 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 32bae41..730d805 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@ DO != echo -n > deps.mk
DEBUGFLAGS != [ $(RELEASE) ] && echo "-flto=auto -O2 -g -DNODEBUG" || echo "-O0 -g -DDEBUG"
CFLAGS = -Wall -Wextra -fopenmp
DEPFLAGS = -MT $@ -MMD -MP -MF $@.d
+LINTFLAGS = -fsyntax-only
INCLUDEFLAGS = -Iinclude
COMPILEFLAGS =
LINKFLAGS =
@@ -22,12 +23,17 @@ include src/source.mk
COMPILE = $(CROSS_COMPILE)$(CC) $(DEBUGFLAGS)\
$(CFLAGS) $(DEPFLAGS) $(COMPILEFLAGS) $(INCLUDEFLAGS)
+LINT = $(COMPILE) $(LINTFLAGS)
+
OBJS != ./scripts/gen-deps --sources "$(SOURCES)"
MAIN_OBJ != ./scripts/gen-deps --sources "$(MAIN_SRC)"
include tests/source.mk
include deps.mk
+.PHONY: lint
+lint: $(OBJS:.o=.o.l)
+
.PHONY: format
format:
@cd src; find . -iname '*.[ch]' |\
diff --git a/scripts/gen-deps b/scripts/gen-deps
index befd25d..0feed7e 100755
--- a/scripts/gen-deps
+++ b/scripts/gen-deps
@@ -1,17 +1,22 @@
#!/bin/sh
gencommon () {
+ lint="build/${s%.*}${1}.l"
dep="build/${s%.*}${1}.d"
obj="build/${s%.*}${1}"
echo "${dep}:" >> deps.mk
echo "include ${dep}" >> deps.mk
+ echo "${obj}: ${s}" >> deps.mk
}
genobjs () {
gencommon ".o"
echo "${obj}: ${s}" >> deps.mk
echo " \$(COMPILE) -c $< -o \$@" >> deps.mk
+
+ echo "${lint}: ${s}" >> deps.mk
+ echo " \$(LINT) -c ${s} -o /dev/null" >> deps.mk
}
case "${1}" in