diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 264b9d0f..a02acc8d 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -720,6 +720,33 @@ config/named.h : $(CONFIG_LIST) .PRECIOUS : config/named.h +# (Single-element) list of assertion configuration +# +ASSERT_LIST := $(BIN)/.assert.list +ifeq ($(wildcard $(ASSERT_LIST)),) +ASSERT_OLD := +else +ASSERT_OLD := $(shell cat $(ASSERT_LIST)) +endif +ifneq ($(ASSERT_OLD),$(ASSERT)) +$(shell $(ECHO) "$(ASSERT)" > $(ASSERT_LIST)) +endif + +$(ASSERT_LIST) : $(MAKEDEPS) + +VERYCLEANUP += $(ASSERT_LIST) + +# Assertion configuration +# +ifneq ($(ASSERT),) +CFLAGS += -DASSERTING=$(ASSERT) +endif + +include/assert.h : $(ASSERT_LIST) + $(Q)$(TOUCH) $@ + +.PRECIOUS : include/assert.h + # These files use .incbin inline assembly to include a binary file. # Unfortunately ccache does not detect this dependency and caches # builds even when the binary file has changed. diff --git a/src/include/assert.h b/src/include/assert.h index 07f3ecb8..dd71fa71 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -12,11 +12,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#ifndef ASSERTING #ifdef NDEBUG #define ASSERTING 0 #else #define ASSERTING 1 #endif +#endif extern unsigned int assertion_failures;