Blame build-aux/depcomp

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