depcomp revision b12e5c03
109885543Smrg#! /bin/sh
209885543Smrg# depcomp - compile a program generating dependencies as side-effects
309885543Smrg
4b12e5c03Smrgscriptversion=2011-12-04.11; # UTC
509885543Smrg
6b12e5c03Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
7b12e5c03Smrg# 2011 Free 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.
47b12e5c03Smrg  tmpdepfile  Temporary file to use when outputting 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
93b12e5c03Smrg   cygpath_u='sed s,\\\\,/,g'
94b698ba48Smrg   depmode=msvisualcpp
95b698ba48Smrgfi
96b698ba48Smrg
97b12e5c03Smrgif test "$depmode" = msvc7msys; then
98b12e5c03Smrg   # This is just like msvc7 but w/o cygpath translation.
99b12e5c03Smrg   # Just convert the backslash-escaped backslashes to single forward
100b12e5c03Smrg   # slashes to satisfy depend.m4
101b12e5c03Smrg   cygpath_u='sed s,\\\\,/,g'
102b12e5c03Smrg   depmode=msvc7
103b12e5c03Smrgfi
104b12e5c03Smrg
10509885543Smrgcase "$depmode" in
10609885543Smrggcc3)
10709885543Smrg## gcc 3 implements dependency tracking that does exactly what
10809885543Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
10909885543Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
1107104f784Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
1117104f784Smrg## the command line argument order; so add the flags where they
1127104f784Smrg## appear in depend2.am.  Note that the slowdown incurred here
1137104f784Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
1147104f784Smrg  for arg
1157104f784Smrg  do
1167104f784Smrg    case $arg in
1177104f784Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1187104f784Smrg    *)  set fnord "$@" "$arg" ;;
1197104f784Smrg    esac
1207104f784Smrg    shift # fnord
1217104f784Smrg    shift # $arg
1227104f784Smrg  done
1237104f784Smrg  "$@"
12409885543Smrg  stat=$?
12509885543Smrg  if test $stat -eq 0; then :
12609885543Smrg  else
12709885543Smrg    rm -f "$tmpdepfile"
12809885543Smrg    exit $stat
12909885543Smrg  fi
13009885543Smrg  mv "$tmpdepfile" "$depfile"
13109885543Smrg  ;;
13209885543Smrg
13309885543Smrggcc)
13409885543Smrg## There are various ways to get dependency output from gcc.  Here's
13509885543Smrg## why we pick this rather obscure method:
13609885543Smrg## - Don't want to use -MD because we'd like the dependencies to end
13709885543Smrg##   up in a subdir.  Having to rename by hand is ugly.
13809885543Smrg##   (We might end up doing this anyway to support other compilers.)
13909885543Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
14009885543Smrg##   -MM, not -M (despite what the docs say).
14109885543Smrg## - Using -M directly means running the compiler twice (even worse
14209885543Smrg##   than renaming).
14309885543Smrg  if test -z "$gccflag"; then
14409885543Smrg    gccflag=-MD,
14509885543Smrg  fi
14609885543Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
14709885543Smrg  stat=$?
14809885543Smrg  if test $stat -eq 0; then :
14909885543Smrg  else
15009885543Smrg    rm -f "$tmpdepfile"
15109885543Smrg    exit $stat
15209885543Smrg  fi
15309885543Smrg  rm -f "$depfile"
15409885543Smrg  echo "$object : \\" > "$depfile"
15509885543Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
15609885543Smrg## The second -e expression handles DOS-style file names with drive letters.
15709885543Smrg  sed -e 's/^[^:]*: / /' \
15809885543Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
15909885543Smrg## This next piece of magic avoids the `deleted header file' problem.
16009885543Smrg## The problem is that when a header file which appears in a .P file
16109885543Smrg## is deleted, the dependency causes make to die (because there is
16209885543Smrg## typically no way to rebuild the header).  We avoid this by adding
16309885543Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
16409885543Smrg## this for us directly.
16509885543Smrg  tr ' ' '
16609885543Smrg' < "$tmpdepfile" |
16709885543Smrg## Some versions of gcc put a space before the `:'.  On the theory
16809885543Smrg## that the space means something, we add a space to the output as
169b12e5c03Smrg## well.  hp depmode also adds that space, but also prefixes the VPATH
170b12e5c03Smrg## to the object.  Take care to not repeat it in the output.
17109885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
17209885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
173b12e5c03Smrg    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
174b12e5c03Smrg      | sed -e 's/$/ :/' >> "$depfile"
17509885543Smrg  rm -f "$tmpdepfile"
17609885543Smrg  ;;
17709885543Smrg
17809885543Smrghp)
17909885543Smrg  # This case exists only to let depend.m4 do its work.  It works by
18009885543Smrg  # looking at the text of this script.  This case will never be run,
18109885543Smrg  # since it is checked for above.
18209885543Smrg  exit 1
18309885543Smrg  ;;
18409885543Smrg
18509885543Smrgsgi)
18609885543Smrg  if test "$libtool" = yes; then
18709885543Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
18809885543Smrg  else
18909885543Smrg    "$@" -MDupdate "$tmpdepfile"
19009885543Smrg  fi
19109885543Smrg  stat=$?
19209885543Smrg  if test $stat -eq 0; then :
19309885543Smrg  else
19409885543Smrg    rm -f "$tmpdepfile"
19509885543Smrg    exit $stat
19609885543Smrg  fi
19709885543Smrg  rm -f "$depfile"
19809885543Smrg
19909885543Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
20009885543Smrg    echo "$object : \\" > "$depfile"
20109885543Smrg
20209885543Smrg    # Clip off the initial element (the dependent).  Don't try to be
20309885543Smrg    # clever and replace this with sed code, as IRIX sed won't handle
20409885543Smrg    # lines with more than a fixed number of characters (4096 in
20509885543Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
20609885543Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
20709885543Smrg    # dependency line.
20809885543Smrg    tr ' ' '
20909885543Smrg' < "$tmpdepfile" \
21009885543Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
21109885543Smrg    tr '
212b698ba48Smrg' ' ' >> "$depfile"
213b698ba48Smrg    echo >> "$depfile"
21409885543Smrg
21509885543Smrg    # The second pass generates a dummy entry for each header file.
21609885543Smrg    tr ' ' '
21709885543Smrg' < "$tmpdepfile" \
21809885543Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
219b698ba48Smrg   >> "$depfile"
22009885543Smrg  else
22109885543Smrg    # The sourcefile does not contain any dependencies, so just
22209885543Smrg    # store a dummy comment line, to avoid errors with the Makefile
22309885543Smrg    # "include basename.Plo" scheme.
22409885543Smrg    echo "#dummy" > "$depfile"
22509885543Smrg  fi
22609885543Smrg  rm -f "$tmpdepfile"
22709885543Smrg  ;;
22809885543Smrg
22909885543Smrgaix)
23009885543Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
23109885543Smrg  # in a .u file.  In older versions, this file always lives in the
23209885543Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
23309885543Smrg  # start of each line; $object doesn't have directory information.
23409885543Smrg  # Version 6 uses the directory in both cases.
2357104f784Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
2367104f784Smrg  test "x$dir" = "x$object" && dir=
2377104f784Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
23809885543Smrg  if test "$libtool" = yes; then
2397104f784Smrg    tmpdepfile1=$dir$base.u
2407104f784Smrg    tmpdepfile2=$base.u
2417104f784Smrg    tmpdepfile3=$dir.libs/$base.u
24209885543Smrg    "$@" -Wc,-M
24309885543Smrg  else
2447104f784Smrg    tmpdepfile1=$dir$base.u
2457104f784Smrg    tmpdepfile2=$dir$base.u
2467104f784Smrg    tmpdepfile3=$dir$base.u
24709885543Smrg    "$@" -M
24809885543Smrg  fi
24909885543Smrg  stat=$?
25009885543Smrg
25109885543Smrg  if test $stat -eq 0; then :
25209885543Smrg  else
2537104f784Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
25409885543Smrg    exit $stat
25509885543Smrg  fi
25609885543Smrg
2577104f784Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2587104f784Smrg  do
2597104f784Smrg    test -f "$tmpdepfile" && break
2607104f784Smrg  done
26109885543Smrg  if test -f "$tmpdepfile"; then
26209885543Smrg    # Each line is of the form `foo.o: dependent.h'.
26309885543Smrg    # Do two passes, one to just change these to
26409885543Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2657104f784Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
2667104f784Smrg    # That's a tab and a space in the [].
2677104f784Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
26809885543Smrg  else
26909885543Smrg    # The sourcefile does not contain any dependencies, so just
27009885543Smrg    # store a dummy comment line, to avoid errors with the Makefile
27109885543Smrg    # "include basename.Plo" scheme.
27209885543Smrg    echo "#dummy" > "$depfile"
27309885543Smrg  fi
27409885543Smrg  rm -f "$tmpdepfile"
27509885543Smrg  ;;
27609885543Smrg
27709885543Smrgicc)
27809885543Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
27909885543Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
28009885543Smrg  # ICC 7.0 will fill foo.d with something like
28109885543Smrg  #    foo.o: sub/foo.c
28209885543Smrg  #    foo.o: sub/foo.h
28309885543Smrg  # which is wrong.  We want:
28409885543Smrg  #    sub/foo.o: sub/foo.c
28509885543Smrg  #    sub/foo.o: sub/foo.h
28609885543Smrg  #    sub/foo.c:
28709885543Smrg  #    sub/foo.h:
28809885543Smrg  # ICC 7.1 will output
28909885543Smrg  #    foo.o: sub/foo.c sub/foo.h
29009885543Smrg  # and will wrap long lines using \ :
29109885543Smrg  #    foo.o: sub/foo.c ... \
29209885543Smrg  #     sub/foo.h ... \
29309885543Smrg  #     ...
29409885543Smrg
29509885543Smrg  "$@" -MD -MF "$tmpdepfile"
29609885543Smrg  stat=$?
29709885543Smrg  if test $stat -eq 0; then :
29809885543Smrg  else
29909885543Smrg    rm -f "$tmpdepfile"
30009885543Smrg    exit $stat
30109885543Smrg  fi
30209885543Smrg  rm -f "$depfile"
30309885543Smrg  # Each line is of the form `foo.o: dependent.h',
30409885543Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
30509885543Smrg  # Do two passes, one to just change these to
30609885543Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
30709885543Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
30809885543Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
30909885543Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
31009885543Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
31109885543Smrg    sed -e 's/$/ :/' >> "$depfile"
31209885543Smrg  rm -f "$tmpdepfile"
31309885543Smrg  ;;
31409885543Smrg
3157104f784Smrghp2)
3167104f784Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3177104f784Smrg  # compilers, which have integrated preprocessors.  The correct option
3187104f784Smrg  # to use with these is +Maked; it writes dependencies to a file named
3197104f784Smrg  # 'foo.d', which lands next to the object file, wherever that
3207104f784Smrg  # happens to be.
3217104f784Smrg  # Much of this is similar to the tru64 case; see comments there.
3227104f784Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3237104f784Smrg  test "x$dir" = "x$object" && dir=
3247104f784Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3257104f784Smrg  if test "$libtool" = yes; then
3267104f784Smrg    tmpdepfile1=$dir$base.d
3277104f784Smrg    tmpdepfile2=$dir.libs/$base.d
3287104f784Smrg    "$@" -Wc,+Maked
3297104f784Smrg  else
3307104f784Smrg    tmpdepfile1=$dir$base.d
3317104f784Smrg    tmpdepfile2=$dir$base.d
3327104f784Smrg    "$@" +Maked
3337104f784Smrg  fi
3347104f784Smrg  stat=$?
3357104f784Smrg  if test $stat -eq 0; then :
3367104f784Smrg  else
3377104f784Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3387104f784Smrg     exit $stat
3397104f784Smrg  fi
3407104f784Smrg
3417104f784Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3427104f784Smrg  do
3437104f784Smrg    test -f "$tmpdepfile" && break
3447104f784Smrg  done
3457104f784Smrg  if test -f "$tmpdepfile"; then
3467104f784Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3477104f784Smrg    # Add `dependent.h:' lines.
348b698ba48Smrg    sed -ne '2,${
349b698ba48Smrg	       s/^ *//
350b698ba48Smrg	       s/ \\*$//
351b698ba48Smrg	       s/$/:/
352b698ba48Smrg	       p
353b698ba48Smrg	     }' "$tmpdepfile" >> "$depfile"
3547104f784Smrg  else
3557104f784Smrg    echo "#dummy" > "$depfile"
3567104f784Smrg  fi
3577104f784Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3587104f784Smrg  ;;
3597104f784Smrg
36009885543Smrgtru64)
36109885543Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
36209885543Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
36309885543Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
36409885543Smrg   # dependencies in `foo.d' instead, so we check for that too.
36509885543Smrg   # Subdirectories are respected.
36609885543Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
36709885543Smrg   test "x$dir" = "x$object" && dir=
36809885543Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
36909885543Smrg
37009885543Smrg   if test "$libtool" = yes; then
37109885543Smrg      # With Tru64 cc, shared objects can also be used to make a
3727104f784Smrg      # static library.  This mechanism is used in libtool 1.4 series to
37309885543Smrg      # handle both shared and static libraries in a single compilation.
37409885543Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
37509885543Smrg      #
37609885543Smrg      # With libtool 1.5 this exception was removed, and libtool now
37709885543Smrg      # generates 2 separate objects for the 2 libraries.  These two
3787104f784Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
37909885543Smrg      # in $dir$base.o.d.  We have to check for both files, because
38009885543Smrg      # one of the two compilations can be disabled.  We should prefer
38109885543Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
38209885543Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
38309885543Smrg      # the former would cause a distcleancheck panic.
38409885543Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
38509885543Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
38609885543Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
38709885543Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
38809885543Smrg      "$@" -Wc,-MD
38909885543Smrg   else
39009885543Smrg      tmpdepfile1=$dir$base.o.d
39109885543Smrg      tmpdepfile2=$dir$base.d
39209885543Smrg      tmpdepfile3=$dir$base.d
39309885543Smrg      tmpdepfile4=$dir$base.d
39409885543Smrg      "$@" -MD
39509885543Smrg   fi
39609885543Smrg
39709885543Smrg   stat=$?
39809885543Smrg   if test $stat -eq 0; then :
39909885543Smrg   else
40009885543Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
40109885543Smrg      exit $stat
40209885543Smrg   fi
40309885543Smrg
40409885543Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
40509885543Smrg   do
40609885543Smrg     test -f "$tmpdepfile" && break
40709885543Smrg   done
40809885543Smrg   if test -f "$tmpdepfile"; then
40909885543Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
41009885543Smrg      # That's a tab and a space in the [].
41109885543Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
41209885543Smrg   else
41309885543Smrg      echo "#dummy" > "$depfile"
41409885543Smrg   fi
41509885543Smrg   rm -f "$tmpdepfile"
41609885543Smrg   ;;
41709885543Smrg
418b12e5c03Smrgmsvc7)
419b12e5c03Smrg  if test "$libtool" = yes; then
420b12e5c03Smrg    showIncludes=-Wc,-showIncludes
421b12e5c03Smrg  else
422b12e5c03Smrg    showIncludes=-showIncludes
423b12e5c03Smrg  fi
424b12e5c03Smrg  "$@" $showIncludes > "$tmpdepfile"
425b12e5c03Smrg  stat=$?
426b12e5c03Smrg  grep -v '^Note: including file: ' "$tmpdepfile"
427b12e5c03Smrg  if test "$stat" = 0; then :
428b12e5c03Smrg  else
429b12e5c03Smrg    rm -f "$tmpdepfile"
430b12e5c03Smrg    exit $stat
431b12e5c03Smrg  fi
432b12e5c03Smrg  rm -f "$depfile"
433b12e5c03Smrg  echo "$object : \\" > "$depfile"
434b12e5c03Smrg  # The first sed program below extracts the file names and escapes
435b12e5c03Smrg  # backslashes for cygpath.  The second sed program outputs the file
436b12e5c03Smrg  # name when reading, but also accumulates all include files in the
437b12e5c03Smrg  # hold buffer in order to output them again at the end.  This only
438b12e5c03Smrg  # works with sed implementations that can handle large buffers.
439b12e5c03Smrg  sed < "$tmpdepfile" -n '
440b12e5c03Smrg/^Note: including file:  *\(.*\)/ {
441b12e5c03Smrg  s//\1/
442b12e5c03Smrg  s/\\/\\\\/g
443b12e5c03Smrg  p
444b12e5c03Smrg}' | $cygpath_u | sort -u | sed -n '
445b12e5c03Smrgs/ /\\ /g
446b12e5c03Smrgs/\(.*\)/	\1 \\/p
447b12e5c03Smrgs/.\(.*\) \\/\1:/
448b12e5c03SmrgH
449b12e5c03Smrg$ {
450b12e5c03Smrg  s/.*/	/
451b12e5c03Smrg  G
452b12e5c03Smrg  p
453b12e5c03Smrg}' >> "$depfile"
454b12e5c03Smrg  rm -f "$tmpdepfile"
455b12e5c03Smrg  ;;
456b12e5c03Smrg
457b12e5c03Smrgmsvc7msys)
458b12e5c03Smrg  # This case exists only to let depend.m4 do its work.  It works by
459b12e5c03Smrg  # looking at the text of this script.  This case will never be run,
460b12e5c03Smrg  # since it is checked for above.
461b12e5c03Smrg  exit 1
462b12e5c03Smrg  ;;
463b12e5c03Smrg
46409885543Smrg#nosideeffect)
46509885543Smrg  # This comment above is used by automake to tell side-effect
46609885543Smrg  # dependency tracking mechanisms from slower ones.
46709885543Smrg
46809885543Smrgdashmstdout)
46909885543Smrg  # Important note: in order to support this mode, a compiler *must*
47009885543Smrg  # always write the preprocessed file to stdout, regardless of -o.
47109885543Smrg  "$@" || exit $?
47209885543Smrg
47309885543Smrg  # Remove the call to Libtool.
47409885543Smrg  if test "$libtool" = yes; then
475b698ba48Smrg    while test "X$1" != 'X--mode=compile'; do
47609885543Smrg      shift
47709885543Smrg    done
47809885543Smrg    shift
47909885543Smrg  fi
48009885543Smrg
48109885543Smrg  # Remove `-o $object'.
48209885543Smrg  IFS=" "
48309885543Smrg  for arg
48409885543Smrg  do
48509885543Smrg    case $arg in
48609885543Smrg    -o)
48709885543Smrg      shift
48809885543Smrg      ;;
48909885543Smrg    $object)
49009885543Smrg      shift
49109885543Smrg      ;;
49209885543Smrg    *)
49309885543Smrg      set fnord "$@" "$arg"
49409885543Smrg      shift # fnord
49509885543Smrg      shift # $arg
49609885543Smrg      ;;
49709885543Smrg    esac
49809885543Smrg  done
49909885543Smrg
50009885543Smrg  test -z "$dashmflag" && dashmflag=-M
50109885543Smrg  # Require at least two characters before searching for `:'
50209885543Smrg  # in the target name.  This is to cope with DOS-style filenames:
50309885543Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
50409885543Smrg  "$@" $dashmflag |
50509885543Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
50609885543Smrg  rm -f "$depfile"
50709885543Smrg  cat < "$tmpdepfile" > "$depfile"
50809885543Smrg  tr ' ' '
50909885543Smrg' < "$tmpdepfile" | \
51009885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
51109885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
51209885543Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
51309885543Smrg  rm -f "$tmpdepfile"
51409885543Smrg  ;;
51509885543Smrg
51609885543SmrgdashXmstdout)
51709885543Smrg  # This case only exists to satisfy depend.m4.  It is never actually
51809885543Smrg  # run, as this mode is specially recognized in the preamble.
51909885543Smrg  exit 1
52009885543Smrg  ;;
52109885543Smrg
52209885543Smrgmakedepend)
52309885543Smrg  "$@" || exit $?
52409885543Smrg  # Remove any Libtool call
52509885543Smrg  if test "$libtool" = yes; then
526b698ba48Smrg    while test "X$1" != 'X--mode=compile'; do
52709885543Smrg      shift
52809885543Smrg    done
52909885543Smrg    shift
53009885543Smrg  fi
53109885543Smrg  # X makedepend
53209885543Smrg  shift
533b698ba48Smrg  cleared=no eat=no
534b698ba48Smrg  for arg
535b698ba48Smrg  do
53609885543Smrg    case $cleared in
53709885543Smrg    no)
53809885543Smrg      set ""; shift
53909885543Smrg      cleared=yes ;;
54009885543Smrg    esac
541b698ba48Smrg    if test $eat = yes; then
542b698ba48Smrg      eat=no
543b698ba48Smrg      continue
544b698ba48Smrg    fi
54509885543Smrg    case "$arg" in
54609885543Smrg    -D*|-I*)
54709885543Smrg      set fnord "$@" "$arg"; shift ;;
54809885543Smrg    # Strip any option that makedepend may not understand.  Remove
54909885543Smrg    # the object too, otherwise makedepend will parse it as a source file.
550b698ba48Smrg    -arch)
551b698ba48Smrg      eat=yes ;;
55209885543Smrg    -*|$object)
55309885543Smrg      ;;
55409885543Smrg    *)
55509885543Smrg      set fnord "$@" "$arg"; shift ;;
55609885543Smrg    esac
55709885543Smrg  done
558b698ba48Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
55909885543Smrg  touch "$tmpdepfile"
56009885543Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
56109885543Smrg  rm -f "$depfile"
562b12e5c03Smrg  # makedepend may prepend the VPATH from the source file name to the object.
563b12e5c03Smrg  # No need to regex-escape $object, excess matching of '.' is harmless.
564b12e5c03Smrg  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
56509885543Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
56609885543Smrg' | \
56709885543Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
56809885543Smrg## correctly.  Breaking it into two sed invocations is a workaround.
56909885543Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
57009885543Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
57109885543Smrg  ;;
57209885543Smrg
57309885543Smrgcpp)
57409885543Smrg  # Important note: in order to support this mode, a compiler *must*
57509885543Smrg  # always write the preprocessed file to stdout.
57609885543Smrg  "$@" || exit $?
57709885543Smrg
57809885543Smrg  # Remove the call to Libtool.
57909885543Smrg  if test "$libtool" = yes; then
580b698ba48Smrg    while test "X$1" != 'X--mode=compile'; do
58109885543Smrg      shift
58209885543Smrg    done
58309885543Smrg    shift
58409885543Smrg  fi
58509885543Smrg
58609885543Smrg  # Remove `-o $object'.
58709885543Smrg  IFS=" "
58809885543Smrg  for arg
58909885543Smrg  do
59009885543Smrg    case $arg in
59109885543Smrg    -o)
59209885543Smrg      shift
59309885543Smrg      ;;
59409885543Smrg    $object)
59509885543Smrg      shift
59609885543Smrg      ;;
59709885543Smrg    *)
59809885543Smrg      set fnord "$@" "$arg"
59909885543Smrg      shift # fnord
60009885543Smrg      shift # $arg
60109885543Smrg      ;;
60209885543Smrg    esac
60309885543Smrg  done
60409885543Smrg
60509885543Smrg  "$@" -E |
60609885543Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
60709885543Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
60809885543Smrg    sed '$ s: \\$::' > "$tmpdepfile"
60909885543Smrg  rm -f "$depfile"
61009885543Smrg  echo "$object : \\" > "$depfile"
61109885543Smrg  cat < "$tmpdepfile" >> "$depfile"
61209885543Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
61309885543Smrg  rm -f "$tmpdepfile"
61409885543Smrg  ;;
61509885543Smrg
61609885543Smrgmsvisualcpp)
61709885543Smrg  # Important note: in order to support this mode, a compiler *must*
618b698ba48Smrg  # always write the preprocessed file to stdout.
61909885543Smrg  "$@" || exit $?
620b698ba48Smrg
621b698ba48Smrg  # Remove the call to Libtool.
622b698ba48Smrg  if test "$libtool" = yes; then
623b698ba48Smrg    while test "X$1" != 'X--mode=compile'; do
624b698ba48Smrg      shift
625b698ba48Smrg    done
626b698ba48Smrg    shift
627b698ba48Smrg  fi
628b698ba48Smrg
62909885543Smrg  IFS=" "
63009885543Smrg  for arg
63109885543Smrg  do
63209885543Smrg    case "$arg" in
633b698ba48Smrg    -o)
634b698ba48Smrg      shift
635b698ba48Smrg      ;;
636b698ba48Smrg    $object)
637b698ba48Smrg      shift
638b698ba48Smrg      ;;
63909885543Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
64009885543Smrg	set fnord "$@"
64109885543Smrg	shift
64209885543Smrg	shift
64309885543Smrg	;;
64409885543Smrg    *)
64509885543Smrg	set fnord "$@" "$arg"
64609885543Smrg	shift
64709885543Smrg	shift
64809885543Smrg	;;
64909885543Smrg    esac
65009885543Smrg  done
651b698ba48Smrg  "$@" -E 2>/dev/null |
652b698ba48Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
65309885543Smrg  rm -f "$depfile"
65409885543Smrg  echo "$object : \\" > "$depfile"
655b698ba48Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
65609885543Smrg  echo "	" >> "$depfile"
657b698ba48Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
65809885543Smrg  rm -f "$tmpdepfile"
65909885543Smrg  ;;
66009885543Smrg
661b698ba48Smrgmsvcmsys)
662b698ba48Smrg  # This case exists only to let depend.m4 do its work.  It works by
663b698ba48Smrg  # looking at the text of this script.  This case will never be run,
664b698ba48Smrg  # since it is checked for above.
665b698ba48Smrg  exit 1
666b698ba48Smrg  ;;
667b698ba48Smrg
66809885543Smrgnone)
66909885543Smrg  exec "$@"
67009885543Smrg  ;;
67109885543Smrg
67209885543Smrg*)
67309885543Smrg  echo "Unknown depmode $depmode" 1>&2
67409885543Smrg  exit 1
67509885543Smrg  ;;
67609885543Smrgesac
67709885543Smrg
67809885543Smrgexit 0
67909885543Smrg
68009885543Smrg# Local Variables:
68109885543Smrg# mode: shell-script
68209885543Smrg# sh-indentation: 2
68309885543Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
68409885543Smrg# time-stamp-start: "scriptversion="
68509885543Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
686b698ba48Smrg# time-stamp-time-zone: "UTC"
687b698ba48Smrg# time-stamp-end: "; # UTC"
68809885543Smrg# End:
689