Blame depcomp

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