depcomp revision 21c2f794
121c2f794Smrg#! /bin/sh
221c2f794Smrg# depcomp - compile a program generating dependencies as side-effects
321c2f794Smrg
421c2f794Smrgscriptversion=2006-10-15.18
521c2f794Smrg
621c2f794Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
721c2f794Smrg# Foundation, Inc.
821c2f794Smrg
921c2f794Smrg# This program is free software; you can redistribute it and/or modify
1021c2f794Smrg# it under the terms of the GNU General Public License as published by
1121c2f794Smrg# the Free Software Foundation; either version 2, or (at your option)
1221c2f794Smrg# any later version.
1321c2f794Smrg
1421c2f794Smrg# This program is distributed in the hope that it will be useful,
1521c2f794Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1621c2f794Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1721c2f794Smrg# GNU General Public License for more details.
1821c2f794Smrg
1921c2f794Smrg# You should have received a copy of the GNU General Public License
2021c2f794Smrg# along with this program; if not, write to the Free Software
2121c2f794Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2221c2f794Smrg# 02110-1301, USA.
2321c2f794Smrg
2421c2f794Smrg# As a special exception to the GNU General Public License, if you
2521c2f794Smrg# distribute this file as part of a program that contains a
2621c2f794Smrg# configuration script generated by Autoconf, you may include it under
2721c2f794Smrg# the same distribution terms that you use for the rest of that program.
2821c2f794Smrg
2921c2f794Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
3021c2f794Smrg
3121c2f794Smrgcase $1 in
3221c2f794Smrg  '')
3321c2f794Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3421c2f794Smrg     exit 1;
3521c2f794Smrg     ;;
3621c2f794Smrg  -h | --h*)
3721c2f794Smrg    cat <<\EOF
3821c2f794SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3921c2f794Smrg
4021c2f794SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4121c2f794Smrgas side-effects.
4221c2f794Smrg
4321c2f794SmrgEnvironment variables:
4421c2f794Smrg  depmode     Dependency tracking mode.
4521c2f794Smrg  source      Source file read by `PROGRAMS ARGS'.
4621c2f794Smrg  object      Object file output by `PROGRAMS ARGS'.
4721c2f794Smrg  DEPDIR      directory where to store dependencies.
4821c2f794Smrg  depfile     Dependency file to output.
4921c2f794Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
5021c2f794Smrg  libtool     Whether libtool is used (yes/no).
5121c2f794Smrg
5221c2f794SmrgReport bugs to <bug-automake@gnu.org>.
5321c2f794SmrgEOF
5421c2f794Smrg    exit $?
5521c2f794Smrg    ;;
5621c2f794Smrg  -v | --v*)
5721c2f794Smrg    echo "depcomp $scriptversion"
5821c2f794Smrg    exit $?
5921c2f794Smrg    ;;
6021c2f794Smrgesac
6121c2f794Smrg
6221c2f794Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6321c2f794Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6421c2f794Smrg  exit 1
6521c2f794Smrgfi
6621c2f794Smrg
6721c2f794Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6821c2f794Smrgdepfile=${depfile-`echo "$object" |
6921c2f794Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
7021c2f794Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7121c2f794Smrg
7221c2f794Smrgrm -f "$tmpdepfile"
7321c2f794Smrg
7421c2f794Smrg# Some modes work just like other modes, but use different flags.  We
7521c2f794Smrg# parameterize here, but still list the modes in the big case below,
7621c2f794Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7721c2f794Smrg# here, because this file can only contain one case statement.
7821c2f794Smrgif test "$depmode" = hp; then
7921c2f794Smrg  # HP compiler uses -M and no extra arg.
8021c2f794Smrg  gccflag=-M
8121c2f794Smrg  depmode=gcc
8221c2f794Smrgfi
8321c2f794Smrg
8421c2f794Smrgif test "$depmode" = dashXmstdout; then
8521c2f794Smrg   # This is just like dashmstdout with a different argument.
8621c2f794Smrg   dashmflag=-xM
8721c2f794Smrg   depmode=dashmstdout
8821c2f794Smrgfi
8921c2f794Smrg
9021c2f794Smrgcase "$depmode" in
9121c2f794Smrggcc3)
9221c2f794Smrg## gcc 3 implements dependency tracking that does exactly what
9321c2f794Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9421c2f794Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
9521c2f794Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
9621c2f794Smrg## the command line argument order; so add the flags where they
9721c2f794Smrg## appear in depend2.am.  Note that the slowdown incurred here
9821c2f794Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
9921c2f794Smrg  for arg
10021c2f794Smrg  do
10121c2f794Smrg    case $arg in
10221c2f794Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
10321c2f794Smrg    *)  set fnord "$@" "$arg" ;;
10421c2f794Smrg    esac
10521c2f794Smrg    shift # fnord
10621c2f794Smrg    shift # $arg
10721c2f794Smrg  done
10821c2f794Smrg  "$@"
10921c2f794Smrg  stat=$?
11021c2f794Smrg  if test $stat -eq 0; then :
11121c2f794Smrg  else
11221c2f794Smrg    rm -f "$tmpdepfile"
11321c2f794Smrg    exit $stat
11421c2f794Smrg  fi
11521c2f794Smrg  mv "$tmpdepfile" "$depfile"
11621c2f794Smrg  ;;
11721c2f794Smrg
11821c2f794Smrggcc)
11921c2f794Smrg## There are various ways to get dependency output from gcc.  Here's
12021c2f794Smrg## why we pick this rather obscure method:
12121c2f794Smrg## - Don't want to use -MD because we'd like the dependencies to end
12221c2f794Smrg##   up in a subdir.  Having to rename by hand is ugly.
12321c2f794Smrg##   (We might end up doing this anyway to support other compilers.)
12421c2f794Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
12521c2f794Smrg##   -MM, not -M (despite what the docs say).
12621c2f794Smrg## - Using -M directly means running the compiler twice (even worse
12721c2f794Smrg##   than renaming).
12821c2f794Smrg  if test -z "$gccflag"; then
12921c2f794Smrg    gccflag=-MD,
13021c2f794Smrg  fi
13121c2f794Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
13221c2f794Smrg  stat=$?
13321c2f794Smrg  if test $stat -eq 0; then :
13421c2f794Smrg  else
13521c2f794Smrg    rm -f "$tmpdepfile"
13621c2f794Smrg    exit $stat
13721c2f794Smrg  fi
13821c2f794Smrg  rm -f "$depfile"
13921c2f794Smrg  echo "$object : \\" > "$depfile"
14021c2f794Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14121c2f794Smrg## The second -e expression handles DOS-style file names with drive letters.
14221c2f794Smrg  sed -e 's/^[^:]*: / /' \
14321c2f794Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
14421c2f794Smrg## This next piece of magic avoids the `deleted header file' problem.
14521c2f794Smrg## The problem is that when a header file which appears in a .P file
14621c2f794Smrg## is deleted, the dependency causes make to die (because there is
14721c2f794Smrg## typically no way to rebuild the header).  We avoid this by adding
14821c2f794Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
14921c2f794Smrg## this for us directly.
15021c2f794Smrg  tr ' ' '
15121c2f794Smrg' < "$tmpdepfile" |
15221c2f794Smrg## Some versions of gcc put a space before the `:'.  On the theory
15321c2f794Smrg## that the space means something, we add a space to the output as
15421c2f794Smrg## well.
15521c2f794Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
15621c2f794Smrg## correctly.  Breaking it into two sed invocations is a workaround.
15721c2f794Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
15821c2f794Smrg  rm -f "$tmpdepfile"
15921c2f794Smrg  ;;
16021c2f794Smrg
16121c2f794Smrghp)
16221c2f794Smrg  # This case exists only to let depend.m4 do its work.  It works by
16321c2f794Smrg  # looking at the text of this script.  This case will never be run,
16421c2f794Smrg  # since it is checked for above.
16521c2f794Smrg  exit 1
16621c2f794Smrg  ;;
16721c2f794Smrg
16821c2f794Smrgsgi)
16921c2f794Smrg  if test "$libtool" = yes; then
17021c2f794Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17121c2f794Smrg  else
17221c2f794Smrg    "$@" -MDupdate "$tmpdepfile"
17321c2f794Smrg  fi
17421c2f794Smrg  stat=$?
17521c2f794Smrg  if test $stat -eq 0; then :
17621c2f794Smrg  else
17721c2f794Smrg    rm -f "$tmpdepfile"
17821c2f794Smrg    exit $stat
17921c2f794Smrg  fi
18021c2f794Smrg  rm -f "$depfile"
18121c2f794Smrg
18221c2f794Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
18321c2f794Smrg    echo "$object : \\" > "$depfile"
18421c2f794Smrg
18521c2f794Smrg    # Clip off the initial element (the dependent).  Don't try to be
18621c2f794Smrg    # clever and replace this with sed code, as IRIX sed won't handle
18721c2f794Smrg    # lines with more than a fixed number of characters (4096 in
18821c2f794Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
18921c2f794Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
19021c2f794Smrg    # dependency line.
19121c2f794Smrg    tr ' ' '
19221c2f794Smrg' < "$tmpdepfile" \
19321c2f794Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
19421c2f794Smrg    tr '
19521c2f794Smrg' ' ' >> $depfile
19621c2f794Smrg    echo >> $depfile
19721c2f794Smrg
19821c2f794Smrg    # The second pass generates a dummy entry for each header file.
19921c2f794Smrg    tr ' ' '
20021c2f794Smrg' < "$tmpdepfile" \
20121c2f794Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20221c2f794Smrg   >> $depfile
20321c2f794Smrg  else
20421c2f794Smrg    # The sourcefile does not contain any dependencies, so just
20521c2f794Smrg    # store a dummy comment line, to avoid errors with the Makefile
20621c2f794Smrg    # "include basename.Plo" scheme.
20721c2f794Smrg    echo "#dummy" > "$depfile"
20821c2f794Smrg  fi
20921c2f794Smrg  rm -f "$tmpdepfile"
21021c2f794Smrg  ;;
21121c2f794Smrg
21221c2f794Smrgaix)
21321c2f794Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
21421c2f794Smrg  # in a .u file.  In older versions, this file always lives in the
21521c2f794Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
21621c2f794Smrg  # start of each line; $object doesn't have directory information.
21721c2f794Smrg  # Version 6 uses the directory in both cases.
21821c2f794Smrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
21921c2f794Smrg  tmpdepfile="$stripped.u"
22021c2f794Smrg  if test "$libtool" = yes; then
22121c2f794Smrg    "$@" -Wc,-M
22221c2f794Smrg  else
22321c2f794Smrg    "$@" -M
22421c2f794Smrg  fi
22521c2f794Smrg  stat=$?
22621c2f794Smrg
22721c2f794Smrg  if test -f "$tmpdepfile"; then :
22821c2f794Smrg  else
22921c2f794Smrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
23021c2f794Smrg    tmpdepfile="$stripped.u"
23121c2f794Smrg  fi
23221c2f794Smrg
23321c2f794Smrg  if test $stat -eq 0; then :
23421c2f794Smrg  else
23521c2f794Smrg    rm -f "$tmpdepfile"
23621c2f794Smrg    exit $stat
23721c2f794Smrg  fi
23821c2f794Smrg
23921c2f794Smrg  if test -f "$tmpdepfile"; then
24021c2f794Smrg    outname="$stripped.o"
24121c2f794Smrg    # Each line is of the form `foo.o: dependent.h'.
24221c2f794Smrg    # Do two passes, one to just change these to
24321c2f794Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
24421c2f794Smrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
24521c2f794Smrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
24621c2f794Smrg  else
24721c2f794Smrg    # The sourcefile does not contain any dependencies, so just
24821c2f794Smrg    # store a dummy comment line, to avoid errors with the Makefile
24921c2f794Smrg    # "include basename.Plo" scheme.
25021c2f794Smrg    echo "#dummy" > "$depfile"
25121c2f794Smrg  fi
25221c2f794Smrg  rm -f "$tmpdepfile"
25321c2f794Smrg  ;;
25421c2f794Smrg
25521c2f794Smrgicc)
25621c2f794Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
25721c2f794Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
25821c2f794Smrg  # ICC 7.0 will fill foo.d with something like
25921c2f794Smrg  #    foo.o: sub/foo.c
26021c2f794Smrg  #    foo.o: sub/foo.h
26121c2f794Smrg  # which is wrong.  We want:
26221c2f794Smrg  #    sub/foo.o: sub/foo.c
26321c2f794Smrg  #    sub/foo.o: sub/foo.h
26421c2f794Smrg  #    sub/foo.c:
26521c2f794Smrg  #    sub/foo.h:
26621c2f794Smrg  # ICC 7.1 will output
26721c2f794Smrg  #    foo.o: sub/foo.c sub/foo.h
26821c2f794Smrg  # and will wrap long lines using \ :
26921c2f794Smrg  #    foo.o: sub/foo.c ... \
27021c2f794Smrg  #     sub/foo.h ... \
27121c2f794Smrg  #     ...
27221c2f794Smrg
27321c2f794Smrg  "$@" -MD -MF "$tmpdepfile"
27421c2f794Smrg  stat=$?
27521c2f794Smrg  if test $stat -eq 0; then :
27621c2f794Smrg  else
27721c2f794Smrg    rm -f "$tmpdepfile"
27821c2f794Smrg    exit $stat
27921c2f794Smrg  fi
28021c2f794Smrg  rm -f "$depfile"
28121c2f794Smrg  # Each line is of the form `foo.o: dependent.h',
28221c2f794Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
28321c2f794Smrg  # Do two passes, one to just change these to
28421c2f794Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
28521c2f794Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
28621c2f794Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
28721c2f794Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
28821c2f794Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
28921c2f794Smrg    sed -e 's/$/ :/' >> "$depfile"
29021c2f794Smrg  rm -f "$tmpdepfile"
29121c2f794Smrg  ;;
29221c2f794Smrg
29321c2f794Smrghp2)
29421c2f794Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
29521c2f794Smrg  # compilers, which have integrated preprocessors.  The correct option
29621c2f794Smrg  # to use with these is +Maked; it writes dependencies to a file named
29721c2f794Smrg  # 'foo.d', which lands next to the object file, wherever that
29821c2f794Smrg  # happens to be.
29921c2f794Smrg  # Much of this is similar to the tru64 case; see comments there.
30021c2f794Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
30121c2f794Smrg  test "x$dir" = "x$object" && dir=
30221c2f794Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
30321c2f794Smrg  if test "$libtool" = yes; then
30421c2f794Smrg    tmpdepfile1=$dir$base.d
30521c2f794Smrg    tmpdepfile2=$dir.libs/$base.d
30621c2f794Smrg    "$@" -Wc,+Maked
30721c2f794Smrg  else
30821c2f794Smrg    tmpdepfile1=$dir$base.d
30921c2f794Smrg    tmpdepfile2=$dir$base.d
31021c2f794Smrg    "$@" +Maked
31121c2f794Smrg  fi
31221c2f794Smrg  stat=$?
31321c2f794Smrg  if test $stat -eq 0; then :
31421c2f794Smrg  else
31521c2f794Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
31621c2f794Smrg     exit $stat
31721c2f794Smrg  fi
31821c2f794Smrg
31921c2f794Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
32021c2f794Smrg  do
32121c2f794Smrg    test -f "$tmpdepfile" && break
32221c2f794Smrg  done
32321c2f794Smrg  if test -f "$tmpdepfile"; then
32421c2f794Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
32521c2f794Smrg    # Add `dependent.h:' lines.
32621c2f794Smrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
32721c2f794Smrg  else
32821c2f794Smrg    echo "#dummy" > "$depfile"
32921c2f794Smrg  fi
33021c2f794Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
33121c2f794Smrg  ;;
33221c2f794Smrg
33321c2f794Smrgtru64)
33421c2f794Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
33521c2f794Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
33621c2f794Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
33721c2f794Smrg   # dependencies in `foo.d' instead, so we check for that too.
33821c2f794Smrg   # Subdirectories are respected.
33921c2f794Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
34021c2f794Smrg   test "x$dir" = "x$object" && dir=
34121c2f794Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
34221c2f794Smrg
34321c2f794Smrg   if test "$libtool" = yes; then
34421c2f794Smrg      # With Tru64 cc, shared objects can also be used to make a
34521c2f794Smrg      # static library.  This mechanism is used in libtool 1.4 series to
34621c2f794Smrg      # handle both shared and static libraries in a single compilation.
34721c2f794Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
34821c2f794Smrg      #
34921c2f794Smrg      # With libtool 1.5 this exception was removed, and libtool now
35021c2f794Smrg      # generates 2 separate objects for the 2 libraries.  These two
35121c2f794Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
35221c2f794Smrg      # in $dir$base.o.d.  We have to check for both files, because
35321c2f794Smrg      # one of the two compilations can be disabled.  We should prefer
35421c2f794Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
35521c2f794Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
35621c2f794Smrg      # the former would cause a distcleancheck panic.
35721c2f794Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
35821c2f794Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
35921c2f794Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
36021c2f794Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
36121c2f794Smrg      "$@" -Wc,-MD
36221c2f794Smrg   else
36321c2f794Smrg      tmpdepfile1=$dir$base.o.d
36421c2f794Smrg      tmpdepfile2=$dir$base.d
36521c2f794Smrg      tmpdepfile3=$dir$base.d
36621c2f794Smrg      tmpdepfile4=$dir$base.d
36721c2f794Smrg      "$@" -MD
36821c2f794Smrg   fi
36921c2f794Smrg
37021c2f794Smrg   stat=$?
37121c2f794Smrg   if test $stat -eq 0; then :
37221c2f794Smrg   else
37321c2f794Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
37421c2f794Smrg      exit $stat
37521c2f794Smrg   fi
37621c2f794Smrg
37721c2f794Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
37821c2f794Smrg   do
37921c2f794Smrg     test -f "$tmpdepfile" && break
38021c2f794Smrg   done
38121c2f794Smrg   if test -f "$tmpdepfile"; then
38221c2f794Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
38321c2f794Smrg      # That's a tab and a space in the [].
38421c2f794Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
38521c2f794Smrg   else
38621c2f794Smrg      echo "#dummy" > "$depfile"
38721c2f794Smrg   fi
38821c2f794Smrg   rm -f "$tmpdepfile"
38921c2f794Smrg   ;;
39021c2f794Smrg
39121c2f794Smrg#nosideeffect)
39221c2f794Smrg  # This comment above is used by automake to tell side-effect
39321c2f794Smrg  # dependency tracking mechanisms from slower ones.
39421c2f794Smrg
39521c2f794Smrgdashmstdout)
39621c2f794Smrg  # Important note: in order to support this mode, a compiler *must*
39721c2f794Smrg  # always write the preprocessed file to stdout, regardless of -o.
39821c2f794Smrg  "$@" || exit $?
39921c2f794Smrg
40021c2f794Smrg  # Remove the call to Libtool.
40121c2f794Smrg  if test "$libtool" = yes; then
40221c2f794Smrg    while test $1 != '--mode=compile'; do
40321c2f794Smrg      shift
40421c2f794Smrg    done
40521c2f794Smrg    shift
40621c2f794Smrg  fi
40721c2f794Smrg
40821c2f794Smrg  # Remove `-o $object'.
40921c2f794Smrg  IFS=" "
41021c2f794Smrg  for arg
41121c2f794Smrg  do
41221c2f794Smrg    case $arg in
41321c2f794Smrg    -o)
41421c2f794Smrg      shift
41521c2f794Smrg      ;;
41621c2f794Smrg    $object)
41721c2f794Smrg      shift
41821c2f794Smrg      ;;
41921c2f794Smrg    *)
42021c2f794Smrg      set fnord "$@" "$arg"
42121c2f794Smrg      shift # fnord
42221c2f794Smrg      shift # $arg
42321c2f794Smrg      ;;
42421c2f794Smrg    esac
42521c2f794Smrg  done
42621c2f794Smrg
42721c2f794Smrg  test -z "$dashmflag" && dashmflag=-M
42821c2f794Smrg  # Require at least two characters before searching for `:'
42921c2f794Smrg  # in the target name.  This is to cope with DOS-style filenames:
43021c2f794Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
43121c2f794Smrg  "$@" $dashmflag |
43221c2f794Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
43321c2f794Smrg  rm -f "$depfile"
43421c2f794Smrg  cat < "$tmpdepfile" > "$depfile"
43521c2f794Smrg  tr ' ' '
43621c2f794Smrg' < "$tmpdepfile" | \
43721c2f794Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
43821c2f794Smrg## correctly.  Breaking it into two sed invocations is a workaround.
43921c2f794Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
44021c2f794Smrg  rm -f "$tmpdepfile"
44121c2f794Smrg  ;;
44221c2f794Smrg
44321c2f794SmrgdashXmstdout)
44421c2f794Smrg  # This case only exists to satisfy depend.m4.  It is never actually
44521c2f794Smrg  # run, as this mode is specially recognized in the preamble.
44621c2f794Smrg  exit 1
44721c2f794Smrg  ;;
44821c2f794Smrg
44921c2f794Smrgmakedepend)
45021c2f794Smrg  "$@" || exit $?
45121c2f794Smrg  # Remove any Libtool call
45221c2f794Smrg  if test "$libtool" = yes; then
45321c2f794Smrg    while test $1 != '--mode=compile'; do
45421c2f794Smrg      shift
45521c2f794Smrg    done
45621c2f794Smrg    shift
45721c2f794Smrg  fi
45821c2f794Smrg  # X makedepend
45921c2f794Smrg  shift
46021c2f794Smrg  cleared=no
46121c2f794Smrg  for arg in "$@"; do
46221c2f794Smrg    case $cleared in
46321c2f794Smrg    no)
46421c2f794Smrg      set ""; shift
46521c2f794Smrg      cleared=yes ;;
46621c2f794Smrg    esac
46721c2f794Smrg    case "$arg" in
46821c2f794Smrg    -D*|-I*)
46921c2f794Smrg      set fnord "$@" "$arg"; shift ;;
47021c2f794Smrg    # Strip any option that makedepend may not understand.  Remove
47121c2f794Smrg    # the object too, otherwise makedepend will parse it as a source file.
47221c2f794Smrg    -*|$object)
47321c2f794Smrg      ;;
47421c2f794Smrg    *)
47521c2f794Smrg      set fnord "$@" "$arg"; shift ;;
47621c2f794Smrg    esac
47721c2f794Smrg  done
47821c2f794Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
47921c2f794Smrg  touch "$tmpdepfile"
48021c2f794Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
48121c2f794Smrg  rm -f "$depfile"
48221c2f794Smrg  cat < "$tmpdepfile" > "$depfile"
48321c2f794Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
48421c2f794Smrg' | \
48521c2f794Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
48621c2f794Smrg## correctly.  Breaking it into two sed invocations is a workaround.
48721c2f794Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
48821c2f794Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
48921c2f794Smrg  ;;
49021c2f794Smrg
49121c2f794Smrgcpp)
49221c2f794Smrg  # Important note: in order to support this mode, a compiler *must*
49321c2f794Smrg  # always write the preprocessed file to stdout.
49421c2f794Smrg  "$@" || exit $?
49521c2f794Smrg
49621c2f794Smrg  # Remove the call to Libtool.
49721c2f794Smrg  if test "$libtool" = yes; then
49821c2f794Smrg    while test $1 != '--mode=compile'; do
49921c2f794Smrg      shift
50021c2f794Smrg    done
50121c2f794Smrg    shift
50221c2f794Smrg  fi
50321c2f794Smrg
50421c2f794Smrg  # Remove `-o $object'.
50521c2f794Smrg  IFS=" "
50621c2f794Smrg  for arg
50721c2f794Smrg  do
50821c2f794Smrg    case $arg in
50921c2f794Smrg    -o)
51021c2f794Smrg      shift
51121c2f794Smrg      ;;
51221c2f794Smrg    $object)
51321c2f794Smrg      shift
51421c2f794Smrg      ;;
51521c2f794Smrg    *)
51621c2f794Smrg      set fnord "$@" "$arg"
51721c2f794Smrg      shift # fnord
51821c2f794Smrg      shift # $arg
51921c2f794Smrg      ;;
52021c2f794Smrg    esac
52121c2f794Smrg  done
52221c2f794Smrg
52321c2f794Smrg  "$@" -E |
52421c2f794Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
52521c2f794Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
52621c2f794Smrg    sed '$ s: \\$::' > "$tmpdepfile"
52721c2f794Smrg  rm -f "$depfile"
52821c2f794Smrg  echo "$object : \\" > "$depfile"
52921c2f794Smrg  cat < "$tmpdepfile" >> "$depfile"
53021c2f794Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
53121c2f794Smrg  rm -f "$tmpdepfile"
53221c2f794Smrg  ;;
53321c2f794Smrg
53421c2f794Smrgmsvisualcpp)
53521c2f794Smrg  # Important note: in order to support this mode, a compiler *must*
53621c2f794Smrg  # always write the preprocessed file to stdout, regardless of -o,
53721c2f794Smrg  # because we must use -o when running libtool.
53821c2f794Smrg  "$@" || exit $?
53921c2f794Smrg  IFS=" "
54021c2f794Smrg  for arg
54121c2f794Smrg  do
54221c2f794Smrg    case "$arg" in
54321c2f794Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
54421c2f794Smrg	set fnord "$@"
54521c2f794Smrg	shift
54621c2f794Smrg	shift
54721c2f794Smrg	;;
54821c2f794Smrg    *)
54921c2f794Smrg	set fnord "$@" "$arg"
55021c2f794Smrg	shift
55121c2f794Smrg	shift
55221c2f794Smrg	;;
55321c2f794Smrg    esac
55421c2f794Smrg  done
55521c2f794Smrg  "$@" -E |
55621c2f794Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
55721c2f794Smrg  rm -f "$depfile"
55821c2f794Smrg  echo "$object : \\" > "$depfile"
55921c2f794Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
56021c2f794Smrg  echo "	" >> "$depfile"
56121c2f794Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
56221c2f794Smrg  rm -f "$tmpdepfile"
56321c2f794Smrg  ;;
56421c2f794Smrg
56521c2f794Smrgnone)
56621c2f794Smrg  exec "$@"
56721c2f794Smrg  ;;
56821c2f794Smrg
56921c2f794Smrg*)
57021c2f794Smrg  echo "Unknown depmode $depmode" 1>&2
57121c2f794Smrg  exit 1
57221c2f794Smrg  ;;
57321c2f794Smrgesac
57421c2f794Smrg
57521c2f794Smrgexit 0
57621c2f794Smrg
57721c2f794Smrg# Local Variables:
57821c2f794Smrg# mode: shell-script
57921c2f794Smrg# sh-indentation: 2
58021c2f794Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
58121c2f794Smrg# time-stamp-start: "scriptversion="
58221c2f794Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
58321c2f794Smrg# time-stamp-end: "$"
58421c2f794Smrg# End:
585