csomh / source-git / rpm

Forked from source-git/rpm 4 years ago
Clone
2ff057
#! /bin/sh
2ff057
# depcomp - compile a program generating dependencies as side-effects
2ff057
2ff057
scriptversion=2013-05-30.07; # UTC
2ff057
2ff057
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
2ff057
2ff057
# This program is free software; you can redistribute it and/or modify
2ff057
# it under the terms of the GNU General Public License as published by
2ff057
# the Free Software Foundation; either version 2, or (at your option)
2ff057
# any later version.
2ff057
2ff057
# This program is distributed in the hope that it will be useful,
2ff057
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2ff057
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2ff057
# GNU General Public License for more details.
2ff057
2ff057
# You should have received a copy of the GNU General Public License
2ff057
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2ff057
2ff057
# As a special exception to the GNU General Public License, if you
2ff057
# distribute this file as part of a program that contains a
2ff057
# configuration script generated by Autoconf, you may include it under
2ff057
# the same distribution terms that you use for the rest of that program.
2ff057
2ff057
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2ff057
2ff057
case $1 in
2ff057
  '')
2ff057
    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
2ff057
    exit 1;
2ff057
    ;;
2ff057
  -h | --h*)
2ff057
    cat <<\EOF
2ff057
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
2ff057
2ff057
Run PROGRAMS ARGS to compile a file, generating dependencies
2ff057
as side-effects.
2ff057
2ff057
Environment variables:
2ff057
  depmode     Dependency tracking mode.
2ff057
  source      Source file read by 'PROGRAMS ARGS'.
2ff057
  object      Object file output by 'PROGRAMS ARGS'.
2ff057
  DEPDIR      directory where to store dependencies.
2ff057
  depfile     Dependency file to output.
2ff057
  tmpdepfile  Temporary file to use when outputting dependencies.
2ff057
  libtool     Whether libtool is used (yes/no).
2ff057
2ff057
Report bugs to <bug-automake@gnu.org>.
2ff057
EOF
2ff057
    exit $?
2ff057
    ;;
2ff057
  -v | --v*)
2ff057
    echo "depcomp $scriptversion"
2ff057
    exit $?
2ff057
    ;;
2ff057
esac
2ff057
2ff057
# Get the directory component of the given path, and save it in the
2ff057
# global variables '$dir'.  Note that this directory component will
2ff057
# be either empty or ending with a '/' character.  This is deliberate.
2ff057
set_dir_from ()
2ff057
{
2ff057
  case $1 in
2ff057
    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
2ff057
      *) dir=;;
2ff057
  esac
2ff057
}
2ff057
2ff057
# Get the suffix-stripped basename of the given path, and save it the
2ff057
# global variable '$base'.
2ff057
set_base_from ()
2ff057
{
2ff057
  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
2ff057
}
2ff057
2ff057
# If no dependency file was actually created by the compiler invocation,
2ff057
# we still have to create a dummy depfile, to avoid errors with the
2ff057
# Makefile "include basename.Plo" scheme.
2ff057
make_dummy_depfile ()
2ff057
{
2ff057
  echo "#dummy" > "$depfile"
2ff057
}
2ff057
2ff057
# Factor out some common post-processing of the generated depfile.
2ff057
# Requires the auxiliary global variable '$tmpdepfile' to be set.
2ff057
aix_post_process_depfile ()
2ff057
{
2ff057
  # If the compiler actually managed to produce a dependency file,
2ff057
  # post-process it.
2ff057
  if test -f "$tmpdepfile"; then
2ff057
    # Each line is of the form 'foo.o: dependency.h'.
2ff057
    # Do two passes, one to just change these to
2ff057
    #   $object: dependency.h
2ff057
    # and one to simply output
2ff057
    #   dependency.h:
2ff057
    # which is needed to avoid the deleted-header problem.
2ff057
    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
2ff057
      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
2ff057
    } > "$depfile"
2ff057
    rm -f "$tmpdepfile"
2ff057
  else
2ff057
    make_dummy_depfile
2ff057
  fi
2ff057
}
2ff057
2ff057
# A tabulation character.
2ff057
tab='	'
2ff057
# A newline character.
2ff057
nl='
2ff057
'
2ff057
# Character ranges might be problematic outside the C locale.
2ff057
# These definitions help.
2ff057
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
2ff057
lower=abcdefghijklmnopqrstuvwxyz
2ff057
digits=0123456789
2ff057
alpha=${upper}${lower}
2ff057
2ff057
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
2ff057
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
2ff057
  exit 1
2ff057
fi
2ff057
2ff057
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
2ff057
depfile=${depfile-`echo "$object" |
2ff057
  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
2ff057
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
2ff057
2ff057
rm -f "$tmpdepfile"
2ff057
2ff057
# Avoid interferences from the environment.
2ff057
gccflag= dashmflag=
2ff057
2ff057
# Some modes work just like other modes, but use different flags.  We
2ff057
# parameterize here, but still list the modes in the big case below,
2ff057
# to make depend.m4 easier to write.  Note that we *cannot* use a case
2ff057
# here, because this file can only contain one case statement.
2ff057
if test "$depmode" = hp; then
2ff057
  # HP compiler uses -M and no extra arg.
2ff057
  gccflag=-M
2ff057
  depmode=gcc
2ff057
fi
2ff057
2ff057
if test "$depmode" = dashXmstdout; then
2ff057
  # This is just like dashmstdout with a different argument.
2ff057
  dashmflag=-xM
2ff057
  depmode=dashmstdout
2ff057
fi
2ff057
2ff057
cygpath_u="cygpath -u -f -"
2ff057
if test "$depmode" = msvcmsys; then
2ff057
  # This is just like msvisualcpp but w/o cygpath translation.
2ff057
  # Just convert the backslash-escaped backslashes to single forward
2ff057
  # slashes to satisfy depend.m4
2ff057
  cygpath_u='sed s,\\\\,/,g'
2ff057
  depmode=msvisualcpp
2ff057
fi
2ff057
2ff057
if test "$depmode" = msvc7msys; then
2ff057
  # This is just like msvc7 but w/o cygpath translation.
2ff057
  # Just convert the backslash-escaped backslashes to single forward
2ff057
  # slashes to satisfy depend.m4
2ff057
  cygpath_u='sed s,\\\\,/,g'
2ff057
  depmode=msvc7
2ff057
fi
2ff057
2ff057
if test "$depmode" = xlc; then
2ff057
  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
2ff057
  gccflag=-qmakedep=gcc,-MF
2ff057
  depmode=gcc
2ff057
fi
2ff057
2ff057
case "$depmode" in
2ff057
gcc3)
2ff057
## gcc 3 implements dependency tracking that does exactly what
2ff057
## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
2ff057
## it if -MD -MP comes after the -MF stuff.  Hmm.
2ff057
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
2ff057
## the command line argument order; so add the flags where they
2ff057
## appear in depend2.am.  Note that the slowdown incurred here
2ff057
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
2ff057
  for arg
2ff057
  do
2ff057
    case $arg in
2ff057
    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
2ff057
    *)  set fnord "$@" "$arg" ;;
2ff057
    esac
2ff057
    shift # fnord
2ff057
    shift # $arg
2ff057
  done
2ff057
  "$@"
2ff057
  stat=$?
2ff057
  if test $stat -ne 0; then
2ff057
    rm -f "$tmpdepfile"
2ff057
    exit $stat
2ff057
  fi
2ff057
  mv "$tmpdepfile" "$depfile"
2ff057
  ;;
2ff057
2ff057
gcc)
2ff057
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
2ff057
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
2ff057
## (see the conditional assignment to $gccflag above).
2ff057
## There are various ways to get dependency output from gcc.  Here's
2ff057
## why we pick this rather obscure method:
2ff057
## - Don't want to use -MD because we'd like the dependencies to end
2ff057
##   up in a subdir.  Having to rename by hand is ugly.
2ff057
##   (We might end up doing this anyway to support other compilers.)
2ff057
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
2ff057
##   -MM, not -M (despite what the docs say).  Also, it might not be
2ff057
##   supported by the other compilers which use the 'gcc' depmode.
2ff057
## - Using -M directly means running the compiler twice (even worse
2ff057
##   than renaming).
2ff057
  if test -z "$gccflag"; then
2ff057
    gccflag=-MD,
2ff057
  fi
2ff057
  "$@" -Wp,"$gccflag$tmpdepfile"
2ff057
  stat=$?
2ff057
  if test $stat -ne 0; then
2ff057
    rm -f "$tmpdepfile"
2ff057
    exit $stat
2ff057
  fi
2ff057
  rm -f "$depfile"
2ff057
  echo "$object : \\" > "$depfile"
2ff057
  # The second -e expression handles DOS-style file names with drive
2ff057
  # letters.
2ff057
  sed -e 's/^[^:]*: / /' \
2ff057
      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
2ff057
## This next piece of magic avoids the "deleted header file" problem.
2ff057
## The problem is that when a header file which appears in a .P file
2ff057
## is deleted, the dependency causes make to die (because there is
2ff057
## typically no way to rebuild the header).  We avoid this by adding
2ff057
## dummy dependencies for each header file.  Too bad gcc doesn't do
2ff057
## this for us directly.
2ff057
## Some versions of gcc put a space before the ':'.  On the theory
2ff057
## that the space means something, we add a space to the output as
2ff057
## well.  hp depmode also adds that space, but also prefixes the VPATH
2ff057
## to the object.  Take care to not repeat it in the output.
2ff057
## Some versions of the HPUX 10.20 sed can't process this invocation
2ff057
## correctly.  Breaking it into two sed invocations is a workaround.
2ff057
  tr ' ' "$nl" < "$tmpdepfile" \
2ff057
    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
2ff057
    | sed -e 's/$/ :/' >> "$depfile"
2ff057
  rm -f "$tmpdepfile"
2ff057
  ;;
2ff057
2ff057
hp)
2ff057
  # This case exists only to let depend.m4 do its work.  It works by
2ff057
  # looking at the text of this script.  This case will never be run,
2ff057
  # since it is checked for above.
2ff057
  exit 1
2ff057
  ;;
2ff057
2ff057
sgi)
2ff057
  if test "$libtool" = yes; then
2ff057
    "$@" "-Wp,-MDupdate,$tmpdepfile"
2ff057
  else
2ff057
    "$@" -MDupdate "$tmpdepfile"
2ff057
  fi
2ff057
  stat=$?
2ff057
  if test $stat -ne 0; then
2ff057
    rm -f "$tmpdepfile"
2ff057
    exit $stat
2ff057
  fi
2ff057
  rm -f "$depfile"
2ff057
2ff057
  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
2ff057
    echo "$object : \\" > "$depfile"
2ff057
    # Clip off the initial element (the dependent).  Don't try to be
2ff057
    # clever and replace this with sed code, as IRIX sed won't handle
2ff057
    # lines with more than a fixed number of characters (4096 in
2ff057
    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
2ff057
    # the IRIX cc adds comments like '#:fec' to the end of the
2ff057
    # dependency line.
2ff057
    tr ' ' "$nl" < "$tmpdepfile" \
2ff057
      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
2ff057
      | tr "$nl" ' ' >> "$depfile"
2ff057
    echo >> "$depfile"
2ff057
    # The second pass generates a dummy entry for each header file.
2ff057
    tr ' ' "$nl" < "$tmpdepfile" \
2ff057
      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2ff057
      >> "$depfile"
2ff057
  else
2ff057
    make_dummy_depfile
2ff057
  fi
2ff057
  rm -f "$tmpdepfile"
2ff057
  ;;
2ff057
2ff057
xlc)
2ff057
  # This case exists only to let depend.m4 do its work.  It works by
2ff057
  # looking at the text of this script.  This case will never be run,
2ff057
  # since it is checked for above.
2ff057
  exit 1
2ff057
  ;;
2ff057
2ff057
aix)
2ff057
  # The C for AIX Compiler uses -M and outputs the dependencies
2ff057
  # in a .u file.  In older versions, this file always lives in the
2ff057
  # current directory.  Also, the AIX compiler puts '$object:' at the
2ff057
  # start of each line; $object doesn't have directory information.
2ff057
  # Version 6 uses the directory in both cases.
2ff057
  set_dir_from "$object"
2ff057
  set_base_from "$object"
2ff057
  if test "$libtool" = yes; then
2ff057
    tmpdepfile1=$dir$base.u
2ff057
    tmpdepfile2=$base.u
2ff057
    tmpdepfile3=$dir.libs/$base.u
2ff057
    "$@" -Wc,-M
2ff057
  else
2ff057
    tmpdepfile1=$dir$base.u
2ff057
    tmpdepfile2=$dir$base.u
2ff057
    tmpdepfile3=$dir$base.u
2ff057
    "$@" -M
2ff057
  fi
2ff057
  stat=$?
2ff057
  if test $stat -ne 0; then
2ff057
    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2ff057
    exit $stat
2ff057
  fi
2ff057
2ff057
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2ff057
  do
2ff057
    test -f "$tmpdepfile" && break
2ff057
  done
2ff057
  aix_post_process_depfile
2ff057
  ;;
2ff057
2ff057
tcc)
2ff057
  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
2ff057
  # FIXME: That version still under development at the moment of writing.
2ff057
  #        Make that this statement remains true also for stable, released
2ff057
  #        versions.
2ff057
  # It will wrap lines (doesn't matter whether long or short) with a
2ff057
  # trailing '\', as in:
2ff057
  #
2ff057
  #   foo.o : \
2ff057
  #    foo.c \
2ff057
  #    foo.h \
2ff057
  #
2ff057
  # It will put a trailing '\' even on the last line, and will use leading
2ff057
  # spaces rather than leading tabs (at least since its commit 0394caf7
2ff057
  # "Emit spaces for -MD").
2ff057
  "$@" -MD -MF "$tmpdepfile"
2ff057
  stat=$?
2ff057
  if test $stat -ne 0; then
2ff057
    rm -f "$tmpdepfile"
2ff057
    exit $stat
2ff057
  fi
2ff057
  rm -f "$depfile"
2ff057
  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
2ff057
  # We have to change lines of the first kind to '$object: \'.
2ff057
  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
2ff057
  # And for each line of the second kind, we have to emit a 'dep.h:'
2ff057
  # dummy dependency, to avoid the deleted-header problem.
2ff057
  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
2ff057
  rm -f "$tmpdepfile"
2ff057
  ;;
2ff057
2ff057
## The order of this option in the case statement is important, since the
2ff057
## shell code in configure will try each of these formats in the order
2ff057
## listed in this file.  A plain '-MD' option would be understood by many
2ff057
## compilers, so we must ensure this comes after the gcc and icc options.
2ff057
pgcc)
2ff057
  # Portland's C compiler understands '-MD'.
2ff057
  # Will always output deps to 'file.d' where file is the root name of the
2ff057
  # source file under compilation, even if file resides in a subdirectory.
2ff057
  # The object file name does not affect the name of the '.d' file.
2ff057
  # pgcc 10.2 will output
2ff057
  #    foo.o: sub/foo.c sub/foo.h
2ff057
  # and will wrap long lines using '\' :
2ff057
  #    foo.o: sub/foo.c ... \
2ff057
  #     sub/foo.h ... \
2ff057
  #     ...
2ff057
  set_dir_from "$object"
2ff057
  # Use the source, not the object, to determine the base name, since
2ff057
  # that's sadly what pgcc will do too.
2ff057
  set_base_from "$source"
2ff057
  tmpdepfile=$base.d
2ff057
2ff057
  # For projects that build the same source file twice into different object
2ff057
  # files, the pgcc approach of using the *source* file root name can cause
2ff057
  # problems in parallel builds.  Use a locking strategy to avoid stomping on
2ff057
  # the same $tmpdepfile.
2ff057
  lockdir=$base.d-lock
2ff057
  trap "
2ff057
    echo '$0: caught signal, cleaning up...' >&2
2ff057
    rmdir '$lockdir'
2ff057
    exit 1
2ff057
  " 1 2 13 15
2ff057
  numtries=100
2ff057
  i=$numtries
2ff057
  while test $i -gt 0; do
2ff057
    # mkdir is a portable test-and-set.
2ff057
    if mkdir "$lockdir" 2>/dev/null; then
2ff057
      # This process acquired the lock.
2ff057
      "$@" -MD
2ff057
      stat=$?
2ff057
      # Release the lock.
2ff057
      rmdir "$lockdir"
2ff057
      break
2ff057
    else
2ff057
      # If the lock is being held by a different process, wait
2ff057
      # until the winning process is done or we timeout.
2ff057
      while test -d "$lockdir" && test $i -gt 0; do
2ff057
        sleep 1
2ff057
        i=`expr $i - 1`
2ff057
      done
2ff057
    fi
2ff057
    i=`expr $i - 1`
2ff057
  done
2ff057
  trap - 1 2 13 15
2ff057
  if test $i -le 0; then
2ff057
    echo "$0: failed to acquire lock after $numtries attempts" >&2
2ff057
    echo "$0: check lockdir '$lockdir'" >&2
2ff057
    exit 1
2ff057
  fi
2ff057
2ff057
  if test $stat -ne 0; then
2ff057
    rm -f "$tmpdepfile"
2ff057
    exit $stat
2ff057
  fi
2ff057
  rm -f "$depfile"
2ff057
  # Each line is of the form `foo.o: dependent.h',
2ff057
  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2ff057
  # Do two passes, one to just change these to
2ff057
  # `$object: dependent.h' and one to simply `dependent.h:'.
2ff057
  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2ff057
  # Some versions of the HPUX 10.20 sed can't process this invocation
2ff057
  # correctly.  Breaking it into two sed invocations is a workaround.
2ff057
  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
2ff057
    | sed -e 's/$/ :/' >> "$depfile"
2ff057
  rm -f "$tmpdepfile"
2ff057
  ;;
2ff057
2ff057
hp2)
2ff057
  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
2ff057
  # compilers, which have integrated preprocessors.  The correct option
2ff057
  # to use with these is +Maked; it writes dependencies to a file named
2ff057
  # 'foo.d', which lands next to the object file, wherever that
2ff057
  # happens to be.
2ff057
  # Much of this is similar to the tru64 case; see comments there.
2ff057
  set_dir_from  "$object"
2ff057
  set_base_from "$object"
2ff057
  if test "$libtool" = yes; then
2ff057
    tmpdepfile1=$dir$base.d
2ff057
    tmpdepfile2=$dir.libs/$base.d
2ff057
    "$@" -Wc,+Maked
2ff057
  else
2ff057
    tmpdepfile1=$dir$base.d
2ff057
    tmpdepfile2=$dir$base.d
2ff057
    "$@" +Maked
2ff057
  fi
2ff057
  stat=$?
2ff057
  if test $stat -ne 0; then
2ff057
     rm -f "$tmpdepfile1" "$tmpdepfile2"
2ff057
     exit $stat
2ff057
  fi
2ff057
2ff057
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
2ff057
  do
2ff057
    test -f "$tmpdepfile" && break
2ff057
  done
2ff057
  if test -f "$tmpdepfile"; then
2ff057
    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
2ff057
    # Add 'dependent.h:' lines.
2ff057
    sed -ne '2,${
2ff057
               s/^ *//
2ff057
               s/ \\*$//
2ff057
               s/$/:/
2ff057
               p
2ff057
             }' "$tmpdepfile" >> "$depfile"
2ff057
  else
2ff057
    make_dummy_depfile
2ff057
  fi
2ff057
  rm -f "$tmpdepfile" "$tmpdepfile2"
2ff057
  ;;
2ff057
2ff057
tru64)
2ff057
  # The Tru64 compiler uses -MD to generate dependencies as a side
2ff057
  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
2ff057
  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
2ff057
  # dependencies in 'foo.d' instead, so we check for that too.
2ff057
  # Subdirectories are respected.
2ff057
  set_dir_from  "$object"
2ff057
  set_base_from "$object"
2ff057
2ff057
  if test "$libtool" = yes; then
2ff057
    # Libtool generates 2 separate objects for the 2 libraries.  These
2ff057
    # two compilations output dependencies in $dir.libs/$base.o.d and
2ff057
    # in $dir$base.o.d.  We have to check for both files, because
2ff057
    # one of the two compilations can be disabled.  We should prefer
2ff057
    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
2ff057
    # automatically cleaned when .libs/ is deleted, while ignoring
2ff057
    # the former would cause a distcleancheck panic.
2ff057
    tmpdepfile1=$dir$base.o.d          # libtool 1.5
2ff057
    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
2ff057
    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
2ff057
    "$@" -Wc,-MD
2ff057
  else
2ff057
    tmpdepfile1=$dir$base.d
2ff057
    tmpdepfile2=$dir$base.d
2ff057
    tmpdepfile3=$dir$base.d
2ff057
    "$@" -MD
2ff057
  fi
2ff057
2ff057
  stat=$?
2ff057
  if test $stat -ne 0; then
2ff057
    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2ff057
    exit $stat
2ff057
  fi
2ff057
2ff057
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2ff057
  do
2ff057
    test -f "$tmpdepfile" && break
2ff057
  done
2ff057
  # Same post-processing that is required for AIX mode.
2ff057
  aix_post_process_depfile
2ff057
  ;;
2ff057
2ff057
msvc7)
2ff057
  if test "$libtool" = yes; then
2ff057
    showIncludes=-Wc,-showIncludes
2ff057
  else
2ff057
    showIncludes=-showIncludes
2ff057
  fi
2ff057
  "$@" $showIncludes > "$tmpdepfile"
2ff057
  stat=$?
2ff057
  grep -v '^Note: including file: ' "$tmpdepfile"
2ff057
  if test $stat -ne 0; then
2ff057
    rm -f "$tmpdepfile"
2ff057
    exit $stat
2ff057
  fi
2ff057
  rm -f "$depfile"
2ff057
  echo "$object : \\" > "$depfile"
2ff057
  # The first sed program below extracts the file names and escapes
2ff057
  # backslashes for cygpath.  The second sed program outputs the file
2ff057
  # name when reading, but also accumulates all include files in the
2ff057
  # hold buffer in order to output them again at the end.  This only
2ff057
  # works with sed implementations that can handle large buffers.
2ff057
  sed < "$tmpdepfile" -n '
2ff057
/^Note: including file:  *\(.*\)/ {
2ff057
  s//\1/
2ff057
  s/\\/\\\\/g
2ff057
  p
2ff057
}' | $cygpath_u | sort -u | sed -n '
2ff057
s/ /\\ /g
2ff057
s/\(.*\)/'"$tab"'\1 \\/p
2ff057
s/.\(.*\) \\/\1:/
2ff057
H
2ff057
$ {
2ff057
  s/.*/'"$tab"'/
2ff057
  G
2ff057
  p
2ff057
}' >> "$depfile"
2ff057
  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
2ff057
  rm -f "$tmpdepfile"
2ff057
  ;;
2ff057
2ff057
msvc7msys)
2ff057
  # This case exists only to let depend.m4 do its work.  It works by
2ff057
  # looking at the text of this script.  This case will never be run,
2ff057
  # since it is checked for above.
2ff057
  exit 1
2ff057
  ;;
2ff057
2ff057
#nosideeffect)
2ff057
  # This comment above is used by automake to tell side-effect
2ff057
  # dependency tracking mechanisms from slower ones.
2ff057
2ff057
dashmstdout)
2ff057
  # Important note: in order to support this mode, a compiler *must*
2ff057
  # always write the preprocessed file to stdout, regardless of -o.
2ff057
  "$@" || exit $?
2ff057
2ff057
  # Remove the call to Libtool.
2ff057
  if test "$libtool" = yes; then
2ff057
    while test "X$1" != 'X--mode=compile'; do
2ff057
      shift
2ff057
    done
2ff057
    shift
2ff057
  fi
2ff057
2ff057
  # Remove '-o $object'.
2ff057
  IFS=" "
2ff057
  for arg
2ff057
  do
2ff057
    case $arg in
2ff057
    -o)
2ff057
      shift
2ff057
      ;;
2ff057
    $object)
2ff057
      shift
2ff057
      ;;
2ff057
    *)
2ff057
      set fnord "$@" "$arg"
2ff057
      shift # fnord
2ff057
      shift # $arg
2ff057
      ;;
2ff057
    esac
2ff057
  done
2ff057
2ff057
  test -z "$dashmflag" && dashmflag=-M
2ff057
  # Require at least two characters before searching for ':'
2ff057
  # in the target name.  This is to cope with DOS-style filenames:
2ff057
  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
2ff057
  "$@" $dashmflag |
2ff057
    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
2ff057
  rm -f "$depfile"
2ff057
  cat < "$tmpdepfile" > "$depfile"
2ff057
  # Some versions of the HPUX 10.20 sed can't process this sed invocation
2ff057
  # correctly.  Breaking it into two sed invocations is a workaround.
2ff057
  tr ' ' "$nl" < "$tmpdepfile" \
2ff057
    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
2ff057
    | sed -e 's/$/ :/' >> "$depfile"
2ff057
  rm -f "$tmpdepfile"
2ff057
  ;;
2ff057
2ff057
dashXmstdout)
2ff057
  # This case only exists to satisfy depend.m4.  It is never actually
2ff057
  # run, as this mode is specially recognized in the preamble.
2ff057
  exit 1
2ff057
  ;;
2ff057
2ff057
makedepend)
2ff057
  "$@" || exit $?
2ff057
  # Remove any Libtool call
2ff057
  if test "$libtool" = yes; then
2ff057
    while test "X$1" != 'X--mode=compile'; do
2ff057
      shift
2ff057
    done
2ff057
    shift
2ff057
  fi
2ff057
  # X makedepend
2ff057
  shift
2ff057
  cleared=no eat=no
2ff057
  for arg
2ff057
  do
2ff057
    case $cleared in
2ff057
    no)
2ff057
      set ""; shift
2ff057
      cleared=yes ;;
2ff057
    esac
2ff057
    if test $eat = yes; then
2ff057
      eat=no
2ff057
      continue
2ff057
    fi
2ff057
    case "$arg" in
2ff057
    -D*|-I*)
2ff057
      set fnord "$@" "$arg"; shift ;;
2ff057
    # Strip any option that makedepend may not understand.  Remove
2ff057
    # the object too, otherwise makedepend will parse it as a source file.
2ff057
    -arch)
2ff057
      eat=yes ;;
2ff057
    -*|$object)
2ff057
      ;;
2ff057
    *)
2ff057
      set fnord "$@" "$arg"; shift ;;
2ff057
    esac
2ff057
  done
2ff057
  obj_suffix=`echo "$object" | sed 's/^.*\././'`
2ff057
  touch "$tmpdepfile"
2ff057
  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
2ff057
  rm -f "$depfile"
2ff057
  # makedepend may prepend the VPATH from the source file name to the object.
2ff057
  # No need to regex-escape $object, excess matching of '.' is harmless.
2ff057
  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
2ff057
  # Some versions of the HPUX 10.20 sed can't process the last invocation
2ff057
  # correctly.  Breaking it into two sed invocations is a workaround.
2ff057
  sed '1,2d' "$tmpdepfile" \
2ff057
    | tr ' ' "$nl" \
2ff057
    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
2ff057
    | sed -e 's/$/ :/' >> "$depfile"
2ff057
  rm -f "$tmpdepfile" "$tmpdepfile".bak
2ff057
  ;;
2ff057
2ff057
cpp)
2ff057
  # Important note: in order to support this mode, a compiler *must*
2ff057
  # always write the preprocessed file to stdout.
2ff057
  "$@" || exit $?
2ff057
2ff057
  # Remove the call to Libtool.
2ff057
  if test "$libtool" = yes; then
2ff057
    while test "X$1" != 'X--mode=compile'; do
2ff057
      shift
2ff057
    done
2ff057
    shift
2ff057
  fi
2ff057
2ff057
  # Remove '-o $object'.
2ff057
  IFS=" "
2ff057
  for arg
2ff057
  do
2ff057
    case $arg in
2ff057
    -o)
2ff057
      shift
2ff057
      ;;
2ff057
    $object)
2ff057
      shift
2ff057
      ;;
2ff057
    *)
2ff057
      set fnord "$@" "$arg"
2ff057
      shift # fnord
2ff057
      shift # $arg
2ff057
      ;;
2ff057
    esac
2ff057
  done
2ff057
2ff057
  "$@" -E \
2ff057
    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
2ff057
             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
2ff057
    | sed '$ s: \\$::' > "$tmpdepfile"
2ff057
  rm -f "$depfile"
2ff057
  echo "$object : \\" > "$depfile"
2ff057
  cat < "$tmpdepfile" >> "$depfile"
2ff057
  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
2ff057
  rm -f "$tmpdepfile"
2ff057
  ;;
2ff057
2ff057
msvisualcpp)
2ff057
  # Important note: in order to support this mode, a compiler *must*
2ff057
  # always write the preprocessed file to stdout.
2ff057
  "$@" || exit $?
2ff057
2ff057
  # Remove the call to Libtool.
2ff057
  if test "$libtool" = yes; then
2ff057
    while test "X$1" != 'X--mode=compile'; do
2ff057
      shift
2ff057
    done
2ff057
    shift
2ff057
  fi
2ff057
2ff057
  IFS=" "
2ff057
  for arg
2ff057
  do
2ff057
    case "$arg" in
2ff057
    -o)
2ff057
      shift
2ff057
      ;;
2ff057
    $object)
2ff057
      shift
2ff057
      ;;
2ff057
    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
2ff057
        set fnord "$@"
2ff057
        shift
2ff057
        shift
2ff057
        ;;
2ff057
    *)
2ff057
        set fnord "$@" "$arg"
2ff057
        shift
2ff057
        shift
2ff057
        ;;
2ff057
    esac
2ff057
  done
2ff057
  "$@" -E 2>/dev/null |
2ff057
  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
2ff057
  rm -f "$depfile"
2ff057
  echo "$object : \\" > "$depfile"
2ff057
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
2ff057
  echo "$tab" >> "$depfile"
2ff057
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
2ff057
  rm -f "$tmpdepfile"
2ff057
  ;;
2ff057
2ff057
msvcmsys)
2ff057
  # This case exists only to let depend.m4 do its work.  It works by
2ff057
  # looking at the text of this script.  This case will never be run,
2ff057
  # since it is checked for above.
2ff057
  exit 1
2ff057
  ;;
2ff057
2ff057
none)
2ff057
  exec "$@"
2ff057
  ;;
2ff057
2ff057
*)
2ff057
  echo "Unknown depmode $depmode" 1>&2
2ff057
  exit 1
2ff057
  ;;
2ff057
esac
2ff057
2ff057
exit 0
2ff057
2ff057
# Local Variables:
2ff057
# mode: shell-script
2ff057
# sh-indentation: 2
2ff057
# eval: (add-hook 'write-file-hooks 'time-stamp)
2ff057
# time-stamp-start: "scriptversion="
2ff057
# time-stamp-format: "%:y-%02m-%02d.%02H"
2ff057
# time-stamp-time-zone: "UTC"
2ff057
# time-stamp-end: "; # UTC"
2ff057
# End: