depcomp revision 7104f784
109885543Smrg#! /bin/sh
209885543Smrg# depcomp - compile a program generating dependencies as side-effects
309885543Smrg
47104f784Smrgscriptversion=2007-03-29.01
509885543Smrg
67104f784Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
77104f784Smrg# Foundation, Inc.
809885543Smrg
909885543Smrg# This program is free software; you can redistribute it and/or modify
1009885543Smrg# it under the terms of the GNU General Public License as published by
1109885543Smrg# the Free Software Foundation; either version 2, or (at your option)
1209885543Smrg# any later version.
1309885543Smrg
1409885543Smrg# This program is distributed in the hope that it will be useful,
1509885543Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1609885543Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1709885543Smrg# GNU General Public License for more details.
1809885543Smrg
1909885543Smrg# You should have received a copy of the GNU General Public License
2009885543Smrg# along with this program; if not, write to the Free Software
2109885543Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2209885543Smrg# 02110-1301, USA.
2309885543Smrg
2409885543Smrg# As a special exception to the GNU General Public License, if you
2509885543Smrg# distribute this file as part of a program that contains a
2609885543Smrg# configuration script generated by Autoconf, you may include it under
2709885543Smrg# the same distribution terms that you use for the rest of that program.
2809885543Smrg
2909885543Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
3009885543Smrg
3109885543Smrgcase $1 in
3209885543Smrg  '')
3309885543Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3409885543Smrg     exit 1;
3509885543Smrg     ;;
3609885543Smrg  -h | --h*)
3709885543Smrg    cat <<\EOF
3809885543SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3909885543Smrg
4009885543SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4109885543Smrgas side-effects.
4209885543Smrg
4309885543SmrgEnvironment variables:
4409885543Smrg  depmode     Dependency tracking mode.
4509885543Smrg  source      Source file read by `PROGRAMS ARGS'.
4609885543Smrg  object      Object file output by `PROGRAMS ARGS'.
4709885543Smrg  DEPDIR      directory where to store dependencies.
4809885543Smrg  depfile     Dependency file to output.
4909885543Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
5009885543Smrg  libtool     Whether libtool is used (yes/no).
5109885543Smrg
5209885543SmrgReport bugs to <bug-automake@gnu.org>.
5309885543SmrgEOF
5409885543Smrg    exit $?
5509885543Smrg    ;;
5609885543Smrg  -v | --v*)
5709885543Smrg    echo "depcomp $scriptversion"
5809885543Smrg    exit $?
5909885543Smrg    ;;
6009885543Smrgesac
6109885543Smrg
6209885543Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6309885543Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6409885543Smrg  exit 1
6509885543Smrgfi
6609885543Smrg
6709885543Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6809885543Smrgdepfile=${depfile-`echo "$object" |
6909885543Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
7009885543Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7109885543Smrg
7209885543Smrgrm -f "$tmpdepfile"
7309885543Smrg
7409885543Smrg# Some modes work just like other modes, but use different flags.  We
7509885543Smrg# parameterize here, but still list the modes in the big case below,
7609885543Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7709885543Smrg# here, because this file can only contain one case statement.
7809885543Smrgif test "$depmode" = hp; then
7909885543Smrg  # HP compiler uses -M and no extra arg.
8009885543Smrg  gccflag=-M
8109885543Smrg  depmode=gcc
8209885543Smrgfi
8309885543Smrg
8409885543Smrgif test "$depmode" = dashXmstdout; then
8509885543Smrg   # This is just like dashmstdout with a different argument.
8609885543Smrg   dashmflag=-xM
8709885543Smrg   depmode=dashmstdout
8809885543Smrgfi
8909885543Smrg
9009885543Smrgcase "$depmode" in
9109885543Smrggcc3)
9209885543Smrg## gcc 3 implements dependency tracking that does exactly what
9309885543Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9409885543Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
957104f784Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
967104f784Smrg## the command line argument order; so add the flags where they
977104f784Smrg## appear in depend2.am.  Note that the slowdown incurred here
987104f784Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
997104f784Smrg  for arg
1007104f784Smrg  do
1017104f784Smrg    case $arg in
1027104f784Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1037104f784Smrg    *)  set fnord "$@" "$arg" ;;
1047104f784Smrg    esac
1057104f784Smrg    shift # fnord
1067104f784Smrg    shift # $arg
1077104f784Smrg  done
1087104f784Smrg  "$@"
10909885543Smrg  stat=$?
11009885543Smrg  if test $stat -eq 0; then :
11109885543Smrg  else
11209885543Smrg    rm -f "$tmpdepfile"
11309885543Smrg    exit $stat
11409885543Smrg  fi
11509885543Smrg  mv "$tmpdepfile" "$depfile"
11609885543Smrg  ;;
11709885543Smrg
11809885543Smrggcc)
11909885543Smrg## There are various ways to get dependency output from gcc.  Here's
12009885543Smrg## why we pick this rather obscure method:
12109885543Smrg## - Don't want to use -MD because we'd like the dependencies to end
12209885543Smrg##   up in a subdir.  Having to rename by hand is ugly.
12309885543Smrg##   (We might end up doing this anyway to support other compilers.)
12409885543Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
12509885543Smrg##   -MM, not -M (despite what the docs say).
12609885543Smrg## - Using -M directly means running the compiler twice (even worse
12709885543Smrg##   than renaming).
12809885543Smrg  if test -z "$gccflag"; then
12909885543Smrg    gccflag=-MD,
13009885543Smrg  fi
13109885543Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
13209885543Smrg  stat=$?
13309885543Smrg  if test $stat -eq 0; then :
13409885543Smrg  else
13509885543Smrg    rm -f "$tmpdepfile"
13609885543Smrg    exit $stat
13709885543Smrg  fi
13809885543Smrg  rm -f "$depfile"
13909885543Smrg  echo "$object : \\" > "$depfile"
14009885543Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14109885543Smrg## The second -e expression handles DOS-style file names with drive letters.
14209885543Smrg  sed -e 's/^[^:]*: / /' \
14309885543Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
14409885543Smrg## This next piece of magic avoids the `deleted header file' problem.
14509885543Smrg## The problem is that when a header file which appears in a .P file
14609885543Smrg## is deleted, the dependency causes make to die (because there is
14709885543Smrg## typically no way to rebuild the header).  We avoid this by adding
14809885543Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
14909885543Smrg## this for us directly.
15009885543Smrg  tr ' ' '
15109885543Smrg' < "$tmpdepfile" |
15209885543Smrg## Some versions of gcc put a space before the `:'.  On the theory
15309885543Smrg## that the space means something, we add a space to the output as
15409885543Smrg## well.
15509885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
15609885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
15709885543Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
15809885543Smrg  rm -f "$tmpdepfile"
15909885543Smrg  ;;
16009885543Smrg
16109885543Smrghp)
16209885543Smrg  # This case exists only to let depend.m4 do its work.  It works by
16309885543Smrg  # looking at the text of this script.  This case will never be run,
16409885543Smrg  # since it is checked for above.
16509885543Smrg  exit 1
16609885543Smrg  ;;
16709885543Smrg
16809885543Smrgsgi)
16909885543Smrg  if test "$libtool" = yes; then
17009885543Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17109885543Smrg  else
17209885543Smrg    "$@" -MDupdate "$tmpdepfile"
17309885543Smrg  fi
17409885543Smrg  stat=$?
17509885543Smrg  if test $stat -eq 0; then :
17609885543Smrg  else
17709885543Smrg    rm -f "$tmpdepfile"
17809885543Smrg    exit $stat
17909885543Smrg  fi
18009885543Smrg  rm -f "$depfile"
18109885543Smrg
18209885543Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
18309885543Smrg    echo "$object : \\" > "$depfile"
18409885543Smrg
18509885543Smrg    # Clip off the initial element (the dependent).  Don't try to be
18609885543Smrg    # clever and replace this with sed code, as IRIX sed won't handle
18709885543Smrg    # lines with more than a fixed number of characters (4096 in
18809885543Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
18909885543Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
19009885543Smrg    # dependency line.
19109885543Smrg    tr ' ' '
19209885543Smrg' < "$tmpdepfile" \
19309885543Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
19409885543Smrg    tr '
19509885543Smrg' ' ' >> $depfile
19609885543Smrg    echo >> $depfile
19709885543Smrg
19809885543Smrg    # The second pass generates a dummy entry for each header file.
19909885543Smrg    tr ' ' '
20009885543Smrg' < "$tmpdepfile" \
20109885543Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20209885543Smrg   >> $depfile
20309885543Smrg  else
20409885543Smrg    # The sourcefile does not contain any dependencies, so just
20509885543Smrg    # store a dummy comment line, to avoid errors with the Makefile
20609885543Smrg    # "include basename.Plo" scheme.
20709885543Smrg    echo "#dummy" > "$depfile"
20809885543Smrg  fi
20909885543Smrg  rm -f "$tmpdepfile"
21009885543Smrg  ;;
21109885543Smrg
21209885543Smrgaix)
21309885543Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
21409885543Smrg  # in a .u file.  In older versions, this file always lives in the
21509885543Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
21609885543Smrg  # start of each line; $object doesn't have directory information.
21709885543Smrg  # Version 6 uses the directory in both cases.
2187104f784Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
2197104f784Smrg  test "x$dir" = "x$object" && dir=
2207104f784Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
22109885543Smrg  if test "$libtool" = yes; then
2227104f784Smrg    tmpdepfile1=$dir$base.u
2237104f784Smrg    tmpdepfile2=$base.u
2247104f784Smrg    tmpdepfile3=$dir.libs/$base.u
22509885543Smrg    "$@" -Wc,-M
22609885543Smrg  else
2277104f784Smrg    tmpdepfile1=$dir$base.u
2287104f784Smrg    tmpdepfile2=$dir$base.u
2297104f784Smrg    tmpdepfile3=$dir$base.u
23009885543Smrg    "$@" -M
23109885543Smrg  fi
23209885543Smrg  stat=$?
23309885543Smrg
23409885543Smrg  if test $stat -eq 0; then :
23509885543Smrg  else
2367104f784Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
23709885543Smrg    exit $stat
23809885543Smrg  fi
23909885543Smrg
2407104f784Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2417104f784Smrg  do
2427104f784Smrg    test -f "$tmpdepfile" && break
2437104f784Smrg  done
24409885543Smrg  if test -f "$tmpdepfile"; then
24509885543Smrg    # Each line is of the form `foo.o: dependent.h'.
24609885543Smrg    # Do two passes, one to just change these to
24709885543Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2487104f784Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
2497104f784Smrg    # That's a tab and a space in the [].
2507104f784Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
25109885543Smrg  else
25209885543Smrg    # The sourcefile does not contain any dependencies, so just
25309885543Smrg    # store a dummy comment line, to avoid errors with the Makefile
25409885543Smrg    # "include basename.Plo" scheme.
25509885543Smrg    echo "#dummy" > "$depfile"
25609885543Smrg  fi
25709885543Smrg  rm -f "$tmpdepfile"
25809885543Smrg  ;;
25909885543Smrg
26009885543Smrgicc)
26109885543Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
26209885543Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
26309885543Smrg  # ICC 7.0 will fill foo.d with something like
26409885543Smrg  #    foo.o: sub/foo.c
26509885543Smrg  #    foo.o: sub/foo.h
26609885543Smrg  # which is wrong.  We want:
26709885543Smrg  #    sub/foo.o: sub/foo.c
26809885543Smrg  #    sub/foo.o: sub/foo.h
26909885543Smrg  #    sub/foo.c:
27009885543Smrg  #    sub/foo.h:
27109885543Smrg  # ICC 7.1 will output
27209885543Smrg  #    foo.o: sub/foo.c sub/foo.h
27309885543Smrg  # and will wrap long lines using \ :
27409885543Smrg  #    foo.o: sub/foo.c ... \
27509885543Smrg  #     sub/foo.h ... \
27609885543Smrg  #     ...
27709885543Smrg
27809885543Smrg  "$@" -MD -MF "$tmpdepfile"
27909885543Smrg  stat=$?
28009885543Smrg  if test $stat -eq 0; then :
28109885543Smrg  else
28209885543Smrg    rm -f "$tmpdepfile"
28309885543Smrg    exit $stat
28409885543Smrg  fi
28509885543Smrg  rm -f "$depfile"
28609885543Smrg  # Each line is of the form `foo.o: dependent.h',
28709885543Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
28809885543Smrg  # Do two passes, one to just change these to
28909885543Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
29009885543Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
29109885543Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
29209885543Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
29309885543Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
29409885543Smrg    sed -e 's/$/ :/' >> "$depfile"
29509885543Smrg  rm -f "$tmpdepfile"
29609885543Smrg  ;;
29709885543Smrg
2987104f784Smrghp2)
2997104f784Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3007104f784Smrg  # compilers, which have integrated preprocessors.  The correct option
3017104f784Smrg  # to use with these is +Maked; it writes dependencies to a file named
3027104f784Smrg  # 'foo.d', which lands next to the object file, wherever that
3037104f784Smrg  # happens to be.
3047104f784Smrg  # Much of this is similar to the tru64 case; see comments there.
3057104f784Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3067104f784Smrg  test "x$dir" = "x$object" && dir=
3077104f784Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3087104f784Smrg  if test "$libtool" = yes; then
3097104f784Smrg    tmpdepfile1=$dir$base.d
3107104f784Smrg    tmpdepfile2=$dir.libs/$base.d
3117104f784Smrg    "$@" -Wc,+Maked
3127104f784Smrg  else
3137104f784Smrg    tmpdepfile1=$dir$base.d
3147104f784Smrg    tmpdepfile2=$dir$base.d
3157104f784Smrg    "$@" +Maked
3167104f784Smrg  fi
3177104f784Smrg  stat=$?
3187104f784Smrg  if test $stat -eq 0; then :
3197104f784Smrg  else
3207104f784Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3217104f784Smrg     exit $stat
3227104f784Smrg  fi
3237104f784Smrg
3247104f784Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3257104f784Smrg  do
3267104f784Smrg    test -f "$tmpdepfile" && break
3277104f784Smrg  done
3287104f784Smrg  if test -f "$tmpdepfile"; then
3297104f784Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3307104f784Smrg    # Add `dependent.h:' lines.
3317104f784Smrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
3327104f784Smrg  else
3337104f784Smrg    echo "#dummy" > "$depfile"
3347104f784Smrg  fi
3357104f784Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3367104f784Smrg  ;;
3377104f784Smrg
33809885543Smrgtru64)
33909885543Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
34009885543Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
34109885543Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
34209885543Smrg   # dependencies in `foo.d' instead, so we check for that too.
34309885543Smrg   # Subdirectories are respected.
34409885543Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
34509885543Smrg   test "x$dir" = "x$object" && dir=
34609885543Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
34709885543Smrg
34809885543Smrg   if test "$libtool" = yes; then
34909885543Smrg      # With Tru64 cc, shared objects can also be used to make a
3507104f784Smrg      # static library.  This mechanism is used in libtool 1.4 series to
35109885543Smrg      # handle both shared and static libraries in a single compilation.
35209885543Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
35309885543Smrg      #
35409885543Smrg      # With libtool 1.5 this exception was removed, and libtool now
35509885543Smrg      # generates 2 separate objects for the 2 libraries.  These two
3567104f784Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
35709885543Smrg      # in $dir$base.o.d.  We have to check for both files, because
35809885543Smrg      # one of the two compilations can be disabled.  We should prefer
35909885543Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
36009885543Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
36109885543Smrg      # the former would cause a distcleancheck panic.
36209885543Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
36309885543Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
36409885543Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
36509885543Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
36609885543Smrg      "$@" -Wc,-MD
36709885543Smrg   else
36809885543Smrg      tmpdepfile1=$dir$base.o.d
36909885543Smrg      tmpdepfile2=$dir$base.d
37009885543Smrg      tmpdepfile3=$dir$base.d
37109885543Smrg      tmpdepfile4=$dir$base.d
37209885543Smrg      "$@" -MD
37309885543Smrg   fi
37409885543Smrg
37509885543Smrg   stat=$?
37609885543Smrg   if test $stat -eq 0; then :
37709885543Smrg   else
37809885543Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
37909885543Smrg      exit $stat
38009885543Smrg   fi
38109885543Smrg
38209885543Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
38309885543Smrg   do
38409885543Smrg     test -f "$tmpdepfile" && break
38509885543Smrg   done
38609885543Smrg   if test -f "$tmpdepfile"; then
38709885543Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
38809885543Smrg      # That's a tab and a space in the [].
38909885543Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
39009885543Smrg   else
39109885543Smrg      echo "#dummy" > "$depfile"
39209885543Smrg   fi
39309885543Smrg   rm -f "$tmpdepfile"
39409885543Smrg   ;;
39509885543Smrg
39609885543Smrg#nosideeffect)
39709885543Smrg  # This comment above is used by automake to tell side-effect
39809885543Smrg  # dependency tracking mechanisms from slower ones.
39909885543Smrg
40009885543Smrgdashmstdout)
40109885543Smrg  # Important note: in order to support this mode, a compiler *must*
40209885543Smrg  # always write the preprocessed file to stdout, regardless of -o.
40309885543Smrg  "$@" || exit $?
40409885543Smrg
40509885543Smrg  # Remove the call to Libtool.
40609885543Smrg  if test "$libtool" = yes; then
40709885543Smrg    while test $1 != '--mode=compile'; do
40809885543Smrg      shift
40909885543Smrg    done
41009885543Smrg    shift
41109885543Smrg  fi
41209885543Smrg
41309885543Smrg  # Remove `-o $object'.
41409885543Smrg  IFS=" "
41509885543Smrg  for arg
41609885543Smrg  do
41709885543Smrg    case $arg in
41809885543Smrg    -o)
41909885543Smrg      shift
42009885543Smrg      ;;
42109885543Smrg    $object)
42209885543Smrg      shift
42309885543Smrg      ;;
42409885543Smrg    *)
42509885543Smrg      set fnord "$@" "$arg"
42609885543Smrg      shift # fnord
42709885543Smrg      shift # $arg
42809885543Smrg      ;;
42909885543Smrg    esac
43009885543Smrg  done
43109885543Smrg
43209885543Smrg  test -z "$dashmflag" && dashmflag=-M
43309885543Smrg  # Require at least two characters before searching for `:'
43409885543Smrg  # in the target name.  This is to cope with DOS-style filenames:
43509885543Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
43609885543Smrg  "$@" $dashmflag |
43709885543Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
43809885543Smrg  rm -f "$depfile"
43909885543Smrg  cat < "$tmpdepfile" > "$depfile"
44009885543Smrg  tr ' ' '
44109885543Smrg' < "$tmpdepfile" | \
44209885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
44309885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
44409885543Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
44509885543Smrg  rm -f "$tmpdepfile"
44609885543Smrg  ;;
44709885543Smrg
44809885543SmrgdashXmstdout)
44909885543Smrg  # This case only exists to satisfy depend.m4.  It is never actually
45009885543Smrg  # run, as this mode is specially recognized in the preamble.
45109885543Smrg  exit 1
45209885543Smrg  ;;
45309885543Smrg
45409885543Smrgmakedepend)
45509885543Smrg  "$@" || exit $?
45609885543Smrg  # Remove any Libtool call
45709885543Smrg  if test "$libtool" = yes; then
45809885543Smrg    while test $1 != '--mode=compile'; do
45909885543Smrg      shift
46009885543Smrg    done
46109885543Smrg    shift
46209885543Smrg  fi
46309885543Smrg  # X makedepend
46409885543Smrg  shift
46509885543Smrg  cleared=no
46609885543Smrg  for arg in "$@"; do
46709885543Smrg    case $cleared in
46809885543Smrg    no)
46909885543Smrg      set ""; shift
47009885543Smrg      cleared=yes ;;
47109885543Smrg    esac
47209885543Smrg    case "$arg" in
47309885543Smrg    -D*|-I*)
47409885543Smrg      set fnord "$@" "$arg"; shift ;;
47509885543Smrg    # Strip any option that makedepend may not understand.  Remove
47609885543Smrg    # the object too, otherwise makedepend will parse it as a source file.
47709885543Smrg    -*|$object)
47809885543Smrg      ;;
47909885543Smrg    *)
48009885543Smrg      set fnord "$@" "$arg"; shift ;;
48109885543Smrg    esac
48209885543Smrg  done
48309885543Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
48409885543Smrg  touch "$tmpdepfile"
48509885543Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
48609885543Smrg  rm -f "$depfile"
48709885543Smrg  cat < "$tmpdepfile" > "$depfile"
48809885543Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
48909885543Smrg' | \
49009885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
49109885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
49209885543Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
49309885543Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
49409885543Smrg  ;;
49509885543Smrg
49609885543Smrgcpp)
49709885543Smrg  # Important note: in order to support this mode, a compiler *must*
49809885543Smrg  # always write the preprocessed file to stdout.
49909885543Smrg  "$@" || exit $?
50009885543Smrg
50109885543Smrg  # Remove the call to Libtool.
50209885543Smrg  if test "$libtool" = yes; then
50309885543Smrg    while test $1 != '--mode=compile'; do
50409885543Smrg      shift
50509885543Smrg    done
50609885543Smrg    shift
50709885543Smrg  fi
50809885543Smrg
50909885543Smrg  # Remove `-o $object'.
51009885543Smrg  IFS=" "
51109885543Smrg  for arg
51209885543Smrg  do
51309885543Smrg    case $arg in
51409885543Smrg    -o)
51509885543Smrg      shift
51609885543Smrg      ;;
51709885543Smrg    $object)
51809885543Smrg      shift
51909885543Smrg      ;;
52009885543Smrg    *)
52109885543Smrg      set fnord "$@" "$arg"
52209885543Smrg      shift # fnord
52309885543Smrg      shift # $arg
52409885543Smrg      ;;
52509885543Smrg    esac
52609885543Smrg  done
52709885543Smrg
52809885543Smrg  "$@" -E |
52909885543Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
53009885543Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
53109885543Smrg    sed '$ s: \\$::' > "$tmpdepfile"
53209885543Smrg  rm -f "$depfile"
53309885543Smrg  echo "$object : \\" > "$depfile"
53409885543Smrg  cat < "$tmpdepfile" >> "$depfile"
53509885543Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
53609885543Smrg  rm -f "$tmpdepfile"
53709885543Smrg  ;;
53809885543Smrg
53909885543Smrgmsvisualcpp)
54009885543Smrg  # Important note: in order to support this mode, a compiler *must*
54109885543Smrg  # always write the preprocessed file to stdout, regardless of -o,
54209885543Smrg  # because we must use -o when running libtool.
54309885543Smrg  "$@" || exit $?
54409885543Smrg  IFS=" "
54509885543Smrg  for arg
54609885543Smrg  do
54709885543Smrg    case "$arg" in
54809885543Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
54909885543Smrg	set fnord "$@"
55009885543Smrg	shift
55109885543Smrg	shift
55209885543Smrg	;;
55309885543Smrg    *)
55409885543Smrg	set fnord "$@" "$arg"
55509885543Smrg	shift
55609885543Smrg	shift
55709885543Smrg	;;
55809885543Smrg    esac
55909885543Smrg  done
56009885543Smrg  "$@" -E |
56109885543Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
56209885543Smrg  rm -f "$depfile"
56309885543Smrg  echo "$object : \\" > "$depfile"
56409885543Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
56509885543Smrg  echo "	" >> "$depfile"
56609885543Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
56709885543Smrg  rm -f "$tmpdepfile"
56809885543Smrg  ;;
56909885543Smrg
57009885543Smrgnone)
57109885543Smrg  exec "$@"
57209885543Smrg  ;;
57309885543Smrg
57409885543Smrg*)
57509885543Smrg  echo "Unknown depmode $depmode" 1>&2
57609885543Smrg  exit 1
57709885543Smrg  ;;
57809885543Smrgesac
57909885543Smrg
58009885543Smrgexit 0
58109885543Smrg
58209885543Smrg# Local Variables:
58309885543Smrg# mode: shell-script
58409885543Smrg# sh-indentation: 2
58509885543Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
58609885543Smrg# time-stamp-start: "scriptversion="
58709885543Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
58809885543Smrg# time-stamp-end: "$"
58909885543Smrg# End:
590