db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding# Licensed to the Apache Software Foundation (ASF) under one or more
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding# contributor license agreements. See the NOTICE file distributed with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding# this work for additional information regarding copyright ownership.
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding# The ASF licenses this file to You under the Apache License, Version 2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding# (the "License"); you may not use this file except in compliance with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding# the License. You may obtain a copy of the License at
240b85022b73af58a6d971cd3d05d54037d8f682nd#
240b85022b73af58a6d971cd3d05d54037d8f682nd# http://www.apache.org/licenses/LICENSE-2.0
240b85022b73af58a6d971cd3d05d54037d8f682nd#
240b85022b73af58a6d971cd3d05d54037d8f682nd# Unless required by applicable law or agreed to in writing, software
240b85022b73af58a6d971cd3d05d54037d8f682nd# distributed under the License is distributed on an "AS IS" BASIS,
240b85022b73af58a6d971cd3d05d54037d8f682nd# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
240b85022b73af58a6d971cd3d05d54037d8f682nd# See the License for the specific language governing permissions and
240b85022b73af58a6d971cd3d05d54037d8f682nd# limitations under the License.
240b85022b73af58a6d971cd3d05d54037d8f682nd#
240b85022b73af58a6d971cd3d05d54037d8f682nd#
d138865b16449a01229bbc0f093dbd985e4530caorlikowski# Based on apr's make_export.awk, which is
d138865b16449a01229bbc0f093dbd985e4530caorlikowski# based on Ryan Bloom's make_export.pl
d138865b16449a01229bbc0f093dbd985e4530caorlikowski
d138865b16449a01229bbc0f093dbd985e4530caorlikowski/^#[ \t]*if(def)? (AP[RU]?_|!?defined).*/ {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski if (old_filename != FILENAME) {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski if (old_filename != "") printf("%s", line)
d138865b16449a01229bbc0f093dbd985e4530caorlikowski macro_no = 0
d138865b16449a01229bbc0f093dbd985e4530caorlikowski found = 0
d138865b16449a01229bbc0f093dbd985e4530caorlikowski count = 0
d138865b16449a01229bbc0f093dbd985e4530caorlikowski old_filename = FILENAME
d138865b16449a01229bbc0f093dbd985e4530caorlikowski line = ""
d138865b16449a01229bbc0f093dbd985e4530caorlikowski }
d138865b16449a01229bbc0f093dbd985e4530caorlikowski macro_stack[macro_no++] = macro
d138865b16449a01229bbc0f093dbd985e4530caorlikowski macro = substr($0, length($1)+2)
d138865b16449a01229bbc0f093dbd985e4530caorlikowski count++
d138865b16449a01229bbc0f093dbd985e4530caorlikowski line = line "#ifdef " macro "\n"
d138865b16449a01229bbc0f093dbd985e4530caorlikowski next
d138865b16449a01229bbc0f093dbd985e4530caorlikowski}
d138865b16449a01229bbc0f093dbd985e4530caorlikowski
d138865b16449a01229bbc0f093dbd985e4530caorlikowski/^#[ \t]*endif/ {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski if (count > 0) {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski count--
7c4d457e68a1237b3110c992dc2f179e69cd663forlikowski line = line "#endif /* " macro " */\n"
d138865b16449a01229bbc0f093dbd985e4530caorlikowski macro = macro_stack[--macro_no]
d138865b16449a01229bbc0f093dbd985e4530caorlikowski }
d138865b16449a01229bbc0f093dbd985e4530caorlikowski if (count == 0) {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski if (found != 0) {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski printf("%s", line)
d138865b16449a01229bbc0f093dbd985e4530caorlikowski }
d138865b16449a01229bbc0f093dbd985e4530caorlikowski line = ""
d138865b16449a01229bbc0f093dbd985e4530caorlikowski }
d138865b16449a01229bbc0f093dbd985e4530caorlikowski next
d138865b16449a01229bbc0f093dbd985e4530caorlikowski}
d138865b16449a01229bbc0f093dbd985e4530caorlikowski
d138865b16449a01229bbc0f093dbd985e4530caorlikowskifunction add_symbol (sym_name) {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski if (count) {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski found++
d138865b16449a01229bbc0f093dbd985e4530caorlikowski }
d138865b16449a01229bbc0f093dbd985e4530caorlikowski for (i = 0; i < count; i++) {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski line = line "\t"
d138865b16449a01229bbc0f093dbd985e4530caorlikowski }
d138865b16449a01229bbc0f093dbd985e4530caorlikowski line = line sym_name "\n"
d138865b16449a01229bbc0f093dbd985e4530caorlikowski
d138865b16449a01229bbc0f093dbd985e4530caorlikowski if (count == 0) {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski printf("%s", line)
d138865b16449a01229bbc0f093dbd985e4530caorlikowski line = ""
d138865b16449a01229bbc0f093dbd985e4530caorlikowski }
d138865b16449a01229bbc0f093dbd985e4530caorlikowski}
d138865b16449a01229bbc0f093dbd985e4530caorlikowski
6b6057d317191d6e246b6f34b2adfc829711f1b0bjh/^[ \t]*(extern[ \t]+)?AP[RU]?_DECLARE_DATA .*;$/ {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski varname = $NF;
d138865b16449a01229bbc0f093dbd985e4530caorlikowski gsub( /[*;]/, "", varname);
d138865b16449a01229bbc0f093dbd985e4530caorlikowski gsub( /\[.*\]/, "", varname);
d138865b16449a01229bbc0f093dbd985e4530caorlikowski add_symbol(varname);
d138865b16449a01229bbc0f093dbd985e4530caorlikowski}
d138865b16449a01229bbc0f093dbd985e4530caorlikowski
d138865b16449a01229bbc0f093dbd985e4530caorlikowskiEND {
d138865b16449a01229bbc0f093dbd985e4530caorlikowski printf("%s", line)
d138865b16449a01229bbc0f093dbd985e4530caorlikowski}