1*404b540aSrobert#!/bin/sh 2*404b540aSrobert# 3*404b540aSrobert# Install modified versions of certain ANSI-incompatible system header 4*404b540aSrobert# files which are fixed to work correctly with ANSI C and placed in a 5*404b540aSrobert# directory that GCC will search. 6*404b540aSrobert# 7*404b540aSrobert# See README-fixinc for more information. 8*404b540aSrobert# 9*404b540aSrobert# fixincludes copyright (c) 1998, 1999, 2000, 2002 10*404b540aSrobert# The Free Software Foundation, Inc. 11*404b540aSrobert# 12*404b540aSrobert# fixincludes is free software. 13*404b540aSrobert# 14*404b540aSrobert# You may redistribute it and/or modify it under the terms of the 15*404b540aSrobert# GNU General Public License, as published by the Free Software 16*404b540aSrobert# Foundation; either version 2, or (at your option) any later version. 17*404b540aSrobert# 18*404b540aSrobert# fixincludes is distributed in the hope that it will be useful, 19*404b540aSrobert# but WITHOUT ANY WARRANTY; without even the implied warranty of 20*404b540aSrobert# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21*404b540aSrobert# See the GNU General Public License for more details. 22*404b540aSrobert# 23*404b540aSrobert# You should have received a copy of the GNU General Public License 24*404b540aSrobert# along with fixincludes. See the file "COPYING". If not, 25*404b540aSrobert# write to: The Free Software Foundation, Inc., 26*404b540aSrobert# 51 Franklin Street, Fifth Floor, 27*404b540aSrobert# Boston, MA 02110-1301, USA. 28*404b540aSrobert# 29*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 30*404b540aSrobert 31*404b540aSrobert# Usage: fixinc.sh output-dir input-dir 32*404b540aSrobert# 33*404b540aSrobert# Directory in which to store the results. 34*404b540aSrobert# Fail if no arg to specify a directory for the output. 35*404b540aSrobertif [ "x$1" = "x" ] 36*404b540aSrobertthen 37*404b540aSrobert echo fixincludes: no output directory specified 38*404b540aSrobert exit 1 39*404b540aSrobertfi 40*404b540aSrobert 41*404b540aSrobertLIB=${1} 42*404b540aSrobertshift 43*404b540aSrobert 44*404b540aSrobert# Make sure it exists. 45*404b540aSrobertif [ ! -d $LIB ]; then 46*404b540aSrobert mkdir $LIB || { 47*404b540aSrobert echo fixincludes: output dir '`'$LIB"' cannot be created" 48*404b540aSrobert exit 1 49*404b540aSrobert } 50*404b540aSrobertelse 51*404b540aSrobert ( cd $LIB && touch DONE && rm DONE ) || { 52*404b540aSrobert echo fixincludes: output dir '`'$LIB"' is an invalid directory" 53*404b540aSrobert exit 1 54*404b540aSrobert } 55*404b540aSrobertfi 56*404b540aSrobert 57*404b540aSrobertif test -z "$VERBOSE" 58*404b540aSrobertthen 59*404b540aSrobert VERBOSE=2 60*404b540aSrobert export VERBOSE 61*404b540aSrobertelse 62*404b540aSrobert case "$VERBOSE" in 63*404b540aSrobert [0-9] ) : ;; 64*404b540aSrobert * ) VERBOSE=3 ;; 65*404b540aSrobert esac 66*404b540aSrobertfi 67*404b540aSrobert 68*404b540aSrobert# Define what target system we're fixing. 69*404b540aSrobert# 70*404b540aSrobertif test -r ./Makefile; then 71*404b540aSrobert target_canonical="`sed -n -e 's,^target[ ]*=[ ]*\(.*\)$,\1,p' < Makefile`" 72*404b540aSrobertfi 73*404b540aSrobert 74*404b540aSrobert# If not from the Makefile, then try config.guess 75*404b540aSrobert# 76*404b540aSrobertif test -z "${target_canonical}" ; then 77*404b540aSrobert if test -x ./config.guess ; then 78*404b540aSrobert target_canonical="`config.guess`" ; fi 79*404b540aSrobert test -z "${target_canonical}" && target_canonical=unknown 80*404b540aSrobertfi 81*404b540aSrobertexport target_canonical 82*404b540aSrobert 83*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 84*404b540aSrobert# 85*404b540aSrobert# Define PWDCMD as a command to use to get the working dir 86*404b540aSrobert# in the form that we want. 87*404b540aSrobertPWDCMD=${PWDCMD-pwd} 88*404b540aSrobert 89*404b540aSrobertcase "`$PWDCMD`" in 90*404b540aSrobert//*) 91*404b540aSrobert # On an Apollo, discard everything before `/usr'. 92*404b540aSrobert PWDCMD="eval pwd | sed -e 's,.*/usr/,/usr/,'" 93*404b540aSrobert ;; 94*404b540aSrobertesac 95*404b540aSrobert 96*404b540aSrobert# Original directory. 97*404b540aSrobertORIGDIR=`${PWDCMD}` 98*404b540aSrobertexport ORIGDIR 99*404b540aSrobertFIXINCL=`${PWDCMD}`/fixincl 100*404b540aSrobertif [ ! -x $FIXINCL ] ; then 101*404b540aSrobert echo "Cannot find fixincl" >&2 102*404b540aSrobert exit 1 103*404b540aSrobertfi 104*404b540aSrobertexport FIXINCL 105*404b540aSrobert 106*404b540aSrobert# Make LIB absolute only if needed to avoid problems with the amd. 107*404b540aSrobertcase $LIB in 108*404b540aSrobert/*) 109*404b540aSrobert ;; 110*404b540aSrobert*) 111*404b540aSrobert cd $LIB; LIB=`${PWDCMD}` 112*404b540aSrobert ;; 113*404b540aSrobertesac 114*404b540aSrobert 115*404b540aSrobertif test $VERBOSE -gt 0 116*404b540aSrobertthen echo Fixing headers into ${LIB} for ${target_canonical} target ; fi 117*404b540aSrobert 118*404b540aSrobert# Determine whether this system has symbolic links. 119*404b540aSrobertif test -n "$DJDIR"; then 120*404b540aSrobert LINKS=false 121*404b540aSrobertelif ln -s X $LIB/ShouldNotExist 2>/dev/null; then 122*404b540aSrobert rm -f $LIB/ShouldNotExist 123*404b540aSrobert LINKS=true 124*404b540aSrobertelif ln -s X /tmp/ShouldNotExist 2>/dev/null; then 125*404b540aSrobert rm -f /tmp/ShouldNotExist 126*404b540aSrobert LINKS=true 127*404b540aSrobertelse 128*404b540aSrobert LINKS=false 129*404b540aSrobertfi 130*404b540aSrobert 131*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 132*404b540aSrobert# 133*404b540aSrobert# In the file macro_list are listed all the predefined 134*404b540aSrobert# macros that are not in the C89 reserved namespace (the reserved 135*404b540aSrobert# namespace is all identifiers beginnning with two underscores or one 136*404b540aSrobert# underscore followed by a capital letter). A regular expression to find 137*404b540aSrobert# any of those macros in a header file is written to MN_NAME_PAT. 138*404b540aSrobert# 139*404b540aSrobert# Note dependency on ASCII. \012 = newline. 140*404b540aSrobert# tr ' ' '\n' is, alas, not portable. 141*404b540aSrobert 142*404b540aSrobertif test -s ${MACRO_LIST} 143*404b540aSrobertthen 144*404b540aSrobert if test $VERBOSE -gt 0; then 145*404b540aSrobert echo "Forbidden identifiers: `tr '\012' ' ' < ${MACRO_LIST}`" 146*404b540aSrobert fi 147*404b540aSrobert MN_NAME_PAT="`sed 's/^/\\\\</; s/$/\\\\>/; $!s/$/|/' \ 148*404b540aSrobert < ${MACRO_LIST} | tr -d '\012'`" 149*404b540aSrobert export MN_NAME_PAT 150*404b540aSrobertelse 151*404b540aSrobert if test $VERBOSE -gt 0 152*404b540aSrobert then echo "No forbidden identifiers defined by this target" ; fi 153*404b540aSrobertfi 154*404b540aSrobert 155*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 156*404b540aSrobert# 157*404b540aSrobert# Search each input directory for broken header files. 158*404b540aSrobert# This loop ends near the end of the file. 159*404b540aSrobert# 160*404b540aSrobertif test $# -eq 0 161*404b540aSrobertthen 162*404b540aSrobert INPUTLIST="/usr/include" 163*404b540aSrobertelse 164*404b540aSrobert INPUTLIST="$@" 165*404b540aSrobertfi 166*404b540aSrobert 167*404b540aSrobertfor INPUT in ${INPUTLIST} ; do 168*404b540aSrobert 169*404b540aSrobertcd ${ORIGDIR} 170*404b540aSrobert 171*404b540aSrobert# Make sure a directory exists before changing into it, 172*404b540aSrobert# otherwise Solaris2 will fail-exit the script. 173*404b540aSrobert# 174*404b540aSrobertif [ ! -d ${INPUT} ]; then 175*404b540aSrobert continue 176*404b540aSrobertfi 177*404b540aSrobertcd ${INPUT} 178*404b540aSrobert 179*404b540aSrobertINPUT=`${PWDCMD}` 180*404b540aSrobertexport INPUT 181*404b540aSrobert 182*404b540aSrobert# 183*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 184*404b540aSrobert# 185*404b540aSrobertif test $VERBOSE -gt 1 186*404b540aSrobertthen echo Finding directories and links to directories ; fi 187*404b540aSrobert 188*404b540aSrobert# Find all directories and all symlinks that point to directories. 189*404b540aSrobert# Put the list in $all_dirs. 190*404b540aSrobert# Each time we find a symlink, add it to newdirs 191*404b540aSrobert# so that we do another find within the dir the link points to. 192*404b540aSrobert# Note that $all_dirs may have duplicates in it; 193*404b540aSrobert# later parts of this file are supposed to ignore them. 194*404b540aSrobertdirs="." 195*404b540aSrobertlevels=2 196*404b540aSrobertall_dirs="" 197*404b540aSrobertsearch_dirs="" 198*404b540aSrobert 199*404b540aSrobertwhile [ -n "$dirs" ] && [ $levels -gt 0 ] 200*404b540aSrobertdo 201*404b540aSrobert levels=`expr $levels - 1` 202*404b540aSrobert newdirs= 203*404b540aSrobert for d in $dirs 204*404b540aSrobert do 205*404b540aSrobert if test $VERBOSE -gt 1 206*404b540aSrobert then echo " Searching $INPUT/$d" ; fi 207*404b540aSrobert 208*404b540aSrobert # Find all directories under $d, relative to $d, excluding $d itself. 209*404b540aSrobert # (The /. is needed after $d in case $d is a symlink.) 210*404b540aSrobert all_dirs="$all_dirs `find $d/. -type d -print | \ 211*404b540aSrobert sed -e '/\/\.$/d' -e 's@/./@/@g'`" 212*404b540aSrobert # Find all links to directories. 213*404b540aSrobert # Using `-exec test -d' in find fails on some systems, 214*404b540aSrobert # and trying to run test via sh fails on others, 215*404b540aSrobert # so this is the simplest alternative left. 216*404b540aSrobert # First find all the links, then test each one. 217*404b540aSrobert theselinks= 218*404b540aSrobert $LINKS && \ 219*404b540aSrobert theselinks=`find $d/. -type l -print | sed -e 's@/./@/@g'` 220*404b540aSrobert for d1 in $theselinks --dummy-- 221*404b540aSrobert do 222*404b540aSrobert # If the link points to a directory, 223*404b540aSrobert # add that dir to $newdirs 224*404b540aSrobert if [ -d $d1 ] 225*404b540aSrobert then 226*404b540aSrobert all_dirs="$all_dirs $d1" 227*404b540aSrobert if [ "`ls -ld $d1 | sed -n 's/.*-> //p'`" != "." ] 228*404b540aSrobert then 229*404b540aSrobert newdirs="$newdirs $d1" 230*404b540aSrobert search_dirs="$search_dirs $d1" 231*404b540aSrobert fi 232*404b540aSrobert fi 233*404b540aSrobert done 234*404b540aSrobert done 235*404b540aSrobert 236*404b540aSrobert dirs="$newdirs" 237*404b540aSrobertdone 238*404b540aSrobert 239*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 240*404b540aSrobert# 241*404b540aSrobertdirs= 242*404b540aSrobertif test $VERBOSE -gt 2 243*404b540aSrobertthen echo "All directories (including links to directories):" 244*404b540aSrobert echo $all_dirs 245*404b540aSrobertfi 246*404b540aSrobert 247*404b540aSrobertfor file in $all_dirs; do 248*404b540aSrobert rm -rf $LIB/$file 249*404b540aSrobert if [ ! -d $LIB/$file ] 250*404b540aSrobert then mkdir $LIB/$file 251*404b540aSrobert fi 252*404b540aSrobertdone 253*404b540aSrobertmkdir $LIB/root 254*404b540aSrobert 255*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 256*404b540aSrobert# 257*404b540aSrobert# treetops gets an alternating list 258*404b540aSrobert# of old directories to copy 259*404b540aSrobert# and the new directories to copy to. 260*404b540aSroberttreetops=". ${LIB}" 261*404b540aSrobert 262*404b540aSrobertif $LINKS; then 263*404b540aSrobert if test $VERBOSE -gt 1 264*404b540aSrobert then echo 'Making symbolic directory links' ; fi 265*404b540aSrobert cwd=`${PWDCMD}` 266*404b540aSrobert 267*404b540aSrobert for sym_link in $search_dirs; do 268*404b540aSrobert cd ${INPUT} 269*404b540aSrobert dest=`ls -ld ${sym_link} | sed -n 's/.*-> //p'` 270*404b540aSrobert 271*404b540aSrobert # In case $dest is relative, get to ${sym_link}'s dir first. 272*404b540aSrobert # 273*404b540aSrobert cd ./`echo ${sym_link} | sed 's;/[^/]*$;;'` 274*404b540aSrobert 275*404b540aSrobert # Check that the target directory exists. 276*404b540aSrobert # Redirections changed to avoid bug in sh on Ultrix. 277*404b540aSrobert # 278*404b540aSrobert (cd $dest) > /dev/null 2>&1 279*404b540aSrobert if [ $? = 0 ]; then 280*404b540aSrobert cd $dest 281*404b540aSrobert 282*404b540aSrobert # full_dest_dir gets the dir that the link actually leads to. 283*404b540aSrobert # 284*404b540aSrobert full_dest_dir=`${PWDCMD}` 285*404b540aSrobert 286*404b540aSrobert # Canonicalize ${INPUT} now to minimize the time an 287*404b540aSrobert # automounter has to change the result of ${PWDCMD}. 288*404b540aSrobert # 289*404b540aSrobert cinput=`cd ${INPUT}; ${PWDCMD}` 290*404b540aSrobert 291*404b540aSrobert # If a link points to ., make a similar link to . 292*404b540aSrobert # 293*404b540aSrobert if [ ${full_dest_dir} = ${cinput} ]; then 294*404b540aSrobert if test $VERBOSE -gt 2 295*404b540aSrobert then echo ${sym_link} '->' . ': Making self link' ; fi 296*404b540aSrobert rm -fr ${LIB}/${sym_link} > /dev/null 2>&1 297*404b540aSrobert ln -s . ${LIB}/${sym_link} > /dev/null 2>&1 298*404b540aSrobert 299*404b540aSrobert # If link leads back into ${INPUT}, 300*404b540aSrobert # make a similar link here. 301*404b540aSrobert # 302*404b540aSrobert elif expr ${full_dest_dir} : "${cinput}/.*" > /dev/null; then 303*404b540aSrobert # Y gets the actual target dir name, relative to ${INPUT}. 304*404b540aSrobert y=`echo ${full_dest_dir} | sed -n "s&${cinput}/&&p"` 305*404b540aSrobert # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}. 306*404b540aSrobert dots=`echo "${sym_link}" | 307*404b540aSrobert sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` 308*404b540aSrobert if test $VERBOSE -gt 2 309*404b540aSrobert then echo ${sym_link} '->' $dots$y ': Making local link' ; fi 310*404b540aSrobert rm -fr ${LIB}/${sym_link} > /dev/null 2>&1 311*404b540aSrobert ln -s $dots$y ${LIB}/${sym_link} > /dev/null 2>&1 312*404b540aSrobert 313*404b540aSrobert else 314*404b540aSrobert # If the link is to a dir $target outside ${INPUT}, 315*404b540aSrobert # repoint the link at ${INPUT}/root$target 316*404b540aSrobert # and process $target into ${INPUT}/root$target 317*404b540aSrobert # treat this directory as if it actually contained the files. 318*404b540aSrobert # 319*404b540aSrobert if test $VERBOSE -gt 2 320*404b540aSrobert then echo ${sym_link} '->' root${full_dest_dir} ': Making rooted link' 321*404b540aSrobert fi 322*404b540aSrobert if [ -d $LIB/root${full_dest_dir} ] 323*404b540aSrobert then true 324*404b540aSrobert else 325*404b540aSrobert dirname=root${full_dest_dir}/ 326*404b540aSrobert dirmade=. 327*404b540aSrobert cd $LIB 328*404b540aSrobert while [ x$dirname != x ]; do 329*404b540aSrobert component=`echo $dirname | sed -e 's|/.*$||'` 330*404b540aSrobert mkdir $component >/dev/null 2>&1 331*404b540aSrobert cd $component 332*404b540aSrobert dirmade=$dirmade/$component 333*404b540aSrobert dirname=`echo $dirname | sed -e 's|[^/]*/||'` 334*404b540aSrobert done 335*404b540aSrobert fi 336*404b540aSrobert 337*404b540aSrobert # Duplicate directory structure created in ${LIB}/${sym_link} in new 338*404b540aSrobert # root area. 339*404b540aSrobert # 340*404b540aSrobert for file2 in $all_dirs; do 341*404b540aSrobert case $file2 in 342*404b540aSrobert ${sym_link}/*) 343*404b540aSrobert dupdir=${LIB}/root${full_dest_dir}/`echo $file2 | 344*404b540aSrobert sed -n "s|^${sym_link}/||p"` 345*404b540aSrobert if test $VERBOSE -gt 2 346*404b540aSrobert then echo "Duplicating ${sym_link}'s ${dupdir}" ; fi 347*404b540aSrobert if [ -d ${dupdir} ] 348*404b540aSrobert then true 349*404b540aSrobert else 350*404b540aSrobert mkdir ${dupdir} 351*404b540aSrobert fi 352*404b540aSrobert ;; 353*404b540aSrobert *) 354*404b540aSrobert ;; 355*404b540aSrobert esac 356*404b540aSrobert done 357*404b540aSrobert 358*404b540aSrobert # Get the path from ${LIB} to ${sym_link}, accounting for symlinks. 359*404b540aSrobert # 360*404b540aSrobert parent=`echo "${sym_link}" | sed -e 's@/[^/]*$@@'` 361*404b540aSrobert libabs=`cd ${LIB}; ${PWDCMD}` 362*404b540aSrobert file2=`cd ${LIB}; cd $parent; ${PWDCMD} | sed -e "s@^${libabs}@@"` 363*404b540aSrobert 364*404b540aSrobert # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}. 365*404b540aSrobert # 366*404b540aSrobert dots=`echo "$file2" | sed -e 's@/[^/]*@../@g'` 367*404b540aSrobert rm -fr ${LIB}/${sym_link} > /dev/null 2>&1 368*404b540aSrobert ln -s ${dots}root${full_dest_dir} ${LIB}/${sym_link} > /dev/null 2>&1 369*404b540aSrobert treetops="$treetops ${sym_link} ${LIB}/root${full_dest_dir}" 370*404b540aSrobert fi 371*404b540aSrobert fi 372*404b540aSrobert done 373*404b540aSrobertfi 374*404b540aSrobert 375*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 376*404b540aSrobert# 377*404b540aSrobertrequired= 378*404b540aSrobertset x $treetops 379*404b540aSrobertshift 380*404b540aSrobertwhile [ $# != 0 ]; do 381*404b540aSrobert # $1 is an old directory to copy, and $2 is the new directory to copy to. 382*404b540aSrobert # 383*404b540aSrobert SRCDIR=`cd ${INPUT} ; cd $1 ; ${PWDCMD}` 384*404b540aSrobert export SRCDIR 385*404b540aSrobert 386*404b540aSrobert FIND_BASE=$1 387*404b540aSrobert export FIND_BASE 388*404b540aSrobert shift 389*404b540aSrobert 390*404b540aSrobert DESTDIR=`cd $1;${PWDCMD}` 391*404b540aSrobert export DESTDIR 392*404b540aSrobert shift 393*404b540aSrobert 394*404b540aSrobert # The same dir can appear more than once in treetops. 395*404b540aSrobert # There's no need to scan it more than once. 396*404b540aSrobert # 397*404b540aSrobert if [ -f ${DESTDIR}/DONE ] 398*404b540aSrobert then continue ; fi 399*404b540aSrobert 400*404b540aSrobert touch ${DESTDIR}/DONE 401*404b540aSrobert if test $VERBOSE -gt 1 402*404b540aSrobert then echo Fixing directory ${SRCDIR} into ${DESTDIR} ; fi 403*404b540aSrobert 404*404b540aSrobert # Check files which are symlinks as well as those which are files. 405*404b540aSrobert # 406*404b540aSrobert cd ${INPUT} 407*404b540aSrobert required="$required `if $LINKS; then 408*404b540aSrobert find ${FIND_BASE}/. -name '*.h' \( -type f -o -type l \) -print 409*404b540aSrobert else 410*404b540aSrobert find ${FIND_BASE}/. -name '*.h' -type f -print 411*404b540aSrobert fi | \ 412*404b540aSrobert sed -e 's;/\./;/;g' -e 's;//*;/;g' | \ 413*404b540aSrobert ${FIXINCL}`" 414*404b540aSrobertdone 415*404b540aSrobert 416*404b540aSrobert## Make sure that any include files referenced using double quotes 417*404b540aSrobert## exist in the fixed directory. This comes last since otherwise 418*404b540aSrobert## we might end up deleting some of these files "because they don't 419*404b540aSrobert## need any change." 420*404b540aSrobertset x `echo $required` 421*404b540aSrobertshift 422*404b540aSrobertwhile [ $# != 0 ]; do 423*404b540aSrobert newreq= 424*404b540aSrobert while [ $# != 0 ]; do 425*404b540aSrobert # $1 is the directory to copy from, 426*404b540aSrobert # $2 is the unfixed file, 427*404b540aSrobert # $3 is the fixed file name. 428*404b540aSrobert # 429*404b540aSrobert cd ${INPUT} 430*404b540aSrobert cd $1 431*404b540aSrobert if [ -f $2 ] ; then 432*404b540aSrobert if [ -r $2 ] && [ ! -r $3 ]; then 433*404b540aSrobert cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2 434*404b540aSrobert chmod +w $3 2>/dev/null 435*404b540aSrobert chmod a+r $3 2>/dev/null 436*404b540aSrobert if test $VERBOSE -gt 2 437*404b540aSrobert then echo Copied $2 ; fi 438*404b540aSrobert for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | 439*404b540aSrobert sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'` 440*404b540aSrobert do 441*404b540aSrobert dir=`echo $2 | sed -e s'|/[^/]*$||'` 442*404b540aSrobert dir2=`echo $3 | sed -e s'|/[^/]*$||'` 443*404b540aSrobert newreq="$newreq $1 $dir/$include $dir2/$include" 444*404b540aSrobert done 445*404b540aSrobert fi 446*404b540aSrobert fi 447*404b540aSrobert shift; shift; shift 448*404b540aSrobert done 449*404b540aSrobert set x $newreq 450*404b540aSrobert shift 451*404b540aSrobertdone 452*404b540aSrobert 453*404b540aSrobertif test $VERBOSE -gt 2 454*404b540aSrobertthen echo 'Cleaning up DONE files.' ; fi 455*404b540aSrobertcd $LIB 456*404b540aSrobert# Look for files case-insensitively, for the benefit of 457*404b540aSrobert# DOS/Windows filesystems. 458*404b540aSrobertfind . -name '[Dd][Oo][Nn][Ee]' -exec rm -f '{}' ';' 459*404b540aSrobert 460*404b540aSrobertif test $VERBOSE -gt 1 461*404b540aSrobertthen echo 'Cleaning up unneeded directories:' ; fi 462*404b540aSrobertcd $LIB 463*404b540aSrobertall_dirs=`find . -type d \! -name '.' -print | sort -r` 464*404b540aSrobertfor file in $all_dirs; do 465*404b540aSrobert if rmdir $LIB/$file > /dev/null 466*404b540aSrobert then 467*404b540aSrobert test $VERBOSE -gt 3 && echo " removed $file" 468*404b540aSrobert fi 469*404b540aSrobertdone 2> /dev/null 470*404b540aSrobert 471*404b540aSrobert# On systems which don't support symlinks, `find' may barf 472*404b540aSrobert# if called with "-type l" predicate. So only use that if 473*404b540aSrobert# we know we should look for symlinks. 474*404b540aSrobertif $LINKS; then 475*404b540aSrobert test $VERBOSE -gt 2 && echo "Removing unused symlinks" 476*404b540aSrobert 477*404b540aSrobert all_dirs=`find . -type l -print` 478*404b540aSrobert for file in $all_dirs 479*404b540aSrobert do 480*404b540aSrobert if test ! -d $file 481*404b540aSrobert then 482*404b540aSrobert rm -f $file 483*404b540aSrobert test $VERBOSE -gt 3 && echo " removed $file" 484*404b540aSrobert rmdir `dirname $file` > /dev/null && \ 485*404b540aSrobert test $VERBOSE -gt 3 && \ 486*404b540aSrobert echo " removed `dirname $file`" 487*404b540aSrobert fi 488*404b540aSrobert done 2> /dev/null 489*404b540aSrobertfi 490*404b540aSrobert 491*404b540aSrobertif test $VERBOSE -gt 0 492*404b540aSrobertthen echo fixincludes is done ; fi 493*404b540aSrobert 494*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 495*404b540aSrobert# 496*404b540aSrobert# End of for INPUT directories 497*404b540aSrobert# 498*404b540aSrobertdone 499*404b540aSrobert# 500*404b540aSrobert# # # # # # # # # # # # # # # # # # # # # 501