Blame depcomp

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