s4-dns: dlz_bind9: Fix ipv6 updates
[samba.git] / source3 / script / mksyms.awk
1 #
2 # mksyms.awk
3 #
4 # Extract symbols to export from C-header files.
5 # output in version-script format for linking shared libraries.
6 #
7 # Copyright (C) 2008 Michael Adam <obnox@samba.org>
8 #
9 BEGIN {
10         inheader=0;
11         current_file="";
12         print "#"
13         print "# This file is automatically generated with \"make symbols\". DO NOT EDIT "
14         print "#"
15         print "{"
16         print "\tglobal:"
17 }
18
19 END {
20         print""
21         print "\tlocal: *;"
22         print "};"
23 }
24
25 {
26         if (FILENAME!=current_file) {
27                 print "\t\t# The following definitions come from",FILENAME
28                 current_file=FILENAME
29         }
30         if (inheader) {
31                 if (match($0,"[)][^()]*[;][ \t]*$")) {
32                         inheader = 0;
33                 }
34                 next;
35         }
36 }
37
38 /^static/ || /^[ \t]*typedef/ || !/^[a-zA-Z\_]/ {
39         next;
40 }
41
42 /^extern[ \t]+[^()]+[;][ \t]*$/ {
43         gsub(/[^ \t]+[ \t]+/, "");
44         sub(/[;][ \t]*$/, "");
45         printf "\t\t%s;\n", $0;
46         next;
47 }
48
49 # look for function headers:
50 {
51         gotstart = 0;
52         if ($0 ~ /^[A-Za-z_][A-Za-z0-9_]+/) {
53         gotstart = 1;
54         }
55         if(!gotstart) {
56                 next;
57         }
58 }
59
60 /[_A-Za-z0-9]+[ \t]*[(].*[)][^()]*;[ \t]*$/ {
61         sub(/[(].*$/, "");
62         gsub(/[^ \t]+[ \t]+/, "");
63         gsub(/^[*]+/, "");
64         printf "\t\t%s;\n",$0;
65         next;
66 }
67
68 /[_A-Za-z0-9]+[ \t]*[(]/ {
69         inheader=1;
70         sub(/[(].*$/, "");
71         gsub(/[^ \t]+[ \t]+/, "");
72         gsub(/^[*]/, "");
73         printf "\t\t%s;\n",$0;
74         next;
75 }
76