Release 960805
[wine/multimedia.git] / tools / make_debug
blobf7865a57393b5f688932db6f37ad67b914c8c58b
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]) ; else fprintf
93 #define debugging_$x debug_msg_enabled[$i]
94 #else
95 #ifdef DEBUG_$y
96 #define dprintf_$x fprintf
97 #define debugging_$x 1
98 #else
99 #define dprintf_$x while(0) fprintf
100 #define debugging_$x 0
101 #endif
102 #endif
104 ++EOF++
105 let i=$i+1
106 done
109 cat <<++EOF++ >>$DEBUG_H
111 #ifdef DEBUG_RUNTIME
112 #ifdef DEBUG_DEFINE_VARIABLES
113 static char *debug_msg_name[] = {
114 ++EOF++
116 cat temp.$$ |
118 while read x
120 echo " \"$x\"," >> $DEBUG_H
121 done
124 cat <<++EOF++ >>$DEBUG_H
127 #endif
128 #endif
129 ++EOF++
131 # Build stddebug.h
133 sed '/^\/\* Do not remove this line or change anything below this line \*\//q'\
134 <$STDDEBUG_H.old >$STDDEBUG_H
136 cat <<++EOF++ >>$STDDEBUG_H
138 #ifdef DEBUG_NONE
139 ++EOF++
141 cat temp.$$ | tr a-z A-Z |
143 while read x
145 echo "#undef DEBUG_$x" >> $STDDEBUG_H
146 done
149 cat <<++EOF++ >>$STDDEBUG_H
150 #endif
152 #ifdef DEBUG_ALL
153 ++EOF++
155 cat temp.$$ | tr a-z A-Z |
157 while read x
159 echo "#define DEBUG_$x" >> $STDDEBUG_H
160 done
162 echo "#endif" >> $STDDEBUG_H
164 rm temp.$$ $DEBUG_H.old $STDDEBUG_H.old