Blame depcomp

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