depcomp
branchSDL-1.2
changeset 611 b39ee38ead19
parent 285 b3f70e3d7246
child 664 b6b714389ea9
     1.1 --- a/depcomp	Wed Oct 17 01:00:32 2018 +0300
     1.2 +++ b/depcomp	Thu Oct 18 11:55:14 2018 +0300
     1.3 @@ -1,10 +1,9 @@
     1.4  #! /bin/sh
     1.5  # depcomp - compile a program generating dependencies as side-effects
     1.6  
     1.7 -scriptversion=2006-10-15.18
     1.8 +scriptversion=2012-07-12.20; # UTC
     1.9  
    1.10 -# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
    1.11 -# Foundation, Inc.
    1.12 +# Copyright (C) 1999-2012 Free Software Foundation, Inc.
    1.13  
    1.14  # This program is free software; you can redistribute it and/or modify
    1.15  # it under the terms of the GNU General Public License as published by
    1.16 @@ -17,9 +16,7 @@
    1.17  # GNU General Public License for more details.
    1.18  
    1.19  # You should have received a copy of the GNU General Public License
    1.20 -# along with this program; if not, write to the Free Software
    1.21 -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    1.22 -# 02110-1301, USA.
    1.23 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.24  
    1.25  # As a special exception to the GNU General Public License, if you
    1.26  # distribute this file as part of a program that contains a
    1.27 @@ -30,7 +27,7 @@
    1.28  
    1.29  case $1 in
    1.30    '')
    1.31 -     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
    1.32 +     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
    1.33       exit 1;
    1.34       ;;
    1.35    -h | --h*)
    1.36 @@ -42,11 +39,11 @@
    1.37  
    1.38  Environment variables:
    1.39    depmode     Dependency tracking mode.
    1.40 -  source      Source file read by `PROGRAMS ARGS'.
    1.41 -  object      Object file output by `PROGRAMS ARGS'.
    1.42 +  source      Source file read by 'PROGRAMS ARGS'.
    1.43 +  object      Object file output by 'PROGRAMS ARGS'.
    1.44    DEPDIR      directory where to store dependencies.
    1.45    depfile     Dependency file to output.
    1.46 -  tmpdepfile  Temporary file to use when outputing dependencies.
    1.47 +  tmpdepfile  Temporary file to use when outputting dependencies.
    1.48    libtool     Whether libtool is used (yes/no).
    1.49  
    1.50  Report bugs to <bug-automake@gnu.org>.
    1.51 @@ -59,6 +56,12 @@
    1.52      ;;
    1.53  esac
    1.54  
    1.55 +# A tabulation character.
    1.56 +tab='	'
    1.57 +# A newline character.
    1.58 +nl='
    1.59 +'
    1.60 +
    1.61  if test -z "$depmode" || test -z "$source" || test -z "$object"; then
    1.62    echo "depcomp: Variables source, object and depmode must be set" 1>&2
    1.63    exit 1
    1.64 @@ -87,6 +90,29 @@
    1.65     depmode=dashmstdout
    1.66  fi
    1.67  
    1.68 +cygpath_u="cygpath -u -f -"
    1.69 +if test "$depmode" = msvcmsys; then
    1.70 +   # This is just like msvisualcpp but w/o cygpath translation.
    1.71 +   # Just convert the backslash-escaped backslashes to single forward
    1.72 +   # slashes to satisfy depend.m4
    1.73 +   cygpath_u='sed s,\\\\,/,g'
    1.74 +   depmode=msvisualcpp
    1.75 +fi
    1.76 +
    1.77 +if test "$depmode" = msvc7msys; then
    1.78 +   # This is just like msvc7 but w/o cygpath translation.
    1.79 +   # Just convert the backslash-escaped backslashes to single forward
    1.80 +   # slashes to satisfy depend.m4
    1.81 +   cygpath_u='sed s,\\\\,/,g'
    1.82 +   depmode=msvc7
    1.83 +fi
    1.84 +
    1.85 +if test "$depmode" = xlc; then
    1.86 +   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
    1.87 +   gccflag=-qmakedep=gcc,-MF
    1.88 +   depmode=gcc
    1.89 +fi
    1.90 +
    1.91  case "$depmode" in
    1.92  gcc3)
    1.93  ## gcc 3 implements dependency tracking that does exactly what
    1.94 @@ -141,20 +167,21 @@
    1.95  ## The second -e expression handles DOS-style file names with drive letters.
    1.96    sed -e 's/^[^:]*: / /' \
    1.97        -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
    1.98 -## This next piece of magic avoids the `deleted header file' problem.
    1.99 +## This next piece of magic avoids the "deleted header file" problem.
   1.100  ## The problem is that when a header file which appears in a .P file
   1.101  ## is deleted, the dependency causes make to die (because there is
   1.102  ## typically no way to rebuild the header).  We avoid this by adding
   1.103  ## dummy dependencies for each header file.  Too bad gcc doesn't do
   1.104  ## this for us directly.
   1.105 -  tr ' ' '
   1.106 -' < "$tmpdepfile" |
   1.107 -## Some versions of gcc put a space before the `:'.  On the theory
   1.108 +  tr ' ' "$nl" < "$tmpdepfile" |
   1.109 +## Some versions of gcc put a space before the ':'.  On the theory
   1.110  ## that the space means something, we add a space to the output as
   1.111 -## well.
   1.112 +## well.  hp depmode also adds that space, but also prefixes the VPATH
   1.113 +## to the object.  Take care to not repeat it in the output.
   1.114  ## Some versions of the HPUX 10.20 sed can't process this invocation
   1.115  ## correctly.  Breaking it into two sed invocations is a workaround.
   1.116 -    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
   1.117 +    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
   1.118 +      | sed -e 's/$/ :/' >> "$depfile"
   1.119    rm -f "$tmpdepfile"
   1.120    ;;
   1.121  
   1.122 @@ -186,20 +213,17 @@
   1.123      # clever and replace this with sed code, as IRIX sed won't handle
   1.124      # lines with more than a fixed number of characters (4096 in
   1.125      # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
   1.126 -    # the IRIX cc adds comments like `#:fec' to the end of the
   1.127 +    # the IRIX cc adds comments like '#:fec' to the end of the
   1.128      # dependency line.
   1.129 -    tr ' ' '
   1.130 -' < "$tmpdepfile" \
   1.131 +    tr ' ' "$nl" < "$tmpdepfile" \
   1.132      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
   1.133 -    tr '
   1.134 -' ' ' >> $depfile
   1.135 -    echo >> $depfile
   1.136 +    tr "$nl" ' ' >> "$depfile"
   1.137 +    echo >> "$depfile"
   1.138  
   1.139      # The second pass generates a dummy entry for each header file.
   1.140 -    tr ' ' '
   1.141 -' < "$tmpdepfile" \
   1.142 +    tr ' ' "$nl" < "$tmpdepfile" \
   1.143     | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
   1.144 -   >> $depfile
   1.145 +   >> "$depfile"
   1.146    else
   1.147      # The sourcefile does not contain any dependencies, so just
   1.148      # store a dummy comment line, to avoid errors with the Makefile
   1.149 @@ -209,40 +233,51 @@
   1.150    rm -f "$tmpdepfile"
   1.151    ;;
   1.152  
   1.153 +xlc)
   1.154 +  # This case exists only to let depend.m4 do its work.  It works by
   1.155 +  # looking at the text of this script.  This case will never be run,
   1.156 +  # since it is checked for above.
   1.157 +  exit 1
   1.158 +  ;;
   1.159 +
   1.160  aix)
   1.161    # The C for AIX Compiler uses -M and outputs the dependencies
   1.162    # in a .u file.  In older versions, this file always lives in the
   1.163 -  # current directory.  Also, the AIX compiler puts `$object:' at the
   1.164 +  # current directory.  Also, the AIX compiler puts '$object:' at the
   1.165    # start of each line; $object doesn't have directory information.
   1.166    # Version 6 uses the directory in both cases.
   1.167 -  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
   1.168 -  tmpdepfile="$stripped.u"
   1.169 +  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
   1.170 +  test "x$dir" = "x$object" && dir=
   1.171 +  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
   1.172    if test "$libtool" = yes; then
   1.173 +    tmpdepfile1=$dir$base.u
   1.174 +    tmpdepfile2=$base.u
   1.175 +    tmpdepfile3=$dir.libs/$base.u
   1.176      "$@" -Wc,-M
   1.177    else
   1.178 +    tmpdepfile1=$dir$base.u
   1.179 +    tmpdepfile2=$dir$base.u
   1.180 +    tmpdepfile3=$dir$base.u
   1.181      "$@" -M
   1.182    fi
   1.183    stat=$?
   1.184  
   1.185 -  if test -f "$tmpdepfile"; then :
   1.186 -  else
   1.187 -    stripped=`echo "$stripped" | sed 's,^.*/,,'`
   1.188 -    tmpdepfile="$stripped.u"
   1.189 -  fi
   1.190 -
   1.191    if test $stat -eq 0; then :
   1.192    else
   1.193 -    rm -f "$tmpdepfile"
   1.194 +    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
   1.195      exit $stat
   1.196    fi
   1.197  
   1.198 +  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
   1.199 +  do
   1.200 +    test -f "$tmpdepfile" && break
   1.201 +  done
   1.202    if test -f "$tmpdepfile"; then
   1.203 -    outname="$stripped.o"
   1.204 -    # Each line is of the form `foo.o: dependent.h'.
   1.205 +    # Each line is of the form 'foo.o: dependent.h'.
   1.206      # Do two passes, one to just change these to
   1.207 -    # `$object: dependent.h' and one to simply `dependent.h:'.
   1.208 -    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
   1.209 -    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
   1.210 +    # '$object: dependent.h' and one to simply 'dependent.h:'.
   1.211 +    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
   1.212 +    sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
   1.213    else
   1.214      # The sourcefile does not contain any dependencies, so just
   1.215      # store a dummy comment line, to avoid errors with the Makefile
   1.216 @@ -253,23 +288,26 @@
   1.217    ;;
   1.218  
   1.219  icc)
   1.220 -  # Intel's C compiler understands `-MD -MF file'.  However on
   1.221 -  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
   1.222 +  # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
   1.223 +  # However on
   1.224 +  #    $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
   1.225    # ICC 7.0 will fill foo.d with something like
   1.226    #    foo.o: sub/foo.c
   1.227    #    foo.o: sub/foo.h
   1.228 -  # which is wrong.  We want:
   1.229 +  # which is wrong.  We want
   1.230    #    sub/foo.o: sub/foo.c
   1.231    #    sub/foo.o: sub/foo.h
   1.232    #    sub/foo.c:
   1.233    #    sub/foo.h:
   1.234    # ICC 7.1 will output
   1.235    #    foo.o: sub/foo.c sub/foo.h
   1.236 -  # and will wrap long lines using \ :
   1.237 +  # and will wrap long lines using '\':
   1.238    #    foo.o: sub/foo.c ... \
   1.239    #     sub/foo.h ... \
   1.240    #     ...
   1.241 -
   1.242 +  # tcc 0.9.26 (FIXME still under development at the moment of writing)
   1.243 +  # will emit a similar output, but also prepend the continuation lines
   1.244 +  # with horizontal tabulation characters.
   1.245    "$@" -MD -MF "$tmpdepfile"
   1.246    stat=$?
   1.247    if test $stat -eq 0; then :
   1.248 @@ -278,6 +316,85 @@
   1.249      exit $stat
   1.250    fi
   1.251    rm -f "$depfile"
   1.252 +  # Each line is of the form 'foo.o: dependent.h',
   1.253 +  # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
   1.254 +  # Do two passes, one to just change these to
   1.255 +  # '$object: dependent.h' and one to simply 'dependent.h:'.
   1.256 +  sed -e "s/^[ $tab][ $tab]*/  /" -e "s,^[^:]*:,$object :," \
   1.257 +    < "$tmpdepfile" > "$depfile"
   1.258 +  sed '
   1.259 +    s/[ '"$tab"'][ '"$tab"']*/ /g
   1.260 +    s/^ *//
   1.261 +    s/ *\\*$//
   1.262 +    s/^[^:]*: *//
   1.263 +    /^$/d
   1.264 +    /:$/d
   1.265 +    s/$/ :/
   1.266 +  ' < "$tmpdepfile" >> "$depfile"
   1.267 +  rm -f "$tmpdepfile"
   1.268 +  ;;
   1.269 +
   1.270 +## The order of this option in the case statement is important, since the
   1.271 +## shell code in configure will try each of these formats in the order
   1.272 +## listed in this file.  A plain '-MD' option would be understood by many
   1.273 +## compilers, so we must ensure this comes after the gcc and icc options.
   1.274 +pgcc)
   1.275 +  # Portland's C compiler understands '-MD'.
   1.276 +  # Will always output deps to 'file.d' where file is the root name of the
   1.277 +  # source file under compilation, even if file resides in a subdirectory.
   1.278 +  # The object file name does not affect the name of the '.d' file.
   1.279 +  # pgcc 10.2 will output
   1.280 +  #    foo.o: sub/foo.c sub/foo.h
   1.281 +  # and will wrap long lines using '\' :
   1.282 +  #    foo.o: sub/foo.c ... \
   1.283 +  #     sub/foo.h ... \
   1.284 +  #     ...
   1.285 +  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
   1.286 +  test "x$dir" = "x$object" && dir=
   1.287 +  # Use the source, not the object, to determine the base name, since
   1.288 +  # that's sadly what pgcc will do too.
   1.289 +  base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'`
   1.290 +  tmpdepfile="$base.d"
   1.291 +
   1.292 +  # For projects that build the same source file twice into different object
   1.293 +  # files, the pgcc approach of using the *source* file root name can cause
   1.294 +  # problems in parallel builds.  Use a locking strategy to avoid stomping on
   1.295 +  # the same $tmpdepfile.
   1.296 +  lockdir="$base.d-lock"
   1.297 +  trap "echo '$0: caught signal, cleaning up...' >&2; rm -rf $lockdir" 1 2 13 15
   1.298 +  numtries=100
   1.299 +  i=$numtries
   1.300 +  while test $i -gt 0 ; do
   1.301 +    # mkdir is a portable test-and-set.
   1.302 +    if mkdir $lockdir 2>/dev/null; then
   1.303 +      # This process acquired the lock.
   1.304 +      "$@" -MD
   1.305 +      stat=$?
   1.306 +      # Release the lock.
   1.307 +      rm -rf $lockdir
   1.308 +      break
   1.309 +    else
   1.310 +      ## the lock is being held by a different process,
   1.311 +      ## wait until the winning process is done or we timeout
   1.312 +      while test -d $lockdir && test $i -gt 0; do
   1.313 +        sleep 1
   1.314 +        i=`expr $i - 1`
   1.315 +      done
   1.316 +    fi
   1.317 +    i=`expr $i - 1`
   1.318 +  done
   1.319 +  trap - 1 2 13 15
   1.320 +  if test $i -le 0; then
   1.321 +    echo "$0: failed to acquire lock after $numtries attempts" >&2
   1.322 +    echo "$0: check lockdir '$lockdir'" >&2
   1.323 +    exit 1
   1.324 +  fi
   1.325 +
   1.326 +  if test $stat -ne 0; then
   1.327 +    rm -f "$tmpdepfile"
   1.328 +    exit $stat
   1.329 +  fi
   1.330 +  rm -f "$depfile"
   1.331    # Each line is of the form `foo.o: dependent.h',
   1.332    # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
   1.333    # Do two passes, one to just change these to
   1.334 @@ -322,8 +439,13 @@
   1.335    done
   1.336    if test -f "$tmpdepfile"; then
   1.337      sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
   1.338 -    # Add `dependent.h:' lines.
   1.339 -    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
   1.340 +    # Add 'dependent.h:' lines.
   1.341 +    sed -ne '2,${
   1.342 +	       s/^ *//
   1.343 +	       s/ \\*$//
   1.344 +	       s/$/:/
   1.345 +	       p
   1.346 +	     }' "$tmpdepfile" >> "$depfile"
   1.347    else
   1.348      echo "#dummy" > "$depfile"
   1.349    fi
   1.350 @@ -332,9 +454,9 @@
   1.351  
   1.352  tru64)
   1.353     # The Tru64 compiler uses -MD to generate dependencies as a side
   1.354 -   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
   1.355 +   # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
   1.356     # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
   1.357 -   # dependencies in `foo.d' instead, so we check for that too.
   1.358 +   # dependencies in 'foo.d' instead, so we check for that too.
   1.359     # Subdirectories are respected.
   1.360     dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
   1.361     test "x$dir" = "x$object" && dir=
   1.362 @@ -380,14 +502,59 @@
   1.363     done
   1.364     if test -f "$tmpdepfile"; then
   1.365        sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
   1.366 -      # That's a tab and a space in the [].
   1.367 -      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
   1.368 +      sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
   1.369     else
   1.370        echo "#dummy" > "$depfile"
   1.371     fi
   1.372     rm -f "$tmpdepfile"
   1.373     ;;
   1.374  
   1.375 +msvc7)
   1.376 +  if test "$libtool" = yes; then
   1.377 +    showIncludes=-Wc,-showIncludes
   1.378 +  else
   1.379 +    showIncludes=-showIncludes
   1.380 +  fi
   1.381 +  "$@" $showIncludes > "$tmpdepfile"
   1.382 +  stat=$?
   1.383 +  grep -v '^Note: including file: ' "$tmpdepfile"
   1.384 +  if test "$stat" = 0; then :
   1.385 +  else
   1.386 +    rm -f "$tmpdepfile"
   1.387 +    exit $stat
   1.388 +  fi
   1.389 +  rm -f "$depfile"
   1.390 +  echo "$object : \\" > "$depfile"
   1.391 +  # The first sed program below extracts the file names and escapes
   1.392 +  # backslashes for cygpath.  The second sed program outputs the file
   1.393 +  # name when reading, but also accumulates all include files in the
   1.394 +  # hold buffer in order to output them again at the end.  This only
   1.395 +  # works with sed implementations that can handle large buffers.
   1.396 +  sed < "$tmpdepfile" -n '
   1.397 +/^Note: including file:  *\(.*\)/ {
   1.398 +  s//\1/
   1.399 +  s/\\/\\\\/g
   1.400 +  p
   1.401 +}' | $cygpath_u | sort -u | sed -n '
   1.402 +s/ /\\ /g
   1.403 +s/\(.*\)/'"$tab"'\1 \\/p
   1.404 +s/.\(.*\) \\/\1:/
   1.405 +H
   1.406 +$ {
   1.407 +  s/.*/'"$tab"'/
   1.408 +  G
   1.409 +  p
   1.410 +}' >> "$depfile"
   1.411 +  rm -f "$tmpdepfile"
   1.412 +  ;;
   1.413 +
   1.414 +msvc7msys)
   1.415 +  # This case exists only to let depend.m4 do its work.  It works by
   1.416 +  # looking at the text of this script.  This case will never be run,
   1.417 +  # since it is checked for above.
   1.418 +  exit 1
   1.419 +  ;;
   1.420 +
   1.421  #nosideeffect)
   1.422    # This comment above is used by automake to tell side-effect
   1.423    # dependency tracking mechanisms from slower ones.
   1.424 @@ -399,13 +566,13 @@
   1.425  
   1.426    # Remove the call to Libtool.
   1.427    if test "$libtool" = yes; then
   1.428 -    while test $1 != '--mode=compile'; do
   1.429 +    while test "X$1" != 'X--mode=compile'; do
   1.430        shift
   1.431      done
   1.432      shift
   1.433    fi
   1.434  
   1.435 -  # Remove `-o $object'.
   1.436 +  # Remove '-o $object'.
   1.437    IFS=" "
   1.438    for arg
   1.439    do
   1.440 @@ -425,15 +592,14 @@
   1.441    done
   1.442  
   1.443    test -z "$dashmflag" && dashmflag=-M
   1.444 -  # Require at least two characters before searching for `:'
   1.445 +  # Require at least two characters before searching for ':'
   1.446    # in the target name.  This is to cope with DOS-style filenames:
   1.447 -  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
   1.448 +  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
   1.449    "$@" $dashmflag |
   1.450 -    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
   1.451 +    sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
   1.452    rm -f "$depfile"
   1.453    cat < "$tmpdepfile" > "$depfile"
   1.454 -  tr ' ' '
   1.455 -' < "$tmpdepfile" | \
   1.456 +  tr ' ' "$nl" < "$tmpdepfile" | \
   1.457  ## Some versions of the HPUX 10.20 sed can't process this invocation
   1.458  ## correctly.  Breaking it into two sed invocations is a workaround.
   1.459      sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
   1.460 @@ -450,38 +616,46 @@
   1.461    "$@" || exit $?
   1.462    # Remove any Libtool call
   1.463    if test "$libtool" = yes; then
   1.464 -    while test $1 != '--mode=compile'; do
   1.465 +    while test "X$1" != 'X--mode=compile'; do
   1.466        shift
   1.467      done
   1.468      shift
   1.469    fi
   1.470    # X makedepend
   1.471    shift
   1.472 -  cleared=no
   1.473 -  for arg in "$@"; do
   1.474 +  cleared=no eat=no
   1.475 +  for arg
   1.476 +  do
   1.477      case $cleared in
   1.478      no)
   1.479        set ""; shift
   1.480        cleared=yes ;;
   1.481      esac
   1.482 +    if test $eat = yes; then
   1.483 +      eat=no
   1.484 +      continue
   1.485 +    fi
   1.486      case "$arg" in
   1.487      -D*|-I*)
   1.488        set fnord "$@" "$arg"; shift ;;
   1.489      # Strip any option that makedepend may not understand.  Remove
   1.490      # the object too, otherwise makedepend will parse it as a source file.
   1.491 +    -arch)
   1.492 +      eat=yes ;;
   1.493      -*|$object)
   1.494        ;;
   1.495      *)
   1.496        set fnord "$@" "$arg"; shift ;;
   1.497      esac
   1.498    done
   1.499 -  obj_suffix="`echo $object | sed 's/^.*\././'`"
   1.500 +  obj_suffix=`echo "$object" | sed 's/^.*\././'`
   1.501    touch "$tmpdepfile"
   1.502    ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
   1.503    rm -f "$depfile"
   1.504 -  cat < "$tmpdepfile" > "$depfile"
   1.505 -  sed '1,2d' "$tmpdepfile" | tr ' ' '
   1.506 -' | \
   1.507 +  # makedepend may prepend the VPATH from the source file name to the object.
   1.508 +  # No need to regex-escape $object, excess matching of '.' is harmless.
   1.509 +  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
   1.510 +  sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
   1.511  ## Some versions of the HPUX 10.20 sed can't process this invocation
   1.512  ## correctly.  Breaking it into two sed invocations is a workaround.
   1.513      sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
   1.514 @@ -495,13 +669,13 @@
   1.515  
   1.516    # Remove the call to Libtool.
   1.517    if test "$libtool" = yes; then
   1.518 -    while test $1 != '--mode=compile'; do
   1.519 +    while test "X$1" != 'X--mode=compile'; do
   1.520        shift
   1.521      done
   1.522      shift
   1.523    fi
   1.524  
   1.525 -  # Remove `-o $object'.
   1.526 +  # Remove '-o $object'.
   1.527    IFS=" "
   1.528    for arg
   1.529    do
   1.530 @@ -533,13 +707,27 @@
   1.531  
   1.532  msvisualcpp)
   1.533    # Important note: in order to support this mode, a compiler *must*
   1.534 -  # always write the preprocessed file to stdout, regardless of -o,
   1.535 -  # because we must use -o when running libtool.
   1.536 +  # always write the preprocessed file to stdout.
   1.537    "$@" || exit $?
   1.538 +
   1.539 +  # Remove the call to Libtool.
   1.540 +  if test "$libtool" = yes; then
   1.541 +    while test "X$1" != 'X--mode=compile'; do
   1.542 +      shift
   1.543 +    done
   1.544 +    shift
   1.545 +  fi
   1.546 +
   1.547    IFS=" "
   1.548    for arg
   1.549    do
   1.550      case "$arg" in
   1.551 +    -o)
   1.552 +      shift
   1.553 +      ;;
   1.554 +    $object)
   1.555 +      shift
   1.556 +      ;;
   1.557      "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
   1.558  	set fnord "$@"
   1.559  	shift
   1.560 @@ -552,16 +740,23 @@
   1.561  	;;
   1.562      esac
   1.563    done
   1.564 -  "$@" -E |
   1.565 -  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
   1.566 +  "$@" -E 2>/dev/null |
   1.567 +  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
   1.568    rm -f "$depfile"
   1.569    echo "$object : \\" > "$depfile"
   1.570 -  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
   1.571 -  echo "	" >> "$depfile"
   1.572 -  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
   1.573 +  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
   1.574 +  echo "$tab" >> "$depfile"
   1.575 +  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
   1.576    rm -f "$tmpdepfile"
   1.577    ;;
   1.578  
   1.579 +msvcmsys)
   1.580 +  # This case exists only to let depend.m4 do its work.  It works by
   1.581 +  # looking at the text of this script.  This case will never be run,
   1.582 +  # since it is checked for above.
   1.583 +  exit 1
   1.584 +  ;;
   1.585 +
   1.586  none)
   1.587    exec "$@"
   1.588    ;;
   1.589 @@ -580,5 +775,6 @@
   1.590  # eval: (add-hook 'write-file-hooks 'time-stamp)
   1.591  # time-stamp-start: "scriptversion="
   1.592  # time-stamp-format: "%:y-%02m-%02d.%02H"
   1.593 -# time-stamp-end: "$"
   1.594 +# time-stamp-time-zone: "UTC"
   1.595 +# time-stamp-end: "; # UTC"
   1.596  # End: