Blame depcomp

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