Blame depcomp

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