2 # mkh - pull headers out of C source
3 PATH=/bin:/usr/bin ; export PATH
5 # egrep pattern to pick out marked lines
8 # Sed program to process marked lines into lines for the header file.
9 # The markers have already been removed. Two things are done here: removal
10 # of backslashed newlines, and some fudging of comments. The first is done
11 # because -o needs to have prototypes on one line to strip them down.
12 # Getting comments into the output is tricky; we turn C++-style // comments
13 # into /* */ comments, after altering any existing */'s to avoid trouble.
17 /\/\//s;//\(.*\);/*\1 */;'
22 -o) # old (pre-function-prototype) compiler
23 # add code to comment out argument lists
25 "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);'
28 -A) # funny Amanda P macro
30 "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 P((\2));'
33 -b) # funny Berkeley __P macro
35 "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));'
38 -s) # compiler doesn't like `static foo();'
39 # add code to get rid of the `static'
41 "'/^static[ ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;'
44 -p) # private declarations
48 -i) # wrap in #ifndef, argument is name
57 if test " $ifndef" != " "
59 echo "#ifndef $ifndef"
60 echo "#define $ifndef /* never again */"
62 echo "/* ========= begin header generated by $0 ========= */"
63 echo '#ifdef __cplusplus'
69 echo "/* === $f === */"
70 egrep "$egrep" $f | sed 's/^ ==*[ ]//;s/^ ==*$//' | sed "$peel"
73 echo '#ifdef __cplusplus'
76 echo "/* ========= end header generated by $0 ========= */"
77 if test " $ifndef" != " "