Blame depcomp

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