Blame depcomp

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