Blame depcomp

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