diff --git a/wmake/wcleanLnIncludeAll b/wmake/wcleanLnIncludeAll index 7d7d0059c1..67da4d0bb0 100755 --- a/wmake/wcleanLnIncludeAll +++ b/wmake/wcleanLnIncludeAll @@ -24,7 +24,7 @@ # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script -# wmakeLnInclude +# wcleanLnIncludeAll # # Description # Delete all the lnInclude directories in the tree. diff --git a/wmake/wmakeLnInclude b/wmake/wmakeLnInclude index fcf3bfbf50..ad63d6bca9 100755 --- a/wmake/wmakeLnInclude +++ b/wmake/wmakeLnInclude @@ -80,8 +80,18 @@ do done baseDir=$1 +# convert incorrect path/dir/lnInclude to something sensible +while [ "${baseDir##*/}" = lnInclude ] +do + baseDir="${baseDir%/*}" + if [ "$baseDir" = lnInclude ] + then + baseDir="." + fi +done incDir=$baseDir/lnInclude + if [ $# -eq 1 ] then lnOpt="-s" @@ -89,7 +99,7 @@ elif [ $# -eq 2 ] then lnOpt="$2" else - usage "ERROR: wrong number of arguments" + usage "ERROR: incorrect number of arguments" fi @@ -101,7 +111,6 @@ fi if [ -d $incDir ] then - # could change force to remove lnInclude first if [ ! "$forceUpdate" ] then # echo $Script: include directory $incDir already exists, exiting. @@ -117,24 +126,34 @@ then exit 0 fi +cd $incDir || exit 1 + # Link include files # ~~~~~~~~~~~~~~~~~~ echo $Script: linking include files to $incDir -echo - -cd $incDir - -find .. $findOpt \ - \( -name lnInclude -o -name -Make -o -name config \) -prune \ - -o \( -name '*.[CHh]' -o -name '*.[ch]xx' -o -name '*.[ch]pp' -o -name '*.type' \) \ - -a ! -name ".#*" \ - -exec ln $lnOpt {} . \; - # -# remove any broken links +# remove any broken links first (this helps when file locations have moved) # find -L . -type l -exec rm \{\} \; +# +# create links, avoid recreating links unless necessary +# +find .. $findOpt \ + \( -name lnInclude -o -name Make -o -name config \) -prune \ + -o \( -name '*.[CHh]' -o -name '*.[ch]xx' -o -name '*.[ch]pp' -o -name '*.type' \) \ + -a ! -name ".#*" \ + -print | \ + while read src + do + link=$(readlink ${src##*/}) + if [ "$link" != "$src" ] + then + rm $link 2>/dev/null + ln $lnOpt $src . + fi + done + #------------------------------------------------------------------------------