endif
endif
+# Debug message autocolourisation range
+#
+DBGCOL_LIST := $(BIN)/.dbgcol.list
+ifeq ($(wildcard $(DBGCOL_LIST)),)
+DBGCOL_OLD := <invalid>
+else
+DBGCOL_OLD := $(shell cat $(DBGCOL_LIST))
+endif
+ifneq ($(DBGCOL_OLD),$(DBGCOL))
+$(shell $(ECHO) "$(DBGCOL)" > $(DBGCOL_LIST))
+endif
+
+$(DBGCOL_LIST) : $(MAKEDEPS)
+
+VERYCLEANUP += $(DBGCOL_LIST)
+
+DBGCOL_COLOURS := $(subst -, ,$(DBGCOL))
+DBGCOL_MIN := $(word 1,$(DBGCOL_COLOURS))
+DBGCOL_MAX := $(word 2,$(DBGCOL_COLOURS))
+
+debug_DEPS += $(DBGCOL_LIST)
+
+CFLAGS_debug += $(if $(DBGCOL_MIN),-DDBGCOL_MIN=$(DBGCOL_MIN))
+CFLAGS_debug += $(if $(DBGCOL_MAX),-DDBGCOL_MAX=$(DBGCOL_MAX))
+
# We automatically generate rules for any file mentioned in AUTO_SRCS
# using the following set of templates. We use $(eval ...) if
# available, otherwise we generate separate Makefile fragments and
}
}
+/**
+ * Base message stream colour
+ *
+ * We default to using 31 (red foreground) as the base colour.
+ */
+#ifndef DBGCOL_MIN
+#define DBGCOL_MIN 31
+#endif
+
/**
* Maximum number of separately coloured message streams
*
* of which will be the terminal default and one of which will be
* invisible on the terminal because it matches the background colour.
*/
-#define NUM_AUTO_COLOURS 6
+#ifndef DBGCOL_MAX
+#define DBGCOL_MAX ( DBGCOL_MIN + 6 - 1 )
+#endif
/** A colour assigned to an autocolourised debug message stream */
struct autocolour {
* @ret colour Colour ID
*/
static int dbg_autocolour ( unsigned long stream ) {
- static struct autocolour acs[NUM_AUTO_COLOURS];
+ static struct autocolour acs[ DBGCOL_MAX - DBGCOL_MIN + 1 ];
static unsigned long use;
unsigned int i;
unsigned int oldest;
*/
void dbg_autocolourise ( unsigned long stream ) {
dbg_printf ( "\033[%dm",
- ( stream ? ( 31 + dbg_autocolour ( stream ) ) : 0 ) );
+ ( stream ? ( DBGCOL_MIN + dbg_autocolour ( stream ) ) :0));
}
/**