Blame depcomp

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