]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[profile] Allow profiling to be globally enabled or disabled
authorMichael Brown <mcb30@ipxe.org>
Tue, 5 Jul 2016 12:45:54 +0000 (13:45 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 5 Jul 2016 12:49:51 +0000 (13:49 +0100)
As with assertions, profiling is enabled for objects built with any
debug level (including an explicit debug level of zero).

Allow profiling to be globally enabled or disabled by adding PROFILE=1
or PROFILE=0 respectively to the build command line.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/Makefile.housekeeping
src/include/ipxe/profile.h

index a02acc8ddcdaf7ebc439b50b0ab6410c9c55d289..f09db37289e3d29382dc46deda1df491dce17d4c 100644 (file)
@@ -747,6 +747,33 @@ include/assert.h : $(ASSERT_LIST)
 
 .PRECIOUS : include/assert.h
 
+# (Single-element) list of profiling configuration
+#
+PROFILE_LIST := $(BIN)/.profile.list
+ifeq ($(wildcard $(PROFILE_LIST)),)
+PROFILE_OLD := <invalid>
+else
+PROFILE_OLD := $(shell cat $(PROFILE_LIST))
+endif
+ifneq ($(PROFILE_OLD),$(PROFILE))
+$(shell $(ECHO) "$(PROFILE)" > $(PROFILE_LIST))
+endif
+
+$(PROFILE_LIST) : $(MAKEDEPS)
+
+VERYCLEANUP += $(PROFILE_LIST)
+
+# Profiling configuration
+#
+ifneq ($(PROFILE),)
+CFLAGS += -DPROFILING=$(PROFILE)
+endif
+
+include/ipxe/profile.h : $(PROFILE_LIST)
+       $(Q)$(TOUCH) $@
+
+.PRECIOUS : include/ipxe/profile.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.
index b6d2b19e03483f2a90adf411b86df077bc7ebfa0..2c69e120840243b099ca766b97f0bf3fb201a992 100644 (file)
@@ -12,11 +12,13 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <bits/profile.h>
 #include <ipxe/tables.h>
 
+#ifndef PROFILING
 #ifdef NDEBUG
 #define PROFILING 0
 #else
 #define PROFILING 1
 #endif
+#endif
 
 /**
  * A data structure for storing profiling information