]> granicus.if.org Git - apache/blob - build/make_nw_export.awk
Follow up to r1789213: more accurate CHANGES entry.
[apache] / build / make_nw_export.awk
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements.  See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License.  You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # Based on apr's make_export.awk, which is
17 # based on Ryan Bloom's make_export.pl
18 #
19
20 BEGIN {
21 }
22
23 function add_symbol(sym_name) {
24     sub(" ", "", sym_name)
25     exports[++idx] = sym_name
26 }
27
28 # List of functions that we don't support, yet??
29 #/ap_some_name/{next}
30 /ap_mpm_pod_/{next}
31
32 /^[ \t]*(AP|DAV|CACHE)([RU]|_CORE)?_DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ {
33     sub("[ \t]*(AP|DAV|CACHE)([RU]|_CORE)?_DECLARE[^(]*[(][^)]*[)][ \t]*", "")
34     sub("[(].*", "")
35     sub("([^ ]* (^([ \t]*[(])))+", "")
36     add_symbol($0)
37     next
38 }
39
40 /^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ {
41     split($0, args, ",")
42     symbol = args[2]
43     sub("^[ \t]+", "", symbol)
44     sub("[ \t]+$", "", symbol)
45     add_symbol("ap_hook_" symbol)
46     add_symbol("ap_hook_get_" symbol)
47     add_symbol("ap_run_" symbol)
48     next
49 }
50
51 /^[ \t]*AP[RU]?_DECLARE_EXTERNAL_HOOK[^(]*[(][^)]*/ {
52     split($0, args, ",")
53     prefix = args[1]
54     sub("^.*[(]", "", prefix)
55     symbol = args[4]
56     sub("^[ \t]+", "", symbol)
57     sub("[ \t]+$", "", symbol)
58     add_symbol(prefix "_hook_" symbol)
59     add_symbol(prefix "_hook_get_" symbol)
60     add_symbol(prefix "_run_" symbol)
61     next
62 }
63
64 /^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ {
65     sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0)
66     sub("[)].*$", "", $0)
67     add_symbol("apr_" $0 "_pool_get")
68     next
69 }
70
71 /^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ {
72     sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0)
73     sub("[)].*$", "", $0)
74     add_symbol("apr_" $0 "_inherit_set")
75     next
76 }
77
78 /^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ {
79     sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0)
80     sub("[)].*$", "", $0)
81     add_symbol("apr_" $0 "_inherit_unset")
82     next
83 }
84
85 /^[ \t]*(extern[ \t]+)?AP[RU]?_DECLARE_DATA .*;/ {
86     gsub(/[*;\n\r]/, "")
87     gsub(/\[.*\]/, "")
88     add_symbol($NF)
89 }
90
91
92 END {
93     printf("Added %d symbols to export list.\n", idx) > "/dev/stderr"
94     # sort symbols with shell sort
95     increment = int(idx / 2)
96     while (increment > 0) {
97         for (i = increment+1; i <= idx; i++) {
98             j = i
99             temp = exports[i]
100             while ((j >= increment+1) && (exports[j-increment] > temp)) {
101                 exports[j] = exports[j-increment]
102                 j -= increment
103             }
104             exports[j] = temp
105         }
106         if (increment == 2)
107             increment = 1
108         else
109             increment = int(increment*5/11)
110     }
111     # print the array
112     printf(" (%s)\n", EXPPREFIX)
113     while (x < idx - 1) {
114         printf(" %s,\n", exports[++x])
115     }
116     printf(" %s\n", exports[++x])
117 }
118