depcomp
changeset 664 b6b714389ea9
parent 612 ca95d0e31aec
     1.1 --- a/depcomp	Wed Jun 19 07:36:02 2019 -0700
     1.2 +++ b/depcomp	Wed Jun 19 07:37:56 2019 -0700
     1.3 @@ -1,9 +1,9 @@
     1.4  #! /bin/sh
     1.5  # depcomp - compile a program generating dependencies as side-effects
     1.6  
     1.7 -scriptversion=2012-07-12.20; # UTC
     1.8 +scriptversion=2017-09-16.17; # UTC
     1.9  
    1.10 -# Copyright (C) 1999-2012 Free Software Foundation, Inc.
    1.11 +# Copyright (C) 1999-2018 Free Software Foundation, Inc.
    1.12  
    1.13  # This program is free software; you can redistribute it and/or modify
    1.14  # it under the terms of the GNU General Public License as published by
    1.15 @@ -16,7 +16,7 @@
    1.16  # GNU General Public License for more details.
    1.17  
    1.18  # You should have received a copy of the GNU General Public License
    1.19 -# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.20 +# along with this program.  If not, see <https://www.gnu.org/licenses/>.
    1.21  
    1.22  # As a special exception to the GNU General Public License, if you
    1.23  # distribute this file as part of a program that contains a
    1.24 @@ -27,9 +27,9 @@
    1.25  
    1.26  case $1 in
    1.27    '')
    1.28 -     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
    1.29 -     exit 1;
    1.30 -     ;;
    1.31 +    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
    1.32 +    exit 1;
    1.33 +    ;;
    1.34    -h | --h*)
    1.35      cat <<\EOF
    1.36  Usage: depcomp [--help] [--version] PROGRAM [ARGS]
    1.37 @@ -56,11 +56,65 @@
    1.38      ;;
    1.39  esac
    1.40  
    1.41 +# Get the directory component of the given path, and save it in the
    1.42 +# global variables '$dir'.  Note that this directory component will
    1.43 +# be either empty or ending with a '/' character.  This is deliberate.
    1.44 +set_dir_from ()
    1.45 +{
    1.46 +  case $1 in
    1.47 +    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
    1.48 +      *) dir=;;
    1.49 +  esac
    1.50 +}
    1.51 +
    1.52 +# Get the suffix-stripped basename of the given path, and save it the
    1.53 +# global variable '$base'.
    1.54 +set_base_from ()
    1.55 +{
    1.56 +  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
    1.57 +}
    1.58 +
    1.59 +# If no dependency file was actually created by the compiler invocation,
    1.60 +# we still have to create a dummy depfile, to avoid errors with the
    1.61 +# Makefile "include basename.Plo" scheme.
    1.62 +make_dummy_depfile ()
    1.63 +{
    1.64 +  echo "#dummy" > "$depfile"
    1.65 +}
    1.66 +
    1.67 +# Factor out some common post-processing of the generated depfile.
    1.68 +# Requires the auxiliary global variable '$tmpdepfile' to be set.
    1.69 +aix_post_process_depfile ()
    1.70 +{
    1.71 +  # If the compiler actually managed to produce a dependency file,
    1.72 +  # post-process it.
    1.73 +  if test -f "$tmpdepfile"; then
    1.74 +    # Each line is of the form 'foo.o: dependency.h'.
    1.75 +    # Do two passes, one to just change these to
    1.76 +    #   $object: dependency.h
    1.77 +    # and one to simply output
    1.78 +    #   dependency.h:
    1.79 +    # which is needed to avoid the deleted-header problem.
    1.80 +    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
    1.81 +      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
    1.82 +    } > "$depfile"
    1.83 +    rm -f "$tmpdepfile"
    1.84 +  else
    1.85 +    make_dummy_depfile
    1.86 +  fi
    1.87 +}
    1.88 +
    1.89  # A tabulation character.
    1.90  tab='	'
    1.91  # A newline character.
    1.92  nl='
    1.93  '
    1.94 +# Character ranges might be problematic outside the C locale.
    1.95 +# These definitions help.
    1.96 +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
    1.97 +lower=abcdefghijklmnopqrstuvwxyz
    1.98 +digits=0123456789
    1.99 +alpha=${upper}${lower}
   1.100  
   1.101  if test -z "$depmode" || test -z "$source" || test -z "$object"; then
   1.102    echo "depcomp: Variables source, object and depmode must be set" 1>&2
   1.103 @@ -74,6 +128,9 @@
   1.104  
   1.105  rm -f "$tmpdepfile"
   1.106  
   1.107 +# Avoid interferences from the environment.
   1.108 +gccflag= dashmflag=
   1.109 +
   1.110  # Some modes work just like other modes, but use different flags.  We
   1.111  # parameterize here, but still list the modes in the big case below,
   1.112  # to make depend.m4 easier to write.  Note that we *cannot* use a case
   1.113 @@ -85,32 +142,32 @@
   1.114  fi
   1.115  
   1.116  if test "$depmode" = dashXmstdout; then
   1.117 -   # This is just like dashmstdout with a different argument.
   1.118 -   dashmflag=-xM
   1.119 -   depmode=dashmstdout
   1.120 +  # This is just like dashmstdout with a different argument.
   1.121 +  dashmflag=-xM
   1.122 +  depmode=dashmstdout
   1.123  fi
   1.124  
   1.125  cygpath_u="cygpath -u -f -"
   1.126  if test "$depmode" = msvcmsys; then
   1.127 -   # This is just like msvisualcpp but w/o cygpath translation.
   1.128 -   # Just convert the backslash-escaped backslashes to single forward
   1.129 -   # slashes to satisfy depend.m4
   1.130 -   cygpath_u='sed s,\\\\,/,g'
   1.131 -   depmode=msvisualcpp
   1.132 +  # This is just like msvisualcpp but w/o cygpath translation.
   1.133 +  # Just convert the backslash-escaped backslashes to single forward
   1.134 +  # slashes to satisfy depend.m4
   1.135 +  cygpath_u='sed s,\\\\,/,g'
   1.136 +  depmode=msvisualcpp
   1.137  fi
   1.138  
   1.139  if test "$depmode" = msvc7msys; then
   1.140 -   # This is just like msvc7 but w/o cygpath translation.
   1.141 -   # Just convert the backslash-escaped backslashes to single forward
   1.142 -   # slashes to satisfy depend.m4
   1.143 -   cygpath_u='sed s,\\\\,/,g'
   1.144 -   depmode=msvc7
   1.145 +  # This is just like msvc7 but w/o cygpath translation.
   1.146 +  # Just convert the backslash-escaped backslashes to single forward
   1.147 +  # slashes to satisfy depend.m4
   1.148 +  cygpath_u='sed s,\\\\,/,g'
   1.149 +  depmode=msvc7
   1.150  fi
   1.151  
   1.152  if test "$depmode" = xlc; then
   1.153 -   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
   1.154 -   gccflag=-qmakedep=gcc,-MF
   1.155 -   depmode=gcc
   1.156 +  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
   1.157 +  gccflag=-qmakedep=gcc,-MF
   1.158 +  depmode=gcc
   1.159  fi
   1.160  
   1.161  case "$depmode" in
   1.162 @@ -133,8 +190,7 @@
   1.163    done
   1.164    "$@"
   1.165    stat=$?
   1.166 -  if test $stat -eq 0; then :
   1.167 -  else
   1.168 +  if test $stat -ne 0; then
   1.169      rm -f "$tmpdepfile"
   1.170      exit $stat
   1.171    fi
   1.172 @@ -142,13 +198,17 @@
   1.173    ;;
   1.174  
   1.175  gcc)
   1.176 +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
   1.177 +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
   1.178 +## (see the conditional assignment to $gccflag above).
   1.179  ## There are various ways to get dependency output from gcc.  Here's
   1.180  ## why we pick this rather obscure method:
   1.181  ## - Don't want to use -MD because we'd like the dependencies to end
   1.182  ##   up in a subdir.  Having to rename by hand is ugly.
   1.183  ##   (We might end up doing this anyway to support other compilers.)
   1.184  ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
   1.185 -##   -MM, not -M (despite what the docs say).
   1.186 +##   -MM, not -M (despite what the docs say).  Also, it might not be
   1.187 +##   supported by the other compilers which use the 'gcc' depmode.
   1.188  ## - Using -M directly means running the compiler twice (even worse
   1.189  ##   than renaming).
   1.190    if test -z "$gccflag"; then
   1.191 @@ -156,15 +216,14 @@
   1.192    fi
   1.193    "$@" -Wp,"$gccflag$tmpdepfile"
   1.194    stat=$?
   1.195 -  if test $stat -eq 0; then :
   1.196 -  else
   1.197 +  if test $stat -ne 0; then
   1.198      rm -f "$tmpdepfile"
   1.199      exit $stat
   1.200    fi
   1.201    rm -f "$depfile"
   1.202    echo "$object : \\" > "$depfile"
   1.203 -  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
   1.204 -## The second -e expression handles DOS-style file names with drive letters.
   1.205 +  # The second -e expression handles DOS-style file names with drive
   1.206 +  # letters.
   1.207    sed -e 's/^[^:]*: / /' \
   1.208        -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
   1.209  ## This next piece of magic avoids the "deleted header file" problem.
   1.210 @@ -173,15 +232,15 @@
   1.211  ## typically no way to rebuild the header).  We avoid this by adding
   1.212  ## dummy dependencies for each header file.  Too bad gcc doesn't do
   1.213  ## this for us directly.
   1.214 -  tr ' ' "$nl" < "$tmpdepfile" |
   1.215  ## Some versions of gcc put a space before the ':'.  On the theory
   1.216  ## that the space means something, we add a space to the output as
   1.217  ## well.  hp depmode also adds that space, but also prefixes the VPATH
   1.218  ## to the object.  Take care to not repeat it in the output.
   1.219  ## Some versions of the HPUX 10.20 sed can't process this invocation
   1.220  ## correctly.  Breaking it into two sed invocations is a workaround.
   1.221 -    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
   1.222 -      | sed -e 's/$/ :/' >> "$depfile"
   1.223 +  tr ' ' "$nl" < "$tmpdepfile" \
   1.224 +    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
   1.225 +    | sed -e 's/$/ :/' >> "$depfile"
   1.226    rm -f "$tmpdepfile"
   1.227    ;;
   1.228  
   1.229 @@ -199,8 +258,7 @@
   1.230      "$@" -MDupdate "$tmpdepfile"
   1.231    fi
   1.232    stat=$?
   1.233 -  if test $stat -eq 0; then :
   1.234 -  else
   1.235 +  if test $stat -ne 0; then
   1.236      rm -f "$tmpdepfile"
   1.237      exit $stat
   1.238    fi
   1.239 @@ -208,7 +266,6 @@
   1.240  
   1.241    if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
   1.242      echo "$object : \\" > "$depfile"
   1.243 -
   1.244      # Clip off the initial element (the dependent).  Don't try to be
   1.245      # clever and replace this with sed code, as IRIX sed won't handle
   1.246      # lines with more than a fixed number of characters (4096 in
   1.247 @@ -216,19 +273,15 @@
   1.248      # the IRIX cc adds comments like '#:fec' to the end of the
   1.249      # dependency line.
   1.250      tr ' ' "$nl" < "$tmpdepfile" \
   1.251 -    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
   1.252 -    tr "$nl" ' ' >> "$depfile"
   1.253 +      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
   1.254 +      | tr "$nl" ' ' >> "$depfile"
   1.255      echo >> "$depfile"
   1.256 -
   1.257      # The second pass generates a dummy entry for each header file.
   1.258      tr ' ' "$nl" < "$tmpdepfile" \
   1.259 -   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
   1.260 -   >> "$depfile"
   1.261 +      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
   1.262 +      >> "$depfile"
   1.263    else
   1.264 -    # The sourcefile does not contain any dependencies, so just
   1.265 -    # store a dummy comment line, to avoid errors with the Makefile
   1.266 -    # "include basename.Plo" scheme.
   1.267 -    echo "#dummy" > "$depfile"
   1.268 +    make_dummy_depfile
   1.269    fi
   1.270    rm -f "$tmpdepfile"
   1.271    ;;
   1.272 @@ -246,9 +299,8 @@
   1.273    # current directory.  Also, the AIX compiler puts '$object:' at the
   1.274    # start of each line; $object doesn't have directory information.
   1.275    # Version 6 uses the directory in both cases.
   1.276 -  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
   1.277 -  test "x$dir" = "x$object" && dir=
   1.278 -  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
   1.279 +  set_dir_from "$object"
   1.280 +  set_base_from "$object"
   1.281    if test "$libtool" = yes; then
   1.282      tmpdepfile1=$dir$base.u
   1.283      tmpdepfile2=$base.u
   1.284 @@ -261,9 +313,7 @@
   1.285      "$@" -M
   1.286    fi
   1.287    stat=$?
   1.288 -
   1.289 -  if test $stat -eq 0; then :
   1.290 -  else
   1.291 +  if test $stat -ne 0; then
   1.292      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
   1.293      exit $stat
   1.294    fi
   1.295 @@ -272,65 +322,37 @@
   1.296    do
   1.297      test -f "$tmpdepfile" && break
   1.298    done
   1.299 -  if test -f "$tmpdepfile"; then
   1.300 -    # Each line is of the form 'foo.o: dependent.h'.
   1.301 -    # Do two passes, one to just change these to
   1.302 -    # '$object: dependent.h' and one to simply 'dependent.h:'.
   1.303 -    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
   1.304 -    sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
   1.305 -  else
   1.306 -    # The sourcefile does not contain any dependencies, so just
   1.307 -    # store a dummy comment line, to avoid errors with the Makefile
   1.308 -    # "include basename.Plo" scheme.
   1.309 -    echo "#dummy" > "$depfile"
   1.310 -  fi
   1.311 -  rm -f "$tmpdepfile"
   1.312 +  aix_post_process_depfile
   1.313    ;;
   1.314  
   1.315 -icc)
   1.316 -  # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
   1.317 -  # However on
   1.318 -  #    $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
   1.319 -  # ICC 7.0 will fill foo.d with something like
   1.320 -  #    foo.o: sub/foo.c
   1.321 -  #    foo.o: sub/foo.h
   1.322 -  # which is wrong.  We want
   1.323 -  #    sub/foo.o: sub/foo.c
   1.324 -  #    sub/foo.o: sub/foo.h
   1.325 -  #    sub/foo.c:
   1.326 -  #    sub/foo.h:
   1.327 -  # ICC 7.1 will output
   1.328 -  #    foo.o: sub/foo.c sub/foo.h
   1.329 -  # and will wrap long lines using '\':
   1.330 -  #    foo.o: sub/foo.c ... \
   1.331 -  #     sub/foo.h ... \
   1.332 -  #     ...
   1.333 -  # tcc 0.9.26 (FIXME still under development at the moment of writing)
   1.334 -  # will emit a similar output, but also prepend the continuation lines
   1.335 -  # with horizontal tabulation characters.
   1.336 +tcc)
   1.337 +  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
   1.338 +  # FIXME: That version still under development at the moment of writing.
   1.339 +  #        Make that this statement remains true also for stable, released
   1.340 +  #        versions.
   1.341 +  # It will wrap lines (doesn't matter whether long or short) with a
   1.342 +  # trailing '\', as in:
   1.343 +  #
   1.344 +  #   foo.o : \
   1.345 +  #    foo.c \
   1.346 +  #    foo.h \
   1.347 +  #
   1.348 +  # It will put a trailing '\' even on the last line, and will use leading
   1.349 +  # spaces rather than leading tabs (at least since its commit 0394caf7
   1.350 +  # "Emit spaces for -MD").
   1.351    "$@" -MD -MF "$tmpdepfile"
   1.352    stat=$?
   1.353 -  if test $stat -eq 0; then :
   1.354 -  else
   1.355 +  if test $stat -ne 0; then
   1.356      rm -f "$tmpdepfile"
   1.357      exit $stat
   1.358    fi
   1.359    rm -f "$depfile"
   1.360 -  # Each line is of the form 'foo.o: dependent.h',
   1.361 -  # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
   1.362 -  # Do two passes, one to just change these to
   1.363 -  # '$object: dependent.h' and one to simply 'dependent.h:'.
   1.364 -  sed -e "s/^[ $tab][ $tab]*/  /" -e "s,^[^:]*:,$object :," \
   1.365 -    < "$tmpdepfile" > "$depfile"
   1.366 -  sed '
   1.367 -    s/[ '"$tab"'][ '"$tab"']*/ /g
   1.368 -    s/^ *//
   1.369 -    s/ *\\*$//
   1.370 -    s/^[^:]*: *//
   1.371 -    /^$/d
   1.372 -    /:$/d
   1.373 -    s/$/ :/
   1.374 -  ' < "$tmpdepfile" >> "$depfile"
   1.375 +  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
   1.376 +  # We have to change lines of the first kind to '$object: \'.
   1.377 +  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
   1.378 +  # And for each line of the second kind, we have to emit a 'dep.h:'
   1.379 +  # dummy dependency, to avoid the deleted-header problem.
   1.380 +  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
   1.381    rm -f "$tmpdepfile"
   1.382    ;;
   1.383  
   1.384 @@ -349,34 +371,37 @@
   1.385    #    foo.o: sub/foo.c ... \
   1.386    #     sub/foo.h ... \
   1.387    #     ...
   1.388 -  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
   1.389 -  test "x$dir" = "x$object" && dir=
   1.390 +  set_dir_from "$object"
   1.391    # Use the source, not the object, to determine the base name, since
   1.392    # that's sadly what pgcc will do too.
   1.393 -  base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'`
   1.394 -  tmpdepfile="$base.d"
   1.395 +  set_base_from "$source"
   1.396 +  tmpdepfile=$base.d
   1.397  
   1.398    # For projects that build the same source file twice into different object
   1.399    # files, the pgcc approach of using the *source* file root name can cause
   1.400    # problems in parallel builds.  Use a locking strategy to avoid stomping on
   1.401    # the same $tmpdepfile.
   1.402 -  lockdir="$base.d-lock"
   1.403 -  trap "echo '$0: caught signal, cleaning up...' >&2; rm -rf $lockdir" 1 2 13 15
   1.404 +  lockdir=$base.d-lock
   1.405 +  trap "
   1.406 +    echo '$0: caught signal, cleaning up...' >&2
   1.407 +    rmdir '$lockdir'
   1.408 +    exit 1
   1.409 +  " 1 2 13 15
   1.410    numtries=100
   1.411    i=$numtries
   1.412 -  while test $i -gt 0 ; do
   1.413 +  while test $i -gt 0; do
   1.414      # mkdir is a portable test-and-set.
   1.415 -    if mkdir $lockdir 2>/dev/null; then
   1.416 +    if mkdir "$lockdir" 2>/dev/null; then
   1.417        # This process acquired the lock.
   1.418        "$@" -MD
   1.419        stat=$?
   1.420        # Release the lock.
   1.421 -      rm -rf $lockdir
   1.422 +      rmdir "$lockdir"
   1.423        break
   1.424      else
   1.425 -      ## the lock is being held by a different process,
   1.426 -      ## wait until the winning process is done or we timeout
   1.427 -      while test -d $lockdir && test $i -gt 0; do
   1.428 +      # If the lock is being held by a different process, wait
   1.429 +      # until the winning process is done or we timeout.
   1.430 +      while test -d "$lockdir" && test $i -gt 0; do
   1.431          sleep 1
   1.432          i=`expr $i - 1`
   1.433        done
   1.434 @@ -402,8 +427,8 @@
   1.435    sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
   1.436    # Some versions of the HPUX 10.20 sed can't process this invocation
   1.437    # correctly.  Breaking it into two sed invocations is a workaround.
   1.438 -  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
   1.439 -    sed -e 's/$/ :/' >> "$depfile"
   1.440 +  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
   1.441 +    | sed -e 's/$/ :/' >> "$depfile"
   1.442    rm -f "$tmpdepfile"
   1.443    ;;
   1.444  
   1.445 @@ -414,9 +439,8 @@
   1.446    # 'foo.d', which lands next to the object file, wherever that
   1.447    # happens to be.
   1.448    # Much of this is similar to the tru64 case; see comments there.
   1.449 -  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
   1.450 -  test "x$dir" = "x$object" && dir=
   1.451 -  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
   1.452 +  set_dir_from  "$object"
   1.453 +  set_base_from "$object"
   1.454    if test "$libtool" = yes; then
   1.455      tmpdepfile1=$dir$base.d
   1.456      tmpdepfile2=$dir.libs/$base.d
   1.457 @@ -427,8 +451,7 @@
   1.458      "$@" +Maked
   1.459    fi
   1.460    stat=$?
   1.461 -  if test $stat -eq 0; then :
   1.462 -  else
   1.463 +  if test $stat -ne 0; then
   1.464       rm -f "$tmpdepfile1" "$tmpdepfile2"
   1.465       exit $stat
   1.466    fi
   1.467 @@ -438,76 +461,61 @@
   1.468      test -f "$tmpdepfile" && break
   1.469    done
   1.470    if test -f "$tmpdepfile"; then
   1.471 -    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
   1.472 +    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
   1.473      # Add 'dependent.h:' lines.
   1.474      sed -ne '2,${
   1.475 -	       s/^ *//
   1.476 -	       s/ \\*$//
   1.477 -	       s/$/:/
   1.478 -	       p
   1.479 -	     }' "$tmpdepfile" >> "$depfile"
   1.480 +               s/^ *//
   1.481 +               s/ \\*$//
   1.482 +               s/$/:/
   1.483 +               p
   1.484 +             }' "$tmpdepfile" >> "$depfile"
   1.485    else
   1.486 -    echo "#dummy" > "$depfile"
   1.487 +    make_dummy_depfile
   1.488    fi
   1.489    rm -f "$tmpdepfile" "$tmpdepfile2"
   1.490    ;;
   1.491  
   1.492  tru64)
   1.493 -   # The Tru64 compiler uses -MD to generate dependencies as a side
   1.494 -   # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
   1.495 -   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
   1.496 -   # dependencies in 'foo.d' instead, so we check for that too.
   1.497 -   # Subdirectories are respected.
   1.498 -   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
   1.499 -   test "x$dir" = "x$object" && dir=
   1.500 -   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
   1.501 +  # The Tru64 compiler uses -MD to generate dependencies as a side
   1.502 +  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
   1.503 +  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
   1.504 +  # dependencies in 'foo.d' instead, so we check for that too.
   1.505 +  # Subdirectories are respected.
   1.506 +  set_dir_from  "$object"
   1.507 +  set_base_from "$object"
   1.508  
   1.509 -   if test "$libtool" = yes; then
   1.510 -      # With Tru64 cc, shared objects can also be used to make a
   1.511 -      # static library.  This mechanism is used in libtool 1.4 series to
   1.512 -      # handle both shared and static libraries in a single compilation.
   1.513 -      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
   1.514 -      #
   1.515 -      # With libtool 1.5 this exception was removed, and libtool now
   1.516 -      # generates 2 separate objects for the 2 libraries.  These two
   1.517 -      # compilations output dependencies in $dir.libs/$base.o.d and
   1.518 -      # in $dir$base.o.d.  We have to check for both files, because
   1.519 -      # one of the two compilations can be disabled.  We should prefer
   1.520 -      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
   1.521 -      # automatically cleaned when .libs/ is deleted, while ignoring
   1.522 -      # the former would cause a distcleancheck panic.
   1.523 -      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
   1.524 -      tmpdepfile2=$dir$base.o.d          # libtool 1.5
   1.525 -      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
   1.526 -      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
   1.527 -      "$@" -Wc,-MD
   1.528 -   else
   1.529 -      tmpdepfile1=$dir$base.o.d
   1.530 -      tmpdepfile2=$dir$base.d
   1.531 -      tmpdepfile3=$dir$base.d
   1.532 -      tmpdepfile4=$dir$base.d
   1.533 -      "$@" -MD
   1.534 -   fi
   1.535 +  if test "$libtool" = yes; then
   1.536 +    # Libtool generates 2 separate objects for the 2 libraries.  These
   1.537 +    # two compilations output dependencies in $dir.libs/$base.o.d and
   1.538 +    # in $dir$base.o.d.  We have to check for both files, because
   1.539 +    # one of the two compilations can be disabled.  We should prefer
   1.540 +    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
   1.541 +    # automatically cleaned when .libs/ is deleted, while ignoring
   1.542 +    # the former would cause a distcleancheck panic.
   1.543 +    tmpdepfile1=$dir$base.o.d          # libtool 1.5
   1.544 +    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
   1.545 +    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
   1.546 +    "$@" -Wc,-MD
   1.547 +  else
   1.548 +    tmpdepfile1=$dir$base.d
   1.549 +    tmpdepfile2=$dir$base.d
   1.550 +    tmpdepfile3=$dir$base.d
   1.551 +    "$@" -MD
   1.552 +  fi
   1.553  
   1.554 -   stat=$?
   1.555 -   if test $stat -eq 0; then :
   1.556 -   else
   1.557 -      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
   1.558 -      exit $stat
   1.559 -   fi
   1.560 +  stat=$?
   1.561 +  if test $stat -ne 0; then
   1.562 +    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
   1.563 +    exit $stat
   1.564 +  fi
   1.565  
   1.566 -   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
   1.567 -   do
   1.568 -     test -f "$tmpdepfile" && break
   1.569 -   done
   1.570 -   if test -f "$tmpdepfile"; then
   1.571 -      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
   1.572 -      sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
   1.573 -   else
   1.574 -      echo "#dummy" > "$depfile"
   1.575 -   fi
   1.576 -   rm -f "$tmpdepfile"
   1.577 -   ;;
   1.578 +  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
   1.579 +  do
   1.580 +    test -f "$tmpdepfile" && break
   1.581 +  done
   1.582 +  # Same post-processing that is required for AIX mode.
   1.583 +  aix_post_process_depfile
   1.584 +  ;;
   1.585  
   1.586  msvc7)
   1.587    if test "$libtool" = yes; then
   1.588 @@ -518,8 +526,7 @@
   1.589    "$@" $showIncludes > "$tmpdepfile"
   1.590    stat=$?
   1.591    grep -v '^Note: including file: ' "$tmpdepfile"
   1.592 -  if test "$stat" = 0; then :
   1.593 -  else
   1.594 +  if test $stat -ne 0; then
   1.595      rm -f "$tmpdepfile"
   1.596      exit $stat
   1.597    fi
   1.598 @@ -545,6 +552,7 @@
   1.599    G
   1.600    p
   1.601  }' >> "$depfile"
   1.602 +  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
   1.603    rm -f "$tmpdepfile"
   1.604    ;;
   1.605  
   1.606 @@ -596,13 +604,14 @@
   1.607    # in the target name.  This is to cope with DOS-style filenames:
   1.608    # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
   1.609    "$@" $dashmflag |
   1.610 -    sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
   1.611 +    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
   1.612    rm -f "$depfile"
   1.613    cat < "$tmpdepfile" > "$depfile"
   1.614 -  tr ' ' "$nl" < "$tmpdepfile" | \
   1.615 -## Some versions of the HPUX 10.20 sed can't process this invocation
   1.616 -## correctly.  Breaking it into two sed invocations is a workaround.
   1.617 -    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
   1.618 +  # Some versions of the HPUX 10.20 sed can't process this sed invocation
   1.619 +  # correctly.  Breaking it into two sed invocations is a workaround.
   1.620 +  tr ' ' "$nl" < "$tmpdepfile" \
   1.621 +    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
   1.622 +    | sed -e 's/$/ :/' >> "$depfile"
   1.623    rm -f "$tmpdepfile"
   1.624    ;;
   1.625  
   1.626 @@ -655,10 +664,12 @@
   1.627    # makedepend may prepend the VPATH from the source file name to the object.
   1.628    # No need to regex-escape $object, excess matching of '.' is harmless.
   1.629    sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
   1.630 -  sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
   1.631 -## Some versions of the HPUX 10.20 sed can't process this invocation
   1.632 -## correctly.  Breaking it into two sed invocations is a workaround.
   1.633 -    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
   1.634 +  # Some versions of the HPUX 10.20 sed can't process the last invocation
   1.635 +  # correctly.  Breaking it into two sed invocations is a workaround.
   1.636 +  sed '1,2d' "$tmpdepfile" \
   1.637 +    | tr ' ' "$nl" \
   1.638 +    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
   1.639 +    | sed -e 's/$/ :/' >> "$depfile"
   1.640    rm -f "$tmpdepfile" "$tmpdepfile".bak
   1.641    ;;
   1.642  
   1.643 @@ -694,10 +705,10 @@
   1.644      esac
   1.645    done
   1.646  
   1.647 -  "$@" -E |
   1.648 -    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
   1.649 -       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
   1.650 -    sed '$ s: \\$::' > "$tmpdepfile"
   1.651 +  "$@" -E \
   1.652 +    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
   1.653 +             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
   1.654 +    | sed '$ s: \\$::' > "$tmpdepfile"
   1.655    rm -f "$depfile"
   1.656    echo "$object : \\" > "$depfile"
   1.657    cat < "$tmpdepfile" >> "$depfile"
   1.658 @@ -729,15 +740,15 @@
   1.659        shift
   1.660        ;;
   1.661      "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
   1.662 -	set fnord "$@"
   1.663 -	shift
   1.664 -	shift
   1.665 -	;;
   1.666 +        set fnord "$@"
   1.667 +        shift
   1.668 +        shift
   1.669 +        ;;
   1.670      *)
   1.671 -	set fnord "$@" "$arg"
   1.672 -	shift
   1.673 -	shift
   1.674 -	;;
   1.675 +        set fnord "$@" "$arg"
   1.676 +        shift
   1.677 +        shift
   1.678 +        ;;
   1.679      esac
   1.680    done
   1.681    "$@" -E 2>/dev/null |
   1.682 @@ -775,6 +786,6 @@
   1.683  # eval: (add-hook 'write-file-hooks 'time-stamp)
   1.684  # time-stamp-start: "scriptversion="
   1.685  # time-stamp-format: "%:y-%02m-%02d.%02H"
   1.686 -# time-stamp-time-zone: "UTC"
   1.687 +# time-stamp-time-zone: "UTC0"
   1.688  # time-stamp-end: "; # UTC"
   1.689  # End: