depcomp revision 86dafe34
176888252Smrg#! /bin/sh
276888252Smrg# depcomp - compile a program generating dependencies as side-effects
376888252Smrg
486dafe34Smrgscriptversion=2007-03-29.01
576888252Smrg
686dafe34Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
71ae1b5e8Smrg# Foundation, Inc.
876888252Smrg
976888252Smrg# This program is free software; you can redistribute it and/or modify
1076888252Smrg# it under the terms of the GNU General Public License as published by
1176888252Smrg# the Free Software Foundation; either version 2, or (at your option)
1276888252Smrg# any later version.
1376888252Smrg
1476888252Smrg# This program is distributed in the hope that it will be useful,
1576888252Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1676888252Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1776888252Smrg# GNU General Public License for more details.
1876888252Smrg
1976888252Smrg# You should have received a copy of the GNU General Public License
2076888252Smrg# along with this program; if not, write to the Free Software
2176888252Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2276888252Smrg# 02110-1301, USA.
2376888252Smrg
2476888252Smrg# As a special exception to the GNU General Public License, if you
2576888252Smrg# distribute this file as part of a program that contains a
2676888252Smrg# configuration script generated by Autoconf, you may include it under
2776888252Smrg# the same distribution terms that you use for the rest of that program.
2876888252Smrg
2976888252Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
3076888252Smrg
3176888252Smrgcase $1 in
3276888252Smrg  '')
3376888252Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3476888252Smrg     exit 1;
3576888252Smrg     ;;
3676888252Smrg  -h | --h*)
3776888252Smrg    cat <<\EOF
3876888252SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3976888252Smrg
4076888252SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4176888252Smrgas side-effects.
4276888252Smrg
4376888252SmrgEnvironment variables:
4476888252Smrg  depmode     Dependency tracking mode.
4576888252Smrg  source      Source file read by `PROGRAMS ARGS'.
4676888252Smrg  object      Object file output by `PROGRAMS ARGS'.
4776888252Smrg  DEPDIR      directory where to store dependencies.
4876888252Smrg  depfile     Dependency file to output.
4976888252Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
5076888252Smrg  libtool     Whether libtool is used (yes/no).
5176888252Smrg
5276888252SmrgReport bugs to <bug-automake@gnu.org>.
5376888252SmrgEOF
5476888252Smrg    exit $?
5576888252Smrg    ;;
5676888252Smrg  -v | --v*)
5776888252Smrg    echo "depcomp $scriptversion"
5876888252Smrg    exit $?
5976888252Smrg    ;;
6076888252Smrgesac
6176888252Smrg
6276888252Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6376888252Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6476888252Smrg  exit 1
6576888252Smrgfi
6676888252Smrg
6776888252Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6876888252Smrgdepfile=${depfile-`echo "$object" |
6976888252Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
7076888252Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7176888252Smrg
7276888252Smrgrm -f "$tmpdepfile"
7376888252Smrg
7476888252Smrg# Some modes work just like other modes, but use different flags.  We
7576888252Smrg# parameterize here, but still list the modes in the big case below,
7676888252Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7776888252Smrg# here, because this file can only contain one case statement.
7876888252Smrgif test "$depmode" = hp; then
7976888252Smrg  # HP compiler uses -M and no extra arg.
8076888252Smrg  gccflag=-M
8176888252Smrg  depmode=gcc
8276888252Smrgfi
8376888252Smrg
8476888252Smrgif test "$depmode" = dashXmstdout; then
8576888252Smrg   # This is just like dashmstdout with a different argument.
8676888252Smrg   dashmflag=-xM
8776888252Smrg   depmode=dashmstdout
8876888252Smrgfi
8976888252Smrg
9076888252Smrgcase "$depmode" in
9176888252Smrggcc3)
9276888252Smrg## gcc 3 implements dependency tracking that does exactly what
9376888252Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9476888252Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
951ae1b5e8Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
961ae1b5e8Smrg## the command line argument order; so add the flags where they
971ae1b5e8Smrg## appear in depend2.am.  Note that the slowdown incurred here
981ae1b5e8Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
991ae1b5e8Smrg  for arg
1001ae1b5e8Smrg  do
1011ae1b5e8Smrg    case $arg in
1021ae1b5e8Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1031ae1b5e8Smrg    *)  set fnord "$@" "$arg" ;;
1041ae1b5e8Smrg    esac
1051ae1b5e8Smrg    shift # fnord
1061ae1b5e8Smrg    shift # $arg
1071ae1b5e8Smrg  done
1081ae1b5e8Smrg  "$@"
10976888252Smrg  stat=$?
11076888252Smrg  if test $stat -eq 0; then :
11176888252Smrg  else
11276888252Smrg    rm -f "$tmpdepfile"
11376888252Smrg    exit $stat
11476888252Smrg  fi
11576888252Smrg  mv "$tmpdepfile" "$depfile"
11676888252Smrg  ;;
11776888252Smrg
11876888252Smrggcc)
11976888252Smrg## There are various ways to get dependency output from gcc.  Here's
12076888252Smrg## why we pick this rather obscure method:
12176888252Smrg## - Don't want to use -MD because we'd like the dependencies to end
12276888252Smrg##   up in a subdir.  Having to rename by hand is ugly.
12376888252Smrg##   (We might end up doing this anyway to support other compilers.)
12476888252Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
12576888252Smrg##   -MM, not -M (despite what the docs say).
12676888252Smrg## - Using -M directly means running the compiler twice (even worse
12776888252Smrg##   than renaming).
12876888252Smrg  if test -z "$gccflag"; then
12976888252Smrg    gccflag=-MD,
13076888252Smrg  fi
13176888252Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
13276888252Smrg  stat=$?
13376888252Smrg  if test $stat -eq 0; then :
13476888252Smrg  else
13576888252Smrg    rm -f "$tmpdepfile"
13676888252Smrg    exit $stat
13776888252Smrg  fi
13876888252Smrg  rm -f "$depfile"
13976888252Smrg  echo "$object : \\" > "$depfile"
14076888252Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14176888252Smrg## The second -e expression handles DOS-style file names with drive letters.
14276888252Smrg  sed -e 's/^[^:]*: / /' \
14376888252Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
14476888252Smrg## This next piece of magic avoids the `deleted header file' problem.
14576888252Smrg## The problem is that when a header file which appears in a .P file
14676888252Smrg## is deleted, the dependency causes make to die (because there is
14776888252Smrg## typically no way to rebuild the header).  We avoid this by adding
14876888252Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
14976888252Smrg## this for us directly.
15076888252Smrg  tr ' ' '
15176888252Smrg' < "$tmpdepfile" |
15276888252Smrg## Some versions of gcc put a space before the `:'.  On the theory
15376888252Smrg## that the space means something, we add a space to the output as
15476888252Smrg## well.
15576888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
15676888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
15776888252Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
15876888252Smrg  rm -f "$tmpdepfile"
15976888252Smrg  ;;
16076888252Smrg
16176888252Smrghp)
16276888252Smrg  # This case exists only to let depend.m4 do its work.  It works by
16376888252Smrg  # looking at the text of this script.  This case will never be run,
16476888252Smrg  # since it is checked for above.
16576888252Smrg  exit 1
16676888252Smrg  ;;
16776888252Smrg
16876888252Smrgsgi)
16976888252Smrg  if test "$libtool" = yes; then
17076888252Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17176888252Smrg  else
17276888252Smrg    "$@" -MDupdate "$tmpdepfile"
17376888252Smrg  fi
17476888252Smrg  stat=$?
17576888252Smrg  if test $stat -eq 0; then :
17676888252Smrg  else
17776888252Smrg    rm -f "$tmpdepfile"
17876888252Smrg    exit $stat
17976888252Smrg  fi
18076888252Smrg  rm -f "$depfile"
18176888252Smrg
18276888252Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
18376888252Smrg    echo "$object : \\" > "$depfile"
18476888252Smrg
18576888252Smrg    # Clip off the initial element (the dependent).  Don't try to be
18676888252Smrg    # clever and replace this with sed code, as IRIX sed won't handle
18776888252Smrg    # lines with more than a fixed number of characters (4096 in
18876888252Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
18976888252Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
19076888252Smrg    # dependency line.
19176888252Smrg    tr ' ' '
19276888252Smrg' < "$tmpdepfile" \
19376888252Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
19476888252Smrg    tr '
19576888252Smrg' ' ' >> $depfile
19676888252Smrg    echo >> $depfile
19776888252Smrg
19876888252Smrg    # The second pass generates a dummy entry for each header file.
19976888252Smrg    tr ' ' '
20076888252Smrg' < "$tmpdepfile" \
20176888252Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20276888252Smrg   >> $depfile
20376888252Smrg  else
20476888252Smrg    # The sourcefile does not contain any dependencies, so just
20576888252Smrg    # store a dummy comment line, to avoid errors with the Makefile
20676888252Smrg    # "include basename.Plo" scheme.
20776888252Smrg    echo "#dummy" > "$depfile"
20876888252Smrg  fi
20976888252Smrg  rm -f "$tmpdepfile"
21076888252Smrg  ;;
21176888252Smrg
21276888252Smrgaix)
21376888252Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
21476888252Smrg  # in a .u file.  In older versions, this file always lives in the
21576888252Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
21676888252Smrg  # start of each line; $object doesn't have directory information.
21776888252Smrg  # Version 6 uses the directory in both cases.
21886dafe34Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
21986dafe34Smrg  test "x$dir" = "x$object" && dir=
22086dafe34Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
22176888252Smrg  if test "$libtool" = yes; then
22286dafe34Smrg    tmpdepfile1=$dir$base.u
22386dafe34Smrg    tmpdepfile2=$base.u
22486dafe34Smrg    tmpdepfile3=$dir.libs/$base.u
22576888252Smrg    "$@" -Wc,-M
22676888252Smrg  else
22786dafe34Smrg    tmpdepfile1=$dir$base.u
22886dafe34Smrg    tmpdepfile2=$dir$base.u
22986dafe34Smrg    tmpdepfile3=$dir$base.u
23076888252Smrg    "$@" -M
23176888252Smrg  fi
23276888252Smrg  stat=$?
23376888252Smrg
23476888252Smrg  if test $stat -eq 0; then :
23576888252Smrg  else
23686dafe34Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
23776888252Smrg    exit $stat
23876888252Smrg  fi
23976888252Smrg
24086dafe34Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24186dafe34Smrg  do
24286dafe34Smrg    test -f "$tmpdepfile" && break
24386dafe34Smrg  done
24476888252Smrg  if test -f "$tmpdepfile"; then
24576888252Smrg    # Each line is of the form `foo.o: dependent.h'.
24676888252Smrg    # Do two passes, one to just change these to
24776888252Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
24886dafe34Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
24986dafe34Smrg    # That's a tab and a space in the [].
25086dafe34Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
25176888252Smrg  else
25276888252Smrg    # The sourcefile does not contain any dependencies, so just
25376888252Smrg    # store a dummy comment line, to avoid errors with the Makefile
25476888252Smrg    # "include basename.Plo" scheme.
25576888252Smrg    echo "#dummy" > "$depfile"
25676888252Smrg  fi
25776888252Smrg  rm -f "$tmpdepfile"
25876888252Smrg  ;;
25976888252Smrg
26076888252Smrgicc)
26176888252Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
26276888252Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
26376888252Smrg  # ICC 7.0 will fill foo.d with something like
26476888252Smrg  #    foo.o: sub/foo.c
26576888252Smrg  #    foo.o: sub/foo.h
26676888252Smrg  # which is wrong.  We want:
26776888252Smrg  #    sub/foo.o: sub/foo.c
26876888252Smrg  #    sub/foo.o: sub/foo.h
26976888252Smrg  #    sub/foo.c:
27076888252Smrg  #    sub/foo.h:
27176888252Smrg  # ICC 7.1 will output
27276888252Smrg  #    foo.o: sub/foo.c sub/foo.h
27376888252Smrg  # and will wrap long lines using \ :
27476888252Smrg  #    foo.o: sub/foo.c ... \
27576888252Smrg  #     sub/foo.h ... \
27676888252Smrg  #     ...
27776888252Smrg
27876888252Smrg  "$@" -MD -MF "$tmpdepfile"
27976888252Smrg  stat=$?
28076888252Smrg  if test $stat -eq 0; then :
28176888252Smrg  else
28276888252Smrg    rm -f "$tmpdepfile"
28376888252Smrg    exit $stat
28476888252Smrg  fi
28576888252Smrg  rm -f "$depfile"
28676888252Smrg  # Each line is of the form `foo.o: dependent.h',
28776888252Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
28876888252Smrg  # Do two passes, one to just change these to
28976888252Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
29076888252Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
29176888252Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
29276888252Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
29376888252Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
29476888252Smrg    sed -e 's/$/ :/' >> "$depfile"
29576888252Smrg  rm -f "$tmpdepfile"
29676888252Smrg  ;;
29776888252Smrg
2981ae1b5e8Smrghp2)
2991ae1b5e8Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3001ae1b5e8Smrg  # compilers, which have integrated preprocessors.  The correct option
3011ae1b5e8Smrg  # to use with these is +Maked; it writes dependencies to a file named
3021ae1b5e8Smrg  # 'foo.d', which lands next to the object file, wherever that
3031ae1b5e8Smrg  # happens to be.
3041ae1b5e8Smrg  # Much of this is similar to the tru64 case; see comments there.
3051ae1b5e8Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3061ae1b5e8Smrg  test "x$dir" = "x$object" && dir=
3071ae1b5e8Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3081ae1b5e8Smrg  if test "$libtool" = yes; then
3091ae1b5e8Smrg    tmpdepfile1=$dir$base.d
3101ae1b5e8Smrg    tmpdepfile2=$dir.libs/$base.d
3111ae1b5e8Smrg    "$@" -Wc,+Maked
3121ae1b5e8Smrg  else
3131ae1b5e8Smrg    tmpdepfile1=$dir$base.d
3141ae1b5e8Smrg    tmpdepfile2=$dir$base.d
3151ae1b5e8Smrg    "$@" +Maked
3161ae1b5e8Smrg  fi
3171ae1b5e8Smrg  stat=$?
3181ae1b5e8Smrg  if test $stat -eq 0; then :
3191ae1b5e8Smrg  else
3201ae1b5e8Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3211ae1b5e8Smrg     exit $stat
3221ae1b5e8Smrg  fi
3231ae1b5e8Smrg
3241ae1b5e8Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3251ae1b5e8Smrg  do
3261ae1b5e8Smrg    test -f "$tmpdepfile" && break
3271ae1b5e8Smrg  done
3281ae1b5e8Smrg  if test -f "$tmpdepfile"; then
3291ae1b5e8Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3301ae1b5e8Smrg    # Add `dependent.h:' lines.
3311ae1b5e8Smrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
3321ae1b5e8Smrg  else
3331ae1b5e8Smrg    echo "#dummy" > "$depfile"
3341ae1b5e8Smrg  fi
3351ae1b5e8Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3361ae1b5e8Smrg  ;;
3371ae1b5e8Smrg
33876888252Smrgtru64)
33976888252Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
34076888252Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
34176888252Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
34276888252Smrg   # dependencies in `foo.d' instead, so we check for that too.
34376888252Smrg   # Subdirectories are respected.
34476888252Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
34576888252Smrg   test "x$dir" = "x$object" && dir=
34676888252Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
34776888252Smrg
34876888252Smrg   if test "$libtool" = yes; then
34976888252Smrg      # With Tru64 cc, shared objects can also be used to make a
3501ae1b5e8Smrg      # static library.  This mechanism is used in libtool 1.4 series to
35176888252Smrg      # handle both shared and static libraries in a single compilation.
35276888252Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
35376888252Smrg      #
35476888252Smrg      # With libtool 1.5 this exception was removed, and libtool now
35576888252Smrg      # generates 2 separate objects for the 2 libraries.  These two
3561ae1b5e8Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
35776888252Smrg      # in $dir$base.o.d.  We have to check for both files, because
35876888252Smrg      # one of the two compilations can be disabled.  We should prefer
35976888252Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
36076888252Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
36176888252Smrg      # the former would cause a distcleancheck panic.
36276888252Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
36376888252Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
36476888252Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
36576888252Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
36676888252Smrg      "$@" -Wc,-MD
36776888252Smrg   else
36876888252Smrg      tmpdepfile1=$dir$base.o.d
36976888252Smrg      tmpdepfile2=$dir$base.d
37076888252Smrg      tmpdepfile3=$dir$base.d
37176888252Smrg      tmpdepfile4=$dir$base.d
37276888252Smrg      "$@" -MD
37376888252Smrg   fi
37476888252Smrg
37576888252Smrg   stat=$?
37676888252Smrg   if test $stat -eq 0; then :
37776888252Smrg   else
37876888252Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
37976888252Smrg      exit $stat
38076888252Smrg   fi
38176888252Smrg
38276888252Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
38376888252Smrg   do
38476888252Smrg     test -f "$tmpdepfile" && break
38576888252Smrg   done
38676888252Smrg   if test -f "$tmpdepfile"; then
38776888252Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
38876888252Smrg      # That's a tab and a space in the [].
38976888252Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
39076888252Smrg   else
39176888252Smrg      echo "#dummy" > "$depfile"
39276888252Smrg   fi
39376888252Smrg   rm -f "$tmpdepfile"
39476888252Smrg   ;;
39576888252Smrg
39676888252Smrg#nosideeffect)
39776888252Smrg  # This comment above is used by automake to tell side-effect
39876888252Smrg  # dependency tracking mechanisms from slower ones.
39976888252Smrg
40076888252Smrgdashmstdout)
40176888252Smrg  # Important note: in order to support this mode, a compiler *must*
40276888252Smrg  # always write the preprocessed file to stdout, regardless of -o.
40376888252Smrg  "$@" || exit $?
40476888252Smrg
40576888252Smrg  # Remove the call to Libtool.
40676888252Smrg  if test "$libtool" = yes; then
40776888252Smrg    while test $1 != '--mode=compile'; do
40876888252Smrg      shift
40976888252Smrg    done
41076888252Smrg    shift
41176888252Smrg  fi
41276888252Smrg
41376888252Smrg  # Remove `-o $object'.
41476888252Smrg  IFS=" "
41576888252Smrg  for arg
41676888252Smrg  do
41776888252Smrg    case $arg in
41876888252Smrg    -o)
41976888252Smrg      shift
42076888252Smrg      ;;
42176888252Smrg    $object)
42276888252Smrg      shift
42376888252Smrg      ;;
42476888252Smrg    *)
42576888252Smrg      set fnord "$@" "$arg"
42676888252Smrg      shift # fnord
42776888252Smrg      shift # $arg
42876888252Smrg      ;;
42976888252Smrg    esac
43076888252Smrg  done
43176888252Smrg
43276888252Smrg  test -z "$dashmflag" && dashmflag=-M
43376888252Smrg  # Require at least two characters before searching for `:'
43476888252Smrg  # in the target name.  This is to cope with DOS-style filenames:
43576888252Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
43676888252Smrg  "$@" $dashmflag |
43776888252Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
43876888252Smrg  rm -f "$depfile"
43976888252Smrg  cat < "$tmpdepfile" > "$depfile"
44076888252Smrg  tr ' ' '
44176888252Smrg' < "$tmpdepfile" | \
44276888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
44376888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
44476888252Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
44576888252Smrg  rm -f "$tmpdepfile"
44676888252Smrg  ;;
44776888252Smrg
44876888252SmrgdashXmstdout)
44976888252Smrg  # This case only exists to satisfy depend.m4.  It is never actually
45076888252Smrg  # run, as this mode is specially recognized in the preamble.
45176888252Smrg  exit 1
45276888252Smrg  ;;
45376888252Smrg
45476888252Smrgmakedepend)
45576888252Smrg  "$@" || exit $?
45676888252Smrg  # Remove any Libtool call
45776888252Smrg  if test "$libtool" = yes; then
45876888252Smrg    while test $1 != '--mode=compile'; do
45976888252Smrg      shift
46076888252Smrg    done
46176888252Smrg    shift
46276888252Smrg  fi
46376888252Smrg  # X makedepend
46476888252Smrg  shift
46576888252Smrg  cleared=no
46676888252Smrg  for arg in "$@"; do
46776888252Smrg    case $cleared in
46876888252Smrg    no)
46976888252Smrg      set ""; shift
47076888252Smrg      cleared=yes ;;
47176888252Smrg    esac
47276888252Smrg    case "$arg" in
47376888252Smrg    -D*|-I*)
47476888252Smrg      set fnord "$@" "$arg"; shift ;;
47576888252Smrg    # Strip any option that makedepend may not understand.  Remove
47676888252Smrg    # the object too, otherwise makedepend will parse it as a source file.
47776888252Smrg    -*|$object)
47876888252Smrg      ;;
47976888252Smrg    *)
48076888252Smrg      set fnord "$@" "$arg"; shift ;;
48176888252Smrg    esac
48276888252Smrg  done
48376888252Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
48476888252Smrg  touch "$tmpdepfile"
48576888252Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
48676888252Smrg  rm -f "$depfile"
48776888252Smrg  cat < "$tmpdepfile" > "$depfile"
48876888252Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
48976888252Smrg' | \
49076888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
49176888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
49276888252Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
49376888252Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
49476888252Smrg  ;;
49576888252Smrg
49676888252Smrgcpp)
49776888252Smrg  # Important note: in order to support this mode, a compiler *must*
49876888252Smrg  # always write the preprocessed file to stdout.
49976888252Smrg  "$@" || exit $?
50076888252Smrg
50176888252Smrg  # Remove the call to Libtool.
50276888252Smrg  if test "$libtool" = yes; then
50376888252Smrg    while test $1 != '--mode=compile'; do
50476888252Smrg      shift
50576888252Smrg    done
50676888252Smrg    shift
50776888252Smrg  fi
50876888252Smrg
50976888252Smrg  # Remove `-o $object'.
51076888252Smrg  IFS=" "
51176888252Smrg  for arg
51276888252Smrg  do
51376888252Smrg    case $arg in
51476888252Smrg    -o)
51576888252Smrg      shift
51676888252Smrg      ;;
51776888252Smrg    $object)
51876888252Smrg      shift
51976888252Smrg      ;;
52076888252Smrg    *)
52176888252Smrg      set fnord "$@" "$arg"
52276888252Smrg      shift # fnord
52376888252Smrg      shift # $arg
52476888252Smrg      ;;
52576888252Smrg    esac
52676888252Smrg  done
52776888252Smrg
52876888252Smrg  "$@" -E |
52976888252Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
53076888252Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
53176888252Smrg    sed '$ s: \\$::' > "$tmpdepfile"
53276888252Smrg  rm -f "$depfile"
53376888252Smrg  echo "$object : \\" > "$depfile"
53476888252Smrg  cat < "$tmpdepfile" >> "$depfile"
53576888252Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
53676888252Smrg  rm -f "$tmpdepfile"
53776888252Smrg  ;;
53876888252Smrg
53976888252Smrgmsvisualcpp)
54076888252Smrg  # Important note: in order to support this mode, a compiler *must*
54176888252Smrg  # always write the preprocessed file to stdout, regardless of -o,
54276888252Smrg  # because we must use -o when running libtool.
54376888252Smrg  "$@" || exit $?
54476888252Smrg  IFS=" "
54576888252Smrg  for arg
54676888252Smrg  do
54776888252Smrg    case "$arg" in
54876888252Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
54976888252Smrg	set fnord "$@"
55076888252Smrg	shift
55176888252Smrg	shift
55276888252Smrg	;;
55376888252Smrg    *)
55476888252Smrg	set fnord "$@" "$arg"
55576888252Smrg	shift
55676888252Smrg	shift
55776888252Smrg	;;
55876888252Smrg    esac
55976888252Smrg  done
56076888252Smrg  "$@" -E |
56176888252Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
56276888252Smrg  rm -f "$depfile"
56376888252Smrg  echo "$object : \\" > "$depfile"
56476888252Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
56576888252Smrg  echo "	" >> "$depfile"
56676888252Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
56776888252Smrg  rm -f "$tmpdepfile"
56876888252Smrg  ;;
56976888252Smrg
57076888252Smrgnone)
57176888252Smrg  exec "$@"
57276888252Smrg  ;;
57376888252Smrg
57476888252Smrg*)
57576888252Smrg  echo "Unknown depmode $depmode" 1>&2
57676888252Smrg  exit 1
57776888252Smrg  ;;
57876888252Smrgesac
57976888252Smrg
58076888252Smrgexit 0
58176888252Smrg
58276888252Smrg# Local Variables:
58376888252Smrg# mode: shell-script
58476888252Smrg# sh-indentation: 2
58576888252Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
58676888252Smrg# time-stamp-start: "scriptversion="
58776888252Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
58876888252Smrg# time-stamp-end: "$"
58976888252Smrg# End:
590