Blame build-aux/depcomp

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