From: Leandro Lucarella Date: Tue, 22 Sep 2009 15:09:59 +0000 (-0300) Subject: Add a valgrind function X-Git-Url: https://git.llucax.com/software/makeit.git/commitdiff_plain/6f045d91850bab9b78c3283f1b2e230fd18751b4?ds=sidebyside Add a valgrind function The new valgrind function runs a command through valgrind if $(VALGRIND) is non-empty. This is generally useful to use in the "test" goals. --- diff --git a/Lib.mak b/Lib.mak index f948eca..6893b46 100644 --- a/Lib.mak +++ b/Lib.mak @@ -29,6 +29,17 @@ IFLAGS ?= -D # Use pre-compiled headers if non-empty GCH ?= +# If non-empty, use valgrind to run commands via the "valgrind" function +VALGRIND ?= + +# Options to pass to valgrind; if the variable $(VALGRIND_SUPP) is non-empty +# it will be used as a suppressions file. +VALGRIND_CMD ?= valgrind --tool=memcheck --leak-check=yes --db-attach=no \ + --num-callers=24 --leak-resolution=high --track-fds=yes \ + --error-exitcode=1 \ + $(if $V,--log-file=$<.valgrind.log) \ + $(if $(VALGRIND_SUPP),--suppressions=$(VALGRIND_SUPP)) + # Directories ############## @@ -223,6 +234,15 @@ S := $$(_parent__$d__dir_) endef include_subdirs = $(foreach d,$1,$(eval $(build_subdir_code))) +# Run a command through valgrind if $(VALGRIND) is non-empty. The first and +# only argument is the command to. If $(VALGRIND) is empty, the command is +# executed as passed to this function. If valgrind is used, the +# $(VALGRIND_CMD) is prepended to the command to run. See VALGRIND_CMD +# definition for extra options that can be passed as make variables. +valgrind = $(call exec,$(if $(VALGRIND),$(VALGRIND_CMD)) $1,\ + $(if $(VALGRIND),[$(firstword $(VALGRIND_CMD))], ),\ + $(firstword $1)) + # Overridden flags ##################