depcomp revision b698ba48
109885543Smrg#! /bin/sh
209885543Smrg# depcomp - compile a program generating dependencies as side-effects
309885543Smrg
4b698ba48Smrgscriptversion=2009-04-28.21; # UTC
509885543Smrg
6b698ba48Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
7b698ba48Smrg# Software 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
20b698ba48Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2109885543Smrg
2209885543Smrg# As a special exception to the GNU General Public License, if you
2309885543Smrg# distribute this file as part of a program that contains a
2409885543Smrg# configuration script generated by Autoconf, you may include it under
2509885543Smrg# the same distribution terms that you use for the rest of that program.
2609885543Smrg
2709885543Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2809885543Smrg
2909885543Smrgcase $1 in
3009885543Smrg  '')
3109885543Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3209885543Smrg     exit 1;
3309885543Smrg     ;;
3409885543Smrg  -h | --h*)
3509885543Smrg    cat <<\EOF
3609885543SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3709885543Smrg
3809885543SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
3909885543Smrgas side-effects.
4009885543Smrg
4109885543SmrgEnvironment variables:
4209885543Smrg  depmode     Dependency tracking mode.
4309885543Smrg  source      Source file read by `PROGRAMS ARGS'.
4409885543Smrg  object      Object file output by `PROGRAMS ARGS'.
4509885543Smrg  DEPDIR      directory where to store dependencies.
4609885543Smrg  depfile     Dependency file to output.
4709885543Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
4809885543Smrg  libtool     Whether libtool is used (yes/no).
4909885543Smrg
5009885543SmrgReport bugs to <bug-automake@gnu.org>.
5109885543SmrgEOF
5209885543Smrg    exit $?
5309885543Smrg    ;;
5409885543Smrg  -v | --v*)
5509885543Smrg    echo "depcomp $scriptversion"
5609885543Smrg    exit $?
5709885543Smrg    ;;
5809885543Smrgesac
5909885543Smrg
6009885543Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6109885543Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6209885543Smrg  exit 1
6309885543Smrgfi
6409885543Smrg
6509885543Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6609885543Smrgdepfile=${depfile-`echo "$object" |
6709885543Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6809885543Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
6909885543Smrg
7009885543Smrgrm -f "$tmpdepfile"
7109885543Smrg
7209885543Smrg# Some modes work just like other modes, but use different flags.  We
7309885543Smrg# parameterize here, but still list the modes in the big case below,
7409885543Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7509885543Smrg# here, because this file can only contain one case statement.
7609885543Smrgif test "$depmode" = hp; then
7709885543Smrg  # HP compiler uses -M and no extra arg.
7809885543Smrg  gccflag=-M
7909885543Smrg  depmode=gcc
8009885543Smrgfi
8109885543Smrg
8209885543Smrgif test "$depmode" = dashXmstdout; then
8309885543Smrg   # This is just like dashmstdout with a different argument.
8409885543Smrg   dashmflag=-xM
8509885543Smrg   depmode=dashmstdout
8609885543Smrgfi
8709885543Smrg
88b698ba48Smrgcygpath_u="cygpath -u -f -"
89b698ba48Smrgif test "$depmode" = msvcmsys; then
90b698ba48Smrg   # This is just like msvisualcpp but w/o cygpath translation.
91b698ba48Smrg   # Just convert the backslash-escaped backslashes to single forward
92b698ba48Smrg   # slashes to satisfy depend.m4
93b698ba48Smrg   cygpath_u="sed s,\\\\\\\\,/,g"
94b698ba48Smrg   depmode=msvisualcpp
95b698ba48Smrgfi
96b698ba48Smrg
9709885543Smrgcase "$depmode" in
9809885543Smrggcc3)
9909885543Smrg## gcc 3 implements dependency tracking that does exactly what
10009885543Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
10109885543Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
1027104f784Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
1037104f784Smrg## the command line argument order; so add the flags where they
1047104f784Smrg## appear in depend2.am.  Note that the slowdown incurred here
1057104f784Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
1067104f784Smrg  for arg
1077104f784Smrg  do
1087104f784Smrg    case $arg in
1097104f784Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1107104f784Smrg    *)  set fnord "$@" "$arg" ;;
1117104f784Smrg    esac
1127104f784Smrg    shift # fnord
1137104f784Smrg    shift # $arg
1147104f784Smrg  done
1157104f784Smrg  "$@"
11609885543Smrg  stat=$?
11709885543Smrg  if test $stat -eq 0; then :
11809885543Smrg  else
11909885543Smrg    rm -f "$tmpdepfile"
12009885543Smrg    exit $stat
12109885543Smrg  fi
12209885543Smrg  mv "$tmpdepfile" "$depfile"
12309885543Smrg  ;;
12409885543Smrg
12509885543Smrggcc)
12609885543Smrg## There are various ways to get dependency output from gcc.  Here's
12709885543Smrg## why we pick this rather obscure method:
12809885543Smrg## - Don't want to use -MD because we'd like the dependencies to end
12909885543Smrg##   up in a subdir.  Having to rename by hand is ugly.
13009885543Smrg##   (We might end up doing this anyway to support other compilers.)
13109885543Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
13209885543Smrg##   -MM, not -M (despite what the docs say).
13309885543Smrg## - Using -M directly means running the compiler twice (even worse
13409885543Smrg##   than renaming).
13509885543Smrg  if test -z "$gccflag"; then
13609885543Smrg    gccflag=-MD,
13709885543Smrg  fi
13809885543Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
13909885543Smrg  stat=$?
14009885543Smrg  if test $stat -eq 0; then :
14109885543Smrg  else
14209885543Smrg    rm -f "$tmpdepfile"
14309885543Smrg    exit $stat
14409885543Smrg  fi
14509885543Smrg  rm -f "$depfile"
14609885543Smrg  echo "$object : \\" > "$depfile"
14709885543Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14809885543Smrg## The second -e expression handles DOS-style file names with drive letters.
14909885543Smrg  sed -e 's/^[^:]*: / /' \
15009885543Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
15109885543Smrg## This next piece of magic avoids the `deleted header file' problem.
15209885543Smrg## The problem is that when a header file which appears in a .P file
15309885543Smrg## is deleted, the dependency causes make to die (because there is
15409885543Smrg## typically no way to rebuild the header).  We avoid this by adding
15509885543Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
15609885543Smrg## this for us directly.
15709885543Smrg  tr ' ' '
15809885543Smrg' < "$tmpdepfile" |
15909885543Smrg## Some versions of gcc put a space before the `:'.  On the theory
16009885543Smrg## that the space means something, we add a space to the output as
16109885543Smrg## well.
16209885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
16309885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
16409885543Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
16509885543Smrg  rm -f "$tmpdepfile"
16609885543Smrg  ;;
16709885543Smrg
16809885543Smrghp)
16909885543Smrg  # This case exists only to let depend.m4 do its work.  It works by
17009885543Smrg  # looking at the text of this script.  This case will never be run,
17109885543Smrg  # since it is checked for above.
17209885543Smrg  exit 1
17309885543Smrg  ;;
17409885543Smrg
17509885543Smrgsgi)
17609885543Smrg  if test "$libtool" = yes; then
17709885543Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17809885543Smrg  else
17909885543Smrg    "$@" -MDupdate "$tmpdepfile"
18009885543Smrg  fi
18109885543Smrg  stat=$?
18209885543Smrg  if test $stat -eq 0; then :
18309885543Smrg  else
18409885543Smrg    rm -f "$tmpdepfile"
18509885543Smrg    exit $stat
18609885543Smrg  fi
18709885543Smrg  rm -f "$depfile"
18809885543Smrg
18909885543Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
19009885543Smrg    echo "$object : \\" > "$depfile"
19109885543Smrg
19209885543Smrg    # Clip off the initial element (the dependent).  Don't try to be
19309885543Smrg    # clever and replace this with sed code, as IRIX sed won't handle
19409885543Smrg    # lines with more than a fixed number of characters (4096 in
19509885543Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
19609885543Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
19709885543Smrg    # dependency line.
19809885543Smrg    tr ' ' '
19909885543Smrg' < "$tmpdepfile" \
20009885543Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
20109885543Smrg    tr '
202b698ba48Smrg' ' ' >> "$depfile"
203b698ba48Smrg    echo >> "$depfile"
20409885543Smrg
20509885543Smrg    # The second pass generates a dummy entry for each header file.
20609885543Smrg    tr ' ' '
20709885543Smrg' < "$tmpdepfile" \
20809885543Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
209b698ba48Smrg   >> "$depfile"
21009885543Smrg  else
21109885543Smrg    # The sourcefile does not contain any dependencies, so just
21209885543Smrg    # store a dummy comment line, to avoid errors with the Makefile
21309885543Smrg    # "include basename.Plo" scheme.
21409885543Smrg    echo "#dummy" > "$depfile"
21509885543Smrg  fi
21609885543Smrg  rm -f "$tmpdepfile"
21709885543Smrg  ;;
21809885543Smrg
21909885543Smrgaix)
22009885543Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
22109885543Smrg  # in a .u file.  In older versions, this file always lives in the
22209885543Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
22309885543Smrg  # start of each line; $object doesn't have directory information.
22409885543Smrg  # Version 6 uses the directory in both cases.
2257104f784Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
2267104f784Smrg  test "x$dir" = "x$object" && dir=
2277104f784Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
22809885543Smrg  if test "$libtool" = yes; then
2297104f784Smrg    tmpdepfile1=$dir$base.u
2307104f784Smrg    tmpdepfile2=$base.u
2317104f784Smrg    tmpdepfile3=$dir.libs/$base.u
23209885543Smrg    "$@" -Wc,-M
23309885543Smrg  else
2347104f784Smrg    tmpdepfile1=$dir$base.u
2357104f784Smrg    tmpdepfile2=$dir$base.u
2367104f784Smrg    tmpdepfile3=$dir$base.u
23709885543Smrg    "$@" -M
23809885543Smrg  fi
23909885543Smrg  stat=$?
24009885543Smrg
24109885543Smrg  if test $stat -eq 0; then :
24209885543Smrg  else
2437104f784Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24409885543Smrg    exit $stat
24509885543Smrg  fi
24609885543Smrg
2477104f784Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2487104f784Smrg  do
2497104f784Smrg    test -f "$tmpdepfile" && break
2507104f784Smrg  done
25109885543Smrg  if test -f "$tmpdepfile"; then
25209885543Smrg    # Each line is of the form `foo.o: dependent.h'.
25309885543Smrg    # Do two passes, one to just change these to
25409885543Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2557104f784Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
2567104f784Smrg    # That's a tab and a space in the [].
2577104f784Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
25809885543Smrg  else
25909885543Smrg    # The sourcefile does not contain any dependencies, so just
26009885543Smrg    # store a dummy comment line, to avoid errors with the Makefile
26109885543Smrg    # "include basename.Plo" scheme.
26209885543Smrg    echo "#dummy" > "$depfile"
26309885543Smrg  fi
26409885543Smrg  rm -f "$tmpdepfile"
26509885543Smrg  ;;
26609885543Smrg
26709885543Smrgicc)
26809885543Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
26909885543Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
27009885543Smrg  # ICC 7.0 will fill foo.d with something like
27109885543Smrg  #    foo.o: sub/foo.c
27209885543Smrg  #    foo.o: sub/foo.h
27309885543Smrg  # which is wrong.  We want:
27409885543Smrg  #    sub/foo.o: sub/foo.c
27509885543Smrg  #    sub/foo.o: sub/foo.h
27609885543Smrg  #    sub/foo.c:
27709885543Smrg  #    sub/foo.h:
27809885543Smrg  # ICC 7.1 will output
27909885543Smrg  #    foo.o: sub/foo.c sub/foo.h
28009885543Smrg  # and will wrap long lines using \ :
28109885543Smrg  #    foo.o: sub/foo.c ... \
28209885543Smrg  #     sub/foo.h ... \
28309885543Smrg  #     ...
28409885543Smrg
28509885543Smrg  "$@" -MD -MF "$tmpdepfile"
28609885543Smrg  stat=$?
28709885543Smrg  if test $stat -eq 0; then :
28809885543Smrg  else
28909885543Smrg    rm -f "$tmpdepfile"
29009885543Smrg    exit $stat
29109885543Smrg  fi
29209885543Smrg  rm -f "$depfile"
29309885543Smrg  # Each line is of the form `foo.o: dependent.h',
29409885543Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
29509885543Smrg  # Do two passes, one to just change these to
29609885543Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
29709885543Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
29809885543Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
29909885543Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
30009885543Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
30109885543Smrg    sed -e 's/$/ :/' >> "$depfile"
30209885543Smrg  rm -f "$tmpdepfile"
30309885543Smrg  ;;
30409885543Smrg
3057104f784Smrghp2)
3067104f784Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3077104f784Smrg  # compilers, which have integrated preprocessors.  The correct option
3087104f784Smrg  # to use with these is +Maked; it writes dependencies to a file named
3097104f784Smrg  # 'foo.d', which lands next to the object file, wherever that
3107104f784Smrg  # happens to be.
3117104f784Smrg  # Much of this is similar to the tru64 case; see comments there.
3127104f784Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3137104f784Smrg  test "x$dir" = "x$object" && dir=
3147104f784Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3157104f784Smrg  if test "$libtool" = yes; then
3167104f784Smrg    tmpdepfile1=$dir$base.d
3177104f784Smrg    tmpdepfile2=$dir.libs/$base.d
3187104f784Smrg    "$@" -Wc,+Maked
3197104f784Smrg  else
3207104f784Smrg    tmpdepfile1=$dir$base.d
3217104f784Smrg    tmpdepfile2=$dir$base.d
3227104f784Smrg    "$@" +Maked
3237104f784Smrg  fi
3247104f784Smrg  stat=$?
3257104f784Smrg  if test $stat -eq 0; then :
3267104f784Smrg  else
3277104f784Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3287104f784Smrg     exit $stat
3297104f784Smrg  fi
3307104f784Smrg
3317104f784Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3327104f784Smrg  do
3337104f784Smrg    test -f "$tmpdepfile" && break
3347104f784Smrg  done
3357104f784Smrg  if test -f "$tmpdepfile"; then
3367104f784Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3377104f784Smrg    # Add `dependent.h:' lines.
338b698ba48Smrg    sed -ne '2,${
339b698ba48Smrg	       s/^ *//
340b698ba48Smrg	       s/ \\*$//
341b698ba48Smrg	       s/$/:/
342b698ba48Smrg	       p
343b698ba48Smrg	     }' "$tmpdepfile" >> "$depfile"
3447104f784Smrg  else
3457104f784Smrg    echo "#dummy" > "$depfile"
3467104f784Smrg  fi
3477104f784Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3487104f784Smrg  ;;
3497104f784Smrg
35009885543Smrgtru64)
35109885543Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
35209885543Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
35309885543Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
35409885543Smrg   # dependencies in `foo.d' instead, so we check for that too.
35509885543Smrg   # Subdirectories are respected.
35609885543Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
35709885543Smrg   test "x$dir" = "x$object" && dir=
35809885543Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
35909885543Smrg
36009885543Smrg   if test "$libtool" = yes; then
36109885543Smrg      # With Tru64 cc, shared objects can also be used to make a
3627104f784Smrg      # static library.  This mechanism is used in libtool 1.4 series to
36309885543Smrg      # handle both shared and static libraries in a single compilation.
36409885543Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
36509885543Smrg      #
36609885543Smrg      # With libtool 1.5 this exception was removed, and libtool now
36709885543Smrg      # generates 2 separate objects for the 2 libraries.  These two
3687104f784Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
36909885543Smrg      # in $dir$base.o.d.  We have to check for both files, because
37009885543Smrg      # one of the two compilations can be disabled.  We should prefer
37109885543Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
37209885543Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
37309885543Smrg      # the former would cause a distcleancheck panic.
37409885543Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
37509885543Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
37609885543Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
37709885543Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
37809885543Smrg      "$@" -Wc,-MD
37909885543Smrg   else
38009885543Smrg      tmpdepfile1=$dir$base.o.d
38109885543Smrg      tmpdepfile2=$dir$base.d
38209885543Smrg      tmpdepfile3=$dir$base.d
38309885543Smrg      tmpdepfile4=$dir$base.d
38409885543Smrg      "$@" -MD
38509885543Smrg   fi
38609885543Smrg
38709885543Smrg   stat=$?
38809885543Smrg   if test $stat -eq 0; then :
38909885543Smrg   else
39009885543Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
39109885543Smrg      exit $stat
39209885543Smrg   fi
39309885543Smrg
39409885543Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
39509885543Smrg   do
39609885543Smrg     test -f "$tmpdepfile" && break
39709885543Smrg   done
39809885543Smrg   if test -f "$tmpdepfile"; then
39909885543Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
40009885543Smrg      # That's a tab and a space in the [].
40109885543Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
40209885543Smrg   else
40309885543Smrg      echo "#dummy" > "$depfile"
40409885543Smrg   fi
40509885543Smrg   rm -f "$tmpdepfile"
40609885543Smrg   ;;
40709885543Smrg
40809885543Smrg#nosideeffect)
40909885543Smrg  # This comment above is used by automake to tell side-effect
41009885543Smrg  # dependency tracking mechanisms from slower ones.
41109885543Smrg
41209885543Smrgdashmstdout)
41309885543Smrg  # Important note: in order to support this mode, a compiler *must*
41409885543Smrg  # always write the preprocessed file to stdout, regardless of -o.
41509885543Smrg  "$@" || exit $?
41609885543Smrg
41709885543Smrg  # Remove the call to Libtool.
41809885543Smrg  if test "$libtool" = yes; then
419b698ba48Smrg    while test "X$1" != 'X--mode=compile'; do
42009885543Smrg      shift
42109885543Smrg    done
42209885543Smrg    shift
42309885543Smrg  fi
42409885543Smrg
42509885543Smrg  # Remove `-o $object'.
42609885543Smrg  IFS=" "
42709885543Smrg  for arg
42809885543Smrg  do
42909885543Smrg    case $arg in
43009885543Smrg    -o)
43109885543Smrg      shift
43209885543Smrg      ;;
43309885543Smrg    $object)
43409885543Smrg      shift
43509885543Smrg      ;;
43609885543Smrg    *)
43709885543Smrg      set fnord "$@" "$arg"
43809885543Smrg      shift # fnord
43909885543Smrg      shift # $arg
44009885543Smrg      ;;
44109885543Smrg    esac
44209885543Smrg  done
44309885543Smrg
44409885543Smrg  test -z "$dashmflag" && dashmflag=-M
44509885543Smrg  # Require at least two characters before searching for `:'
44609885543Smrg  # in the target name.  This is to cope with DOS-style filenames:
44709885543Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
44809885543Smrg  "$@" $dashmflag |
44909885543Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
45009885543Smrg  rm -f "$depfile"
45109885543Smrg  cat < "$tmpdepfile" > "$depfile"
45209885543Smrg  tr ' ' '
45309885543Smrg' < "$tmpdepfile" | \
45409885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
45509885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
45609885543Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
45709885543Smrg  rm -f "$tmpdepfile"
45809885543Smrg  ;;
45909885543Smrg
46009885543SmrgdashXmstdout)
46109885543Smrg  # This case only exists to satisfy depend.m4.  It is never actually
46209885543Smrg  # run, as this mode is specially recognized in the preamble.
46309885543Smrg  exit 1
46409885543Smrg  ;;
46509885543Smrg
46609885543Smrgmakedepend)
46709885543Smrg  "$@" || exit $?
46809885543Smrg  # Remove any Libtool call
46909885543Smrg  if test "$libtool" = yes; then
470b698ba48Smrg    while test "X$1" != 'X--mode=compile'; do
47109885543Smrg      shift
47209885543Smrg    done
47309885543Smrg    shift
47409885543Smrg  fi
47509885543Smrg  # X makedepend
47609885543Smrg  shift
477b698ba48Smrg  cleared=no eat=no
478b698ba48Smrg  for arg
479b698ba48Smrg  do
48009885543Smrg    case $cleared in
48109885543Smrg    no)
48209885543Smrg      set ""; shift
48309885543Smrg      cleared=yes ;;
48409885543Smrg    esac
485b698ba48Smrg    if test $eat = yes; then
486b698ba48Smrg      eat=no
487b698ba48Smrg      continue
488b698ba48Smrg    fi
48909885543Smrg    case "$arg" in
49009885543Smrg    -D*|-I*)
49109885543Smrg      set fnord "$@" "$arg"; shift ;;
49209885543Smrg    # Strip any option that makedepend may not understand.  Remove
49309885543Smrg    # the object too, otherwise makedepend will parse it as a source file.
494b698ba48Smrg    -arch)
495b698ba48Smrg      eat=yes ;;
49609885543Smrg    -*|$object)
49709885543Smrg      ;;
49809885543Smrg    *)
49909885543Smrg      set fnord "$@" "$arg"; shift ;;
50009885543Smrg    esac
50109885543Smrg  done
502b698ba48Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
50309885543Smrg  touch "$tmpdepfile"
50409885543Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
50509885543Smrg  rm -f "$depfile"
50609885543Smrg  cat < "$tmpdepfile" > "$depfile"
50709885543Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
50809885543Smrg' | \
50909885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
51009885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
51109885543Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
51209885543Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
51309885543Smrg  ;;
51409885543Smrg
51509885543Smrgcpp)
51609885543Smrg  # Important note: in order to support this mode, a compiler *must*
51709885543Smrg  # always write the preprocessed file to stdout.
51809885543Smrg  "$@" || exit $?
51909885543Smrg
52009885543Smrg  # Remove the call to Libtool.
52109885543Smrg  if test "$libtool" = yes; then
522b698ba48Smrg    while test "X$1" != 'X--mode=compile'; do
52309885543Smrg      shift
52409885543Smrg    done
52509885543Smrg    shift
52609885543Smrg  fi
52709885543Smrg
52809885543Smrg  # Remove `-o $object'.
52909885543Smrg  IFS=" "
53009885543Smrg  for arg
53109885543Smrg  do
53209885543Smrg    case $arg in
53309885543Smrg    -o)
53409885543Smrg      shift
53509885543Smrg      ;;
53609885543Smrg    $object)
53709885543Smrg      shift
53809885543Smrg      ;;
53909885543Smrg    *)
54009885543Smrg      set fnord "$@" "$arg"
54109885543Smrg      shift # fnord
54209885543Smrg      shift # $arg
54309885543Smrg      ;;
54409885543Smrg    esac
54509885543Smrg  done
54609885543Smrg
54709885543Smrg  "$@" -E |
54809885543Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
54909885543Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
55009885543Smrg    sed '$ s: \\$::' > "$tmpdepfile"
55109885543Smrg  rm -f "$depfile"
55209885543Smrg  echo "$object : \\" > "$depfile"
55309885543Smrg  cat < "$tmpdepfile" >> "$depfile"
55409885543Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
55509885543Smrg  rm -f "$tmpdepfile"
55609885543Smrg  ;;
55709885543Smrg
55809885543Smrgmsvisualcpp)
55909885543Smrg  # Important note: in order to support this mode, a compiler *must*
560b698ba48Smrg  # always write the preprocessed file to stdout.
56109885543Smrg  "$@" || exit $?
562b698ba48Smrg
563b698ba48Smrg  # Remove the call to Libtool.
564b698ba48Smrg  if test "$libtool" = yes; then
565b698ba48Smrg    while test "X$1" != 'X--mode=compile'; do
566b698ba48Smrg      shift
567b698ba48Smrg    done
568b698ba48Smrg    shift
569b698ba48Smrg  fi
570b698ba48Smrg
57109885543Smrg  IFS=" "
57209885543Smrg  for arg
57309885543Smrg  do
57409885543Smrg    case "$arg" in
575b698ba48Smrg    -o)
576b698ba48Smrg      shift
577b698ba48Smrg      ;;
578b698ba48Smrg    $object)
579b698ba48Smrg      shift
580b698ba48Smrg      ;;
58109885543Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
58209885543Smrg	set fnord "$@"
58309885543Smrg	shift
58409885543Smrg	shift
58509885543Smrg	;;
58609885543Smrg    *)
58709885543Smrg	set fnord "$@" "$arg"
58809885543Smrg	shift
58909885543Smrg	shift
59009885543Smrg	;;
59109885543Smrg    esac
59209885543Smrg  done
593b698ba48Smrg  "$@" -E 2>/dev/null |
594b698ba48Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
59509885543Smrg  rm -f "$depfile"
59609885543Smrg  echo "$object : \\" > "$depfile"
597b698ba48Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
59809885543Smrg  echo "	" >> "$depfile"
599b698ba48Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
60009885543Smrg  rm -f "$tmpdepfile"
60109885543Smrg  ;;
60209885543Smrg
603b698ba48Smrgmsvcmsys)
604b698ba48Smrg  # This case exists only to let depend.m4 do its work.  It works by
605b698ba48Smrg  # looking at the text of this script.  This case will never be run,
606b698ba48Smrg  # since it is checked for above.
607b698ba48Smrg  exit 1
608b698ba48Smrg  ;;
609b698ba48Smrg
61009885543Smrgnone)
61109885543Smrg  exec "$@"
61209885543Smrg  ;;
61309885543Smrg
61409885543Smrg*)
61509885543Smrg  echo "Unknown depmode $depmode" 1>&2
61609885543Smrg  exit 1
61709885543Smrg  ;;
61809885543Smrgesac
61909885543Smrg
62009885543Smrgexit 0
62109885543Smrg
62209885543Smrg# Local Variables:
62309885543Smrg# mode: shell-script
62409885543Smrg# sh-indentation: 2
62509885543Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
62609885543Smrg# time-stamp-start: "scriptversion="
62709885543Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
628b698ba48Smrg# time-stamp-time-zone: "UTC"
629b698ba48Smrg# time-stamp-end: "; # UTC"
63009885543Smrg# End:
631