From d3d1a995a536919c813a5817e12881554f173642 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 7 Oct 2015 12:52:52 +0200 Subject: btrfs-progs: build: make support for static checkers more generic Signed-off-by: David Sterba --- Makefile.in | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'Makefile.in') diff --git a/Makefile.in b/Makefile.in index d176998f..b3081f4e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -14,6 +14,10 @@ # EXTRA_CFLAGS additional compiler flags # EXTRA_LDFLAGS additional linker flags # +# Static checkers: +# CHECKER static checker binary to be called (default: sparse) +# CHECKER_FLAGS flags to pass to CHECKER, can override CFLAGS +# # Export all variables to sub-makes by default export @@ -52,6 +56,14 @@ STATIC_LDFLAGS = -static -Wl,--gc-sections STATIC_LIBS = @UUID_LIBS_STATIC@ @BLKID_LIBS_STATIC@ \ @ZLIB_LIBS_STATIC@ @LZO2_LIBS_STATIC@ -L. -pthread +# don't use FORTIFY with sparse because glibc with FORTIFY can +# generate so many sparse errors that sparse stops parsing, +# which masks real errors that we want to see. +CHECKER := sparse +CHECKER_FLAGS := -include $(check_defs) -D__CHECKER__ \ + -D__CHECK_ENDIAN__ -Wbitwise -Wuninitialized -Wshadow -Wundef \ + -U_FORTIFY_SOURCE + objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \ extent-cache.o extent_io.o volumes.o utils.o repair.o \ @@ -144,7 +156,6 @@ headers = $(libbtrfs_headers) # make C=1 to enable sparse check_defs := .cc-defines.h ifdef C - # # We're trying to use sparse against glibc headers which go wild # trying to use internal compiler macros to test features. We # copy gcc's and give them to sparse. But not __SIZE_TYPE__ @@ -152,13 +163,8 @@ ifdef C # dummy := $(shell $(CC) -dM -E -x c - < /dev/null | \ grep -v __SIZE_TYPE__ > $(check_defs)) - check = sparse -include $(check_defs) -D__CHECKER__ \ - -D__CHECK_ENDIAN__ -Wbitwise -Wuninitialized -Wshadow -Wundef + check = $(CHECKER) check_echo = echo - # don't use FORTIFY with sparse because glibc with FORTIFY can - # generate so many sparse errors that sparse stops parsing, - # which masks real errors that we want to see. - CFLAGS += -U_FORTIFY_SOURCE else check = true check_echo = true @@ -169,7 +175,7 @@ endif .c.o: @$(check_echo) " [SP] $<" - $(Q)$(check) $(CFLAGS) $< + $(Q)$(check) $(CFLAGS) $(CHECKER_FLAGS) $< @echo " [CC] $@" $(Q)$(CC) $(CFLAGS) -c $< -- cgit v1.2.3