]> git.saurik.com Git - wxWidgets.git/blob - src/regex/mkh
Fix for [ 877037 ] It is no longer possible to build using wxWindows.dsw
[wxWidgets.git] / src / regex / mkh
1 #! /bin/sh
2 # mkh - pull headers out of C source
3 PATH=/bin:/usr/bin ; export PATH
4
5 # egrep pattern to pick out marked lines
6 egrep='^ =([ ]|$)'
7
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.
14 peel=' /\\$/N
15 /\\\n[ ]*/s///g
16 /\/\//s;\*/;* /;g
17 /\/\//s;//\(.*\);/*\1 */;'
18
19 for a
20 do
21 case "$a" in
22 -o) # old (pre-function-prototype) compiler
23 # add code to comment out argument lists
24 peel="$peel
25 "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1(/*\2*/);'
26 shift
27 ;;
28 -b) # funny Berkeley __P macro
29 peel="$peel
30 "'/^\([^#\/][^\/]*[a-zA-Z0-9_)]\)(\(.*\))/s;;\1 __P((\2));'
31 shift
32 ;;
33 -s) # compiler doesn't like `static foo();'
34 # add code to get rid of the `static'
35 peel="$peel
36 "'/^static[ ][^\/]*[a-zA-Z0-9_)](.*)/s;static.;;'
37 shift
38 ;;
39 -p) # private declarations
40 egrep='^ ==([ ]|$)'
41 shift
42 ;;
43 -i) # wrap in #ifndef, argument is name
44 ifndef="$2"
45 shift ; shift
46 ;;
47 *) break
48 ;;
49 esac
50 done
51
52 if test " $ifndef" != " "
53 then
54 echo "#ifndef $ifndef"
55 echo "#define $ifndef /* never again */"
56 fi
57 echo "/* ========= begin header generated by $0 ========= */"
58 echo '#ifdef __cplusplus'
59 echo 'extern "C" {'
60 echo '#endif'
61 for f
62 do
63 echo
64 echo "/* === $f === */"
65 egrep "$egrep" $f | sed 's/^ ==*[ ]//;s/^ ==*$//' | sed "$peel"
66 echo
67 done
68 echo '#ifdef __cplusplus'
69 echo '}'
70 echo '#endif'
71 echo "/* ========= end header generated by $0 ========= */"
72 if test " $ifndef" != " "
73 then
74 echo "#endif"
75 fi
76 exit 0