Release 941122
[wine/multimedia.git] / tools / make_debug
blobe7d5460e305e57897e4b77e3baf04b4446d16249
1 #!/bin/sh
3 # This script scans the whole source code for symbols of the form dprintf_xxx,
4 # generates the necessary macro definitions and puts them into the files
5 # include/stddebug.h and include/debug.h . This script must be started with
6 # cwd = rootdir of the Wine-distribution.
8 # Michael Patra <micky@marie.physik.tu-berlin.de>
10 DEBUG_H=include/debug.h
11 STDDEBUG_H=include/stddebug.h
13 mv $DEBUG_H $DEBUG_H.old
14 mv $STDDEBUG_H $STDDEBUG_H.old
16 # Build the list of debug identifiers
17 grep -h dprintf_ */*.c | sed 's/.*dprintf_\([A-Za-z0-9_]*\).*/\1/g' | \
18 sort | uniq > temp.$$
20 # Build debug.h
22 sed '/^\/\* Do not remove this line or change anything below this line \*\//q'\
23 <$DEBUG_H.old >$DEBUG_H
24 cat <<++EOF++ >> $DEBUG_H
26 #ifdef DEBUG_NONE_EXT
27 ++EOF++
29 cat temp.$$ | tr a-z A-Z |
31 while read x
33 echo "#undef DEBUG_$x" >> $DEBUG_H
34 done
37 cat <<++EOF++ >>$DEBUG_H
38 #endif
40 #ifdef DEBUG_ALL_EXT
41 ++EOF++
43 cat temp.$$ | tr a-z A-Z |
45 while read x
47 echo "#define DEBUG_$x" >> $DEBUG_H
48 done
51 cat <<++EOF++ >>$DEBUG_H
52 #endif
54 #ifdef DEBUG_RUNTIME
55 #ifdef DEBUG_DEFINE_VARIABLES
56 short debug_msg_enabled[]={
57 ++EOF++
59 cat temp.$$ | tr a-z A-Z |
61 while read x
63 cat <<++EOF++ >>$DEBUG_H
64 #ifdef DEBUG_$x
66 #else
68 #endif
69 ++EOF++
71 done
74 cat <<++EOF++ >>$DEBUG_H
77 #else
78 extern short debug_msg_enabled[];
79 #endif
80 #endif
82 ++EOF++
84 i=0
85 cat temp.$$ |
87 while read x
89 y=`echo $x | tr a-z A-Z`
90 cat <<++EOF++ >>$DEBUG_H
91 #ifdef DEBUG_RUNTIME
92 #define dprintf_$x if(debug_msg_enabled[$i]) fprintf
93 #else
94 #ifdef DEBUG_$y
95 #define dprintf_$x fprintf
96 #else
97 #define dprintf_$x
98 #endif
99 #endif
101 ++EOF++
102 let i=$i+1
103 done
106 cat <<++EOF++ >>$DEBUG_H
108 #ifdef DEBUG_RUNTIME
109 #ifdef DEBUG_DEFINE_VARIABLES
110 static char *debug_msg_name[] = {
111 ++EOF++
113 cat temp.$$ |
115 while read x
117 echo " \"$x\"," >> $DEBUG_H
118 done
121 cat <<++EOF++ >>$DEBUG_H
124 #endif
125 #endif
126 ++EOF++
128 # Build stddebug.h
130 sed '/^\/\* Do not remove this line or change anything below this line \*\//q'\
131 <$STDDEBUG_H.old >$STDDEBUG_H
133 cat <<++EOF++ >>$STDDEBUG_H
135 #ifdef DEBUG_NONE
136 ++EOF++
138 cat temp.$$ | tr a-z A-Z |
140 while read x
142 echo "#undef DEBUG_$x" >> $STDDEBUG_H
143 done
146 cat <<++EOF++ >>$STDDEBUG_H
147 #endif
149 #ifdef DEBUG_ALL
150 ++EOF++
152 cat temp.$$ | tr a-z A-Z |
154 while read x
156 echo "#define DEBUG_$x" >> $STDDEBUG_H
157 done
159 echo "#endif" >> $STDDEBUG_H
161 rm temp.$$ $DEBUG_H.old $STDDEBUG_H.old