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