1#!/bin/sh 2# 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, 15# software distributed under the License is distributed on an 16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17# KIND, either express or implied. See the License for the 18# specific language governing permissions and limitations 19# under the License. 20# 21# 22# 23# Attempt to figure out the minimum set of includes for our header files. 24# 25# ### this is incomplete. it merely lists the header files in order from 26# ### "no dependencies on other svn headers" to the larger header files 27# ### which have dependencies. manually working through the headers in 28# ### this order will minimize includes. 29# 30# Each header file is test-compiled to ensure that it has enough headers. 31# Of course, this could be false-positive because another header that 32# has been included has further included something to enable compilation 33# of the header in question. More sophisticated testing (e.g. filtering 34# includes out of the included header) would be necessary for detection. 35# 36 37files="*.h private/*.h" 38deps="deps.$$" 39 40INCLUDES="-I. -I.. -I/usr/include/apr-1 -I/usr/include/apache2" 41 42rm -f "$deps" 43for f in $files ; do 44 sed -n "s%#include \"\(svn_[a-z0-9_]*\.h\)\".*%$f \1%p" $f | fgrep -v svn_private_config.h >> "$deps" 45done 46 47 48function process_file () 49{ 50 echo "Processing $header" 51 52 echo "#include \"$header\"" > "$deps".c 53 gcc -o /dev/null -S $INCLUDES "$deps".c 54 55 ### monkey the includes and recompile to find the minimal set 56} 57 58while test -s "$deps" ; do 59#wc -l $deps 60 61 for header in $files ; do 62 63 if grep -q "^$header" "$deps" ; then 64 continue 65 fi 66 67 process_file 68 69 fgrep -v "$header" "$deps" > "$deps".new 70 mv "$deps".new "$deps" 71 72 files="`echo $files | sed s%$header%%`" 73 break 74 done 75 76done 77 78for header in $files ; do 79 process_file 80done 81