Blame depcomp

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