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