diff --git a/Makefile.am b/Makefile.am index 08363169..27efe8da 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,3 +18,14 @@ ChangeLog: GIT_DIR=${srcdir}/.git git-log > ChangeLog dist-hook: ChangeLog + +if LINT +# Check source code with tools like lint & sparse +LINT_SUBDIRS=src # modules + +lint: + @for subdir in $(LINT_SUBDIRS) ; do \ + echo "Making $@ in $$subdir"; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) lint) ; \ + done +endif LINT diff --git a/configure.ac b/configure.ac index e3071c21..1988eb6e 100644 --- a/configure.ac +++ b/configure.ac @@ -314,6 +314,10 @@ if test x"$COMPOSECACHE" = "xyes"; then AC_DEFINE(COMPOSECACHE,1,[Include compose table cache support]) fi +dnl Allow checking code with lint, sparse, etc. +XORG_WITH_LINT +LINT_FLAGS="${LINT_FLAGS} ${X11_CFLAGS} ${XPROTO_CFLAGS}" + if test "x$GCC" = "xyes"; then GCC_WARNINGS="-Wall -Wpointer-arith -Wstrict-prototypes \ -Wmissing-prototypes -Wmissing-declarations \ diff --git a/src/Makefile.am b/src/Makefile.am index 89f845fd..32f55f03 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -380,6 +380,22 @@ preprocess: $(patsubst %.c,%.ii,$(libX11_la_SOURCES)) .c.ii: $(COMPILE) -E -o $@ `test -f '$<' || echo '$(srcdir)/'`$< +if LINT +# Check source code with tools like lint & sparse + +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) + +lint: $(BUILT_SOURCES) + for f in $(libX11_la_SOURCES) ; do \ + $(LINT) $(ALL_LINT_FLAGS) $$f ; \ + done + @for subdir in $(SUBDIRS) ; do \ + echo "Making $@ in src/$$subdir"; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) lint) ; \ + done +endif LINT + # # Building ks_tables.h requires the makekeys utility # diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 72c97758..3ff421d0 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -8,3 +8,14 @@ makekeys_CFLAGS=$(X11_CFLAGS) LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ EXTRA_DIST = mkks.sh + +if LINT +# Check source code with tools like lint & sparse + +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) + +lint: + $(LINT) $(ALL_LINT_FLAGS) makekeys.c + +endif LINT diff --git a/src/xcms/Makefile.am b/src/xcms/Makefile.am index 2251acb7..dac620e5 100644 --- a/src/xcms/Makefile.am +++ b/src/xcms/Makefile.am @@ -84,3 +84,15 @@ libxcms_la_SOURCES = \ X11dir = $(libdir)/X11 dist_X11_DATA = Xcms.txt + + +if LINT +# Check source code with tools like lint & sparse + +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) + +lint: + $(LINT) $(ALL_LINT_FLAGS) $(libxcms_la_SOURCES) -lm + +endif LINT diff --git a/src/xkb/Makefile.am b/src/xkb/Makefile.am index 896a0995..d5431546 100644 --- a/src/xkb/Makefile.am +++ b/src/xkb/Makefile.am @@ -37,3 +37,14 @@ libxkb_la_SOURCES = \ XKBGAlloc.c \ XKBAlloc.c \ XKBlibint.h + +if LINT +# Check source code with tools like lint & sparse + +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) + +lint: + $(LINT) $(ALL_LINT_FLAGS) $(libxkb_la_SOURCES) -lm + +endif LINT diff --git a/src/xlibi18n/Makefile.am b/src/xlibi18n/Makefile.am index 284ff63d..b97316a1 100644 --- a/src/xlibi18n/Makefile.am +++ b/src/xlibi18n/Makefile.am @@ -134,3 +134,14 @@ EXTRA_DIST = \ lcUniConv/COPYRIGHT \ lcUniConv/8bit_tab_to_h.c \ lcUniConv/cjk_tab_to_h.c + +if LINT +# Check source code with tools like lint & sparse + +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) + +lint: + $(LINT) $(ALL_LINT_FLAGS) $(libi18n_la_SOURCES) + +endif LINT