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