1 # Make prototypes from .c files
2 # $Id: make-proto.pl,v 1.11 1999/04/15 12:37:54 joda Exp $
11 do Getopts('o:p:d') || die "foo";
18 print $brace, " ", $_ if($debug);
22 if($if_0 && /^\#endif/) {
42 if(!/^static/ && !/^PRIVATE/){
43 if(/(.*)(__attribute__\s?\(.*\))/) {
53 while(s/\(([^()]*),(.*)\)/($1\$$2)/g){}
58 /([a-zA-Z0-9_]+)\s*@/;
60 # only add newline if more than one parameter
61 $LP = "(("; # XXX workaround for indentation bug in emacs
70 # insert newline before function name
71 s/(.*)\s([a-zA-Z0-9_]+ __P)/$1\n$2/;
89 $line = $line . " " . $_;
102 open(OUT, ">$opt_o");
103 $block = &foo($opt_o);
105 $block = "__public_h__";
109 open(PRIV, ">$opt_p");
110 $private = &foo($opt_p);
112 $private = "__private_h__";
118 $public_h_header = "/* This is a generated file */
135 $private_h_header = "/* This is a generated file */
152 foreach(sort keys %funcs){
153 if(/^(main)$/) { next }
155 $private_h .= $funcs{$_} . "\n\n";
156 if($funcs{$_} =~ /__attribute__/) {
157 $private_attribute_seen = 1;
160 $public_h .= $funcs{$_} . "\n\n";
161 if($funcs{$_} =~ /__attribute__/) {
162 $public_attribute_seen = 1;
167 if ($public_attribute_seen) {
168 $public_h_header .= "#if !defined(__GNUC__) && !defined(__attribute__)
169 #define __attribute__(x)
175 if ($private_attribute_seen) {
176 $private_h_header .= "#if !defined(__GNUC__) && !defined(__attribute__)
177 #define __attribute__(x)
184 if ($public_h ne "") {
185 $public_h = $public_h_header . $public_h . "#endif /* $block */\n";
187 if ($private_h ne "") {
188 $private_h = $private_h_header . $private_h . "#endif /* $private */\n";
195 print PRIV $private_h;