|  | #!/bin/sh | 
|  | # | 
|  | # This script generates the required file for supporting the debug | 
|  | # channels used throught the code. | 
|  | # The generated file is | 
|  | #   include/debugdefs.h | 
|  | # The script must be run in the root directory of the project. | 
|  | # | 
|  | # Dimitrie O. Paun <dimi@cs.toronto.edu> | 
|  | # Patrik Stridvall <ps@leissner.se> | 
|  | # | 
|  |  | 
|  | DEBUG_CHANNELS=`tools/find_debug_channels` | 
|  |  | 
|  | exec > include/debugdefs.h | 
|  |  | 
|  | cat <<EOF | 
|  | /* Do not modify this file -- it is automatically generated! */ | 
|  |  | 
|  | #include "debugtools.h" | 
|  |  | 
|  | #define DEBUG_CLASS_COUNT __DBCL_COUNT | 
|  |  | 
|  | static const char * const debug_cl_name[] = { "fixme", "err", "warn", "trace" }; | 
|  |  | 
|  | EOF | 
|  |  | 
|  | chno=0 | 
|  | for ch in $DEBUG_CHANNELS | 
|  | do | 
|  | echo "char dbch_$ch[] = \"\\003$ch\";" | 
|  | chno=`expr $chno + 1` | 
|  | done | 
|  | echo | 
|  | echo "#define DEBUG_CHANNEL_COUNT $chno" | 
|  |  | 
|  | count=1 | 
|  | echo | 
|  | echo 'static char * const debug_channels[DEBUG_CHANNEL_COUNT] = {' | 
|  | for ch in $DEBUG_CHANNELS | 
|  | do | 
|  | if [ "${count}" != "${chno}" ]; then | 
|  | echo "    dbch_${ch}," | 
|  | else | 
|  | echo "    dbch_${ch}" | 
|  | fi | 
|  | count=`expr $count + 1` | 
|  | done | 
|  | echo '};' | 
|  |  | 
|  | for cls in err fixme warn trace | 
|  | do | 
|  | cat <<EOF | 
|  |  | 
|  | int dbg_header_$cls( const char *dbg_channel, const char *func ) | 
|  | { | 
|  | return dbg_printf( "$cls:%s:%s ", dbg_channel + 1, func ); | 
|  | } | 
|  | EOF | 
|  | done |