summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.housekeeping27
-rw-r--r--src/include/assert.h2
2 files changed, 29 insertions, 0 deletions
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 := <invalid>
+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;