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