Blame build-aux/depcomp

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