aboutsummaryrefslogtreecommitdiffstats
path: root/src/Makefile.housekeeping
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2016-07-05 13:28:51 +0100
committerMichael Brown <mcb30@ipxe.org>2016-07-05 13:28:51 +0100
commit46719f2264fc63deaa712f4dc164d3b33c66e05f (patch)
tree08905147393d593afa255728a5329c940234a88e /src/Makefile.housekeeping
parent6e1ce52d146fe8197c1b58e2e3b0ebcf9ccda349 (diff)
downloadipxe-46719f2264fc63deaa712f4dc164d3b33c66e05f.tar.gz
[libc] Allow assertions to be globally enabled or disabled
Assertions are enabled for objects built with any debug level (including an explicit debug level of zero). It is sometimes useful to be able to enable assertions across all objects; this currently requires manually hacking include/assert.h. Allow assertions to be globally enabled by adding ASSERT=1 to the build command line. For example: make bin/8086100e.mrom ASSERT=1 Similarly, allow assertions to be globally disabled by adding ASSERT=0 to the build command line. If no ASSERT=... is specified on the build command line, then only objects mentioned in DEBUG=... will have assertions enabled (as is currently the case). Note than globally enabling assertions imposes a relatively heavy runtime penalty, primarily due to the various sanity checks performed by list_add(), list_for_each_entry(), etc. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/Makefile.housekeeping')
-rw-r--r--src/Makefile.housekeeping27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index 264b9d0f9..a02acc8dd 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.