Blame depcomp

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