2 # mkh - pull headers out of C source
4 PATH=/bin:/usr/bin ; export PATH
6 # egrep pattern to pick out marked lines
9 # Sed program to process marked lines into lines for the header file.
10 # The markers have already been removed. Two things are done here: removal
11 # of backslashed newlines, and some fudging of comments. The first is done
12 # because -o needs to have prototypes on one line to strip them down.
13 # Getting comments into the output is tricky; we turn C++-style // comments
14 # into /* */ comments, after altering any existing */'s to avoid trouble.
18 /\/\//s;//\(.*\);/*\1 */;'
23 -o) # old (pre-function-prototype) compiler
24 # add code to comment out argument lists
26 "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);'
29 -b) # funny Berkeley __P macro
31 "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));'
34 -s) # compiler doesn't like `static foo();'
35 # add code to get rid of the `static'
37 "'/^static[ ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;'
40 -p) # private declarations
44 -i) # wrap in #ifndef, argument is name
53 if test " $ifndef" != " "
55 echo "#ifndef $ifndef"
56 echo "#define $ifndef /* never again */"
58 echo "/* ========= begin header generated by $0 ========= */"
59 echo '#ifdef __cplusplus'
65 echo "/* === $f === */"
66 egrep "$egrep" $f | sed 's/^ ==*[ ]//;s/^ ==*$//' | sed "$peel"
69 echo '#ifdef __cplusplus'
72 echo "/* ========= end header generated by $0 ========= */"
73 if test " $ifndef" != " "