Blame depcomp

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