bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / build / make_exports.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 BEGIN {
17     printf("/*\n")
18     printf(" * THIS FILE WAS AUTOGENERATED BY make_exports.awk\n")
19     printf(" *\n")
20     printf(" * This is an ugly hack that needs to be here, so\n")
21     printf(" * that libtool will link all of the APR functions\n")
22     printf(" * into server regardless of whether the base server\n")
23     printf(" * uses them.\n")
24     printf(" */\n")
25     printf("\n")
26     printf("#define CORE_PRIVATE\n")
27     printf("\n")
28     
29     for (i = 1; i < ARGC; i++) {
30         file = ARGV[i]
31         sub("([^/]*[/])*", "", file)
32         printf("#include \"%s\"\n", file)
33     }
34
35     printf("\n")
36     printf("const void *ap_ugly_hack = NULL;\n")
37     printf("\n")
38     
39     TYPE_NORMAL = 0
40     TYPE_HEADER = 1
41
42     stackptr = 0
43 }
44
45 function push(line) {
46     stack[stackptr] = line
47     stackptr++
48 }
49
50 function do_output() {
51     printf("/*\n")
52     printf(" * %s\n", FILENAME)
53     printf(" */\n")
54     
55     for (i = 0; i < stackptr; i++) {
56         printf("%s\n", stack[i])
57     }
58     
59     stackptr = 0
60
61     printf("\n");
62 }
63
64 function enter_scope(type) {
65     scope++
66     scope_type[scope] = type
67     scope_stack[scope] = stackptr
68     delete scope_used[scope]
69 }
70
71 function leave_scope() {
72     used = scope_used[scope]
73    
74     if (!used)
75         stackptr = scope_stack[scope]
76
77     scope--
78     if (used) {
79         scope_used[scope] = 1
80         
81         if (!scope)
82             do_output()
83     }
84 }
85
86 function add_symbol(symbol) {
87     if (!index(symbol, "#")) {
88         push("const void *ap_hack_" symbol " = (const void *)" symbol ";")
89         scope_used[scope] = 1
90     }
91 }
92
93 /^[ \t]*AP[RU]?_(CORE_)?DECLARE[^(]*[(][^)]*[)]([^ ]* )*[^(]+[(]/ {
94     sub("[ \t]*AP[RU]?_(CORE_)?DECLARE[^(]*[(][^)]*[)][ \t]*", "")
95     sub("[(].*", "")
96     sub("([^ ]* (^([ \t]*[(])))+", "")
97
98     add_symbol($0)
99     next
100 }
101
102 /^[ \t]*AP_DECLARE_HOOK[^(]*[(][^)]*/ {
103     split($0, args, ",")
104     symbol = args[2]
105     sub("^[ \t]+", "", symbol)
106     sub("[ \t]+$", "", symbol)
107
108     add_symbol("ap_hook_" symbol)
109     add_symbol("ap_hook_get_" symbol)
110     add_symbol("ap_run_" symbol)
111     next
112 }
113
114 /^[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(][^)]*[)]/ {
115     sub("[ \t]*APR_POOL_DECLARE_ACCESSOR[^(]*[(]", "", $0)
116     sub("[)].*$", "", $0)
117     add_symbol("apr_" $0 "_pool_get")
118     next
119 }
120
121 /^[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(][^)]*[)]/ {
122     sub("[ \t]*APR_DECLARE_INHERIT_SET[^(]*[(]", "", $0)
123     sub("[)].*$", "", $0)
124     add_symbol("apr_" $0 "_inherit_set")
125     next
126 }
127
128 /^[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(][^)]*[)]/ {
129     sub("[ \t]*APR_DECLARE_INHERIT_UNSET[^(]*[(]", "", $0)
130     sub("[)].*$", "", $0)
131     add_symbol("apr_" $0 "_inherit_unset")
132     next
133 }
134
135 /^#[ \t]*if(ndef| !defined[(])([^_]*_)*H/ {
136     enter_scope(TYPE_HEADER)
137     next
138 }
139
140 /^#[ \t]*if([n]?def)? / {
141     enter_scope(TYPE_NORMAL)
142     push($0)
143     next
144 }
145
146 /^#[ \t]*endif/ {
147     if (scope_type[scope] == TYPE_NORMAL)
148         push($0)
149         
150     leave_scope()
151     next
152 }
153
154 /^#[ \t]*else/ {
155     push($0)
156     next
157 }
158
159 /^#[ \t]*elif/ {
160     push($0)
161     next
162 }
163
164