Blame depcomp

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