cannam@126: #! /bin/sh
cannam@126: # depcomp - compile a program generating dependencies as side-effects
cannam@126: 
cannam@126: scriptversion=2009-04-28.21; # UTC
cannam@126: 
cannam@126: # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
cannam@126: # Software Foundation, Inc.
cannam@126: 
cannam@126: # This program is free software; you can redistribute it and/or modify
cannam@126: # it under the terms of the GNU General Public License as published by
cannam@126: # the Free Software Foundation; either version 2, or (at your option)
cannam@126: # any later version.
cannam@126: 
cannam@126: # This program is distributed in the hope that it will be useful,
cannam@126: # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@126: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
cannam@126: # GNU General Public License for more details.
cannam@126: 
cannam@126: # You should have received a copy of the GNU General Public License
cannam@126: # along with this program.  If not, see .
cannam@126: 
cannam@126: # As a special exception to the GNU General Public License, if you
cannam@126: # distribute this file as part of a program that contains a
cannam@126: # configuration script generated by Autoconf, you may include it under
cannam@126: # the same distribution terms that you use for the rest of that program.
cannam@126: 
cannam@126: # Originally written by Alexandre Oliva .
cannam@126: 
cannam@126: case $1 in
cannam@126:   '')
cannam@126:      echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
cannam@126:      exit 1;
cannam@126:      ;;
cannam@126:   -h | --h*)
cannam@126:     cat <<\EOF
cannam@126: Usage: depcomp [--help] [--version] PROGRAM [ARGS]
cannam@126: 
cannam@126: Run PROGRAMS ARGS to compile a file, generating dependencies
cannam@126: as side-effects.
cannam@126: 
cannam@126: Environment variables:
cannam@126:   depmode     Dependency tracking mode.
cannam@126:   source      Source file read by `PROGRAMS ARGS'.
cannam@126:   object      Object file output by `PROGRAMS ARGS'.
cannam@126:   DEPDIR      directory where to store dependencies.
cannam@126:   depfile     Dependency file to output.
cannam@126:   tmpdepfile  Temporary file to use when outputing dependencies.
cannam@126:   libtool     Whether libtool is used (yes/no).
cannam@126: 
cannam@126: Report bugs to .
cannam@126: EOF
cannam@126:     exit $?
cannam@126:     ;;
cannam@126:   -v | --v*)
cannam@126:     echo "depcomp $scriptversion"
cannam@126:     exit $?
cannam@126:     ;;
cannam@126: esac
cannam@126: 
cannam@126: if test -z "$depmode" || test -z "$source" || test -z "$object"; then
cannam@126:   echo "depcomp: Variables source, object and depmode must be set" 1>&2
cannam@126:   exit 1
cannam@126: fi
cannam@126: 
cannam@126: # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
cannam@126: depfile=${depfile-`echo "$object" |
cannam@126:   sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
cannam@126: tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
cannam@126: 
cannam@126: rm -f "$tmpdepfile"
cannam@126: 
cannam@126: # Some modes work just like other modes, but use different flags.  We
cannam@126: # parameterize here, but still list the modes in the big case below,
cannam@126: # to make depend.m4 easier to write.  Note that we *cannot* use a case
cannam@126: # here, because this file can only contain one case statement.
cannam@126: if test "$depmode" = hp; then
cannam@126:   # HP compiler uses -M and no extra arg.
cannam@126:   gccflag=-M
cannam@126:   depmode=gcc
cannam@126: fi
cannam@126: 
cannam@126: if test "$depmode" = dashXmstdout; then
cannam@126:    # This is just like dashmstdout with a different argument.
cannam@126:    dashmflag=-xM
cannam@126:    depmode=dashmstdout
cannam@126: fi
cannam@126: 
cannam@126: cygpath_u="cygpath -u -f -"
cannam@126: if test "$depmode" = msvcmsys; then
cannam@126:    # This is just like msvisualcpp but w/o cygpath translation.
cannam@126:    # Just convert the backslash-escaped backslashes to single forward
cannam@126:    # slashes to satisfy depend.m4
cannam@126:    cygpath_u="sed s,\\\\\\\\,/,g"
cannam@126:    depmode=msvisualcpp
cannam@126: fi
cannam@126: 
cannam@126: case "$depmode" in
cannam@126: gcc3)
cannam@126: ## gcc 3 implements dependency tracking that does exactly what
cannam@126: ## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
cannam@126: ## it if -MD -MP comes after the -MF stuff.  Hmm.
cannam@126: ## Unfortunately, FreeBSD c89 acceptance of flags depends upon
cannam@126: ## the command line argument order; so add the flags where they
cannam@126: ## appear in depend2.am.  Note that the slowdown incurred here
cannam@126: ## affects only configure: in makefiles, %FASTDEP% shortcuts this.
cannam@126:   for arg
cannam@126:   do
cannam@126:     case $arg in
cannam@126:     -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
cannam@126:     *)  set fnord "$@" "$arg" ;;
cannam@126:     esac
cannam@126:     shift # fnord
cannam@126:     shift # $arg
cannam@126:   done
cannam@126:   "$@"
cannam@126:   stat=$?
cannam@126:   if test $stat -eq 0; then :
cannam@126:   else
cannam@126:     rm -f "$tmpdepfile"
cannam@126:     exit $stat
cannam@126:   fi
cannam@126:   mv "$tmpdepfile" "$depfile"
cannam@126:   ;;
cannam@126: 
cannam@126: gcc)
cannam@126: ## There are various ways to get dependency output from gcc.  Here's
cannam@126: ## why we pick this rather obscure method:
cannam@126: ## - Don't want to use -MD because we'd like the dependencies to end
cannam@126: ##   up in a subdir.  Having to rename by hand is ugly.
cannam@126: ##   (We might end up doing this anyway to support other compilers.)
cannam@126: ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
cannam@126: ##   -MM, not -M (despite what the docs say).
cannam@126: ## - Using -M directly means running the compiler twice (even worse
cannam@126: ##   than renaming).
cannam@126:   if test -z "$gccflag"; then
cannam@126:     gccflag=-MD,
cannam@126:   fi
cannam@126:   "$@" -Wp,"$gccflag$tmpdepfile"
cannam@126:   stat=$?
cannam@126:   if test $stat -eq 0; then :
cannam@126:   else
cannam@126:     rm -f "$tmpdepfile"
cannam@126:     exit $stat
cannam@126:   fi
cannam@126:   rm -f "$depfile"
cannam@126:   echo "$object : \\" > "$depfile"
cannam@126:   alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
cannam@126: ## The second -e expression handles DOS-style file names with drive letters.
cannam@126:   sed -e 's/^[^:]*: / /' \
cannam@126:       -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
cannam@126: ## This next piece of magic avoids the `deleted header file' problem.
cannam@126: ## The problem is that when a header file which appears in a .P file
cannam@126: ## is deleted, the dependency causes make to die (because there is
cannam@126: ## typically no way to rebuild the header).  We avoid this by adding
cannam@126: ## dummy dependencies for each header file.  Too bad gcc doesn't do
cannam@126: ## this for us directly.
cannam@126:   tr ' ' '
cannam@126: ' < "$tmpdepfile" |
cannam@126: ## Some versions of gcc put a space before the `:'.  On the theory
cannam@126: ## that the space means something, we add a space to the output as
cannam@126: ## well.
cannam@126: ## Some versions of the HPUX 10.20 sed can't process this invocation
cannam@126: ## correctly.  Breaking it into two sed invocations is a workaround.
cannam@126:     sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
cannam@126:   rm -f "$tmpdepfile"
cannam@126:   ;;
cannam@126: 
cannam@126: hp)
cannam@126:   # This case exists only to let depend.m4 do its work.  It works by
cannam@126:   # looking at the text of this script.  This case will never be run,
cannam@126:   # since it is checked for above.
cannam@126:   exit 1
cannam@126:   ;;
cannam@126: 
cannam@126: sgi)
cannam@126:   if test "$libtool" = yes; then
cannam@126:     "$@" "-Wp,-MDupdate,$tmpdepfile"
cannam@126:   else
cannam@126:     "$@" -MDupdate "$tmpdepfile"
cannam@126:   fi
cannam@126:   stat=$?
cannam@126:   if test $stat -eq 0; then :
cannam@126:   else
cannam@126:     rm -f "$tmpdepfile"
cannam@126:     exit $stat
cannam@126:   fi
cannam@126:   rm -f "$depfile"
cannam@126: 
cannam@126:   if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
cannam@126:     echo "$object : \\" > "$depfile"
cannam@126: 
cannam@126:     # Clip off the initial element (the dependent).  Don't try to be
cannam@126:     # clever and replace this with sed code, as IRIX sed won't handle
cannam@126:     # lines with more than a fixed number of characters (4096 in
cannam@126:     # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
cannam@126:     # the IRIX cc adds comments like `#:fec' to the end of the
cannam@126:     # dependency line.
cannam@126:     tr ' ' '
cannam@126: ' < "$tmpdepfile" \
cannam@126:     | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
cannam@126:     tr '
cannam@126: ' ' ' >> "$depfile"
cannam@126:     echo >> "$depfile"
cannam@126: 
cannam@126:     # The second pass generates a dummy entry for each header file.
cannam@126:     tr ' ' '
cannam@126: ' < "$tmpdepfile" \
cannam@126:    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
cannam@126:    >> "$depfile"
cannam@126:   else
cannam@126:     # The sourcefile does not contain any dependencies, so just
cannam@126:     # store a dummy comment line, to avoid errors with the Makefile
cannam@126:     # "include basename.Plo" scheme.
cannam@126:     echo "#dummy" > "$depfile"
cannam@126:   fi
cannam@126:   rm -f "$tmpdepfile"
cannam@126:   ;;
cannam@126: 
cannam@126: aix)
cannam@126:   # The C for AIX Compiler uses -M and outputs the dependencies
cannam@126:   # in a .u file.  In older versions, this file always lives in the
cannam@126:   # current directory.  Also, the AIX compiler puts `$object:' at the
cannam@126:   # start of each line; $object doesn't have directory information.
cannam@126:   # Version 6 uses the directory in both cases.
cannam@126:   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
cannam@126:   test "x$dir" = "x$object" && dir=
cannam@126:   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
cannam@126:   if test "$libtool" = yes; then
cannam@126:     tmpdepfile1=$dir$base.u
cannam@126:     tmpdepfile2=$base.u
cannam@126:     tmpdepfile3=$dir.libs/$base.u
cannam@126:     "$@" -Wc,-M
cannam@126:   else
cannam@126:     tmpdepfile1=$dir$base.u
cannam@126:     tmpdepfile2=$dir$base.u
cannam@126:     tmpdepfile3=$dir$base.u
cannam@126:     "$@" -M
cannam@126:   fi
cannam@126:   stat=$?
cannam@126: 
cannam@126:   if test $stat -eq 0; then :
cannam@126:   else
cannam@126:     rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
cannam@126:     exit $stat
cannam@126:   fi
cannam@126: 
cannam@126:   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
cannam@126:   do
cannam@126:     test -f "$tmpdepfile" && break
cannam@126:   done
cannam@126:   if test -f "$tmpdepfile"; then
cannam@126:     # Each line is of the form `foo.o: dependent.h'.
cannam@126:     # Do two passes, one to just change these to
cannam@126:     # `$object: dependent.h' and one to simply `dependent.h:'.
cannam@126:     sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
cannam@126:     # That's a tab and a space in the [].
cannam@126:     sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
cannam@126:   else
cannam@126:     # The sourcefile does not contain any dependencies, so just
cannam@126:     # store a dummy comment line, to avoid errors with the Makefile
cannam@126:     # "include basename.Plo" scheme.
cannam@126:     echo "#dummy" > "$depfile"
cannam@126:   fi
cannam@126:   rm -f "$tmpdepfile"
cannam@126:   ;;
cannam@126: 
cannam@126: icc)
cannam@126:   # Intel's C compiler understands `-MD -MF file'.  However on
cannam@126:   #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
cannam@126:   # ICC 7.0 will fill foo.d with something like
cannam@126:   #    foo.o: sub/foo.c
cannam@126:   #    foo.o: sub/foo.h
cannam@126:   # which is wrong.  We want:
cannam@126:   #    sub/foo.o: sub/foo.c
cannam@126:   #    sub/foo.o: sub/foo.h
cannam@126:   #    sub/foo.c:
cannam@126:   #    sub/foo.h:
cannam@126:   # ICC 7.1 will output
cannam@126:   #    foo.o: sub/foo.c sub/foo.h
cannam@126:   # and will wrap long lines using \ :
cannam@126:   #    foo.o: sub/foo.c ... \
cannam@126:   #     sub/foo.h ... \
cannam@126:   #     ...
cannam@126: 
cannam@126:   "$@" -MD -MF "$tmpdepfile"
cannam@126:   stat=$?
cannam@126:   if test $stat -eq 0; then :
cannam@126:   else
cannam@126:     rm -f "$tmpdepfile"
cannam@126:     exit $stat
cannam@126:   fi
cannam@126:   rm -f "$depfile"
cannam@126:   # Each line is of the form `foo.o: dependent.h',
cannam@126:   # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
cannam@126:   # Do two passes, one to just change these to
cannam@126:   # `$object: dependent.h' and one to simply `dependent.h:'.
cannam@126:   sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
cannam@126:   # Some versions of the HPUX 10.20 sed can't process this invocation
cannam@126:   # correctly.  Breaking it into two sed invocations is a workaround.
cannam@126:   sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
cannam@126:     sed -e 's/$/ :/' >> "$depfile"
cannam@126:   rm -f "$tmpdepfile"
cannam@126:   ;;
cannam@126: 
cannam@126: hp2)
cannam@126:   # The "hp" stanza above does not work with aCC (C++) and HP's ia64
cannam@126:   # compilers, which have integrated preprocessors.  The correct option
cannam@126:   # to use with these is +Maked; it writes dependencies to a file named
cannam@126:   # 'foo.d', which lands next to the object file, wherever that
cannam@126:   # happens to be.
cannam@126:   # Much of this is similar to the tru64 case; see comments there.
cannam@126:   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
cannam@126:   test "x$dir" = "x$object" && dir=
cannam@126:   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
cannam@126:   if test "$libtool" = yes; then
cannam@126:     tmpdepfile1=$dir$base.d
cannam@126:     tmpdepfile2=$dir.libs/$base.d
cannam@126:     "$@" -Wc,+Maked
cannam@126:   else
cannam@126:     tmpdepfile1=$dir$base.d
cannam@126:     tmpdepfile2=$dir$base.d
cannam@126:     "$@" +Maked
cannam@126:   fi
cannam@126:   stat=$?
cannam@126:   if test $stat -eq 0; then :
cannam@126:   else
cannam@126:      rm -f "$tmpdepfile1" "$tmpdepfile2"
cannam@126:      exit $stat
cannam@126:   fi
cannam@126: 
cannam@126:   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
cannam@126:   do
cannam@126:     test -f "$tmpdepfile" && break
cannam@126:   done
cannam@126:   if test -f "$tmpdepfile"; then
cannam@126:     sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
cannam@126:     # Add `dependent.h:' lines.
cannam@126:     sed -ne '2,${
cannam@126: 	       s/^ *//
cannam@126: 	       s/ \\*$//
cannam@126: 	       s/$/:/
cannam@126: 	       p
cannam@126: 	     }' "$tmpdepfile" >> "$depfile"
cannam@126:   else
cannam@126:     echo "#dummy" > "$depfile"
cannam@126:   fi
cannam@126:   rm -f "$tmpdepfile" "$tmpdepfile2"
cannam@126:   ;;
cannam@126: 
cannam@126: tru64)
cannam@126:    # The Tru64 compiler uses -MD to generate dependencies as a side
cannam@126:    # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
cannam@126:    # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
cannam@126:    # dependencies in `foo.d' instead, so we check for that too.
cannam@126:    # Subdirectories are respected.
cannam@126:    dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
cannam@126:    test "x$dir" = "x$object" && dir=
cannam@126:    base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
cannam@126: 
cannam@126:    if test "$libtool" = yes; then
cannam@126:       # With Tru64 cc, shared objects can also be used to make a
cannam@126:       # static library.  This mechanism is used in libtool 1.4 series to
cannam@126:       # handle both shared and static libraries in a single compilation.
cannam@126:       # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
cannam@126:       #
cannam@126:       # With libtool 1.5 this exception was removed, and libtool now
cannam@126:       # generates 2 separate objects for the 2 libraries.  These two
cannam@126:       # compilations output dependencies in $dir.libs/$base.o.d and
cannam@126:       # in $dir$base.o.d.  We have to check for both files, because
cannam@126:       # one of the two compilations can be disabled.  We should prefer
cannam@126:       # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
cannam@126:       # automatically cleaned when .libs/ is deleted, while ignoring
cannam@126:       # the former would cause a distcleancheck panic.
cannam@126:       tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
cannam@126:       tmpdepfile2=$dir$base.o.d          # libtool 1.5
cannam@126:       tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
cannam@126:       tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
cannam@126:       "$@" -Wc,-MD
cannam@126:    else
cannam@126:       tmpdepfile1=$dir$base.o.d
cannam@126:       tmpdepfile2=$dir$base.d
cannam@126:       tmpdepfile3=$dir$base.d
cannam@126:       tmpdepfile4=$dir$base.d
cannam@126:       "$@" -MD
cannam@126:    fi
cannam@126: 
cannam@126:    stat=$?
cannam@126:    if test $stat -eq 0; then :
cannam@126:    else
cannam@126:       rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
cannam@126:       exit $stat
cannam@126:    fi
cannam@126: 
cannam@126:    for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
cannam@126:    do
cannam@126:      test -f "$tmpdepfile" && break
cannam@126:    done
cannam@126:    if test -f "$tmpdepfile"; then
cannam@126:       sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
cannam@126:       # That's a tab and a space in the [].
cannam@126:       sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
cannam@126:    else
cannam@126:       echo "#dummy" > "$depfile"
cannam@126:    fi
cannam@126:    rm -f "$tmpdepfile"
cannam@126:    ;;
cannam@126: 
cannam@126: #nosideeffect)
cannam@126:   # This comment above is used by automake to tell side-effect
cannam@126:   # dependency tracking mechanisms from slower ones.
cannam@126: 
cannam@126: dashmstdout)
cannam@126:   # Important note: in order to support this mode, a compiler *must*
cannam@126:   # always write the preprocessed file to stdout, regardless of -o.
cannam@126:   "$@" || exit $?
cannam@126: 
cannam@126:   # Remove the call to Libtool.
cannam@126:   if test "$libtool" = yes; then
cannam@126:     while test "X$1" != 'X--mode=compile'; do
cannam@126:       shift
cannam@126:     done
cannam@126:     shift
cannam@126:   fi
cannam@126: 
cannam@126:   # Remove `-o $object'.
cannam@126:   IFS=" "
cannam@126:   for arg
cannam@126:   do
cannam@126:     case $arg in
cannam@126:     -o)
cannam@126:       shift
cannam@126:       ;;
cannam@126:     $object)
cannam@126:       shift
cannam@126:       ;;
cannam@126:     *)
cannam@126:       set fnord "$@" "$arg"
cannam@126:       shift # fnord
cannam@126:       shift # $arg
cannam@126:       ;;
cannam@126:     esac
cannam@126:   done
cannam@126: 
cannam@126:   test -z "$dashmflag" && dashmflag=-M
cannam@126:   # Require at least two characters before searching for `:'
cannam@126:   # in the target name.  This is to cope with DOS-style filenames:
cannam@126:   # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
cannam@126:   "$@" $dashmflag |
cannam@126:     sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
cannam@126:   rm -f "$depfile"
cannam@126:   cat < "$tmpdepfile" > "$depfile"
cannam@126:   tr ' ' '
cannam@126: ' < "$tmpdepfile" | \
cannam@126: ## Some versions of the HPUX 10.20 sed can't process this invocation
cannam@126: ## correctly.  Breaking it into two sed invocations is a workaround.
cannam@126:     sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
cannam@126:   rm -f "$tmpdepfile"
cannam@126:   ;;
cannam@126: 
cannam@126: dashXmstdout)
cannam@126:   # This case only exists to satisfy depend.m4.  It is never actually
cannam@126:   # run, as this mode is specially recognized in the preamble.
cannam@126:   exit 1
cannam@126:   ;;
cannam@126: 
cannam@126: makedepend)
cannam@126:   "$@" || exit $?
cannam@126:   # Remove any Libtool call
cannam@126:   if test "$libtool" = yes; then
cannam@126:     while test "X$1" != 'X--mode=compile'; do
cannam@126:       shift
cannam@126:     done
cannam@126:     shift
cannam@126:   fi
cannam@126:   # X makedepend
cannam@126:   shift
cannam@126:   cleared=no eat=no
cannam@126:   for arg
cannam@126:   do
cannam@126:     case $cleared in
cannam@126:     no)
cannam@126:       set ""; shift
cannam@126:       cleared=yes ;;
cannam@126:     esac
cannam@126:     if test $eat = yes; then
cannam@126:       eat=no
cannam@126:       continue
cannam@126:     fi
cannam@126:     case "$arg" in
cannam@126:     -D*|-I*)
cannam@126:       set fnord "$@" "$arg"; shift ;;
cannam@126:     # Strip any option that makedepend may not understand.  Remove
cannam@126:     # the object too, otherwise makedepend will parse it as a source file.
cannam@126:     -arch)
cannam@126:       eat=yes ;;
cannam@126:     -*|$object)
cannam@126:       ;;
cannam@126:     *)
cannam@126:       set fnord "$@" "$arg"; shift ;;
cannam@126:     esac
cannam@126:   done
cannam@126:   obj_suffix=`echo "$object" | sed 's/^.*\././'`
cannam@126:   touch "$tmpdepfile"
cannam@126:   ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
cannam@126:   rm -f "$depfile"
cannam@126:   cat < "$tmpdepfile" > "$depfile"
cannam@126:   sed '1,2d' "$tmpdepfile" | tr ' ' '
cannam@126: ' | \
cannam@126: ## Some versions of the HPUX 10.20 sed can't process this invocation
cannam@126: ## correctly.  Breaking it into two sed invocations is a workaround.
cannam@126:     sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
cannam@126:   rm -f "$tmpdepfile" "$tmpdepfile".bak
cannam@126:   ;;
cannam@126: 
cannam@126: cpp)
cannam@126:   # Important note: in order to support this mode, a compiler *must*
cannam@126:   # always write the preprocessed file to stdout.
cannam@126:   "$@" || exit $?
cannam@126: 
cannam@126:   # Remove the call to Libtool.
cannam@126:   if test "$libtool" = yes; then
cannam@126:     while test "X$1" != 'X--mode=compile'; do
cannam@126:       shift
cannam@126:     done
cannam@126:     shift
cannam@126:   fi
cannam@126: 
cannam@126:   # Remove `-o $object'.
cannam@126:   IFS=" "
cannam@126:   for arg
cannam@126:   do
cannam@126:     case $arg in
cannam@126:     -o)
cannam@126:       shift
cannam@126:       ;;
cannam@126:     $object)
cannam@126:       shift
cannam@126:       ;;
cannam@126:     *)
cannam@126:       set fnord "$@" "$arg"
cannam@126:       shift # fnord
cannam@126:       shift # $arg
cannam@126:       ;;
cannam@126:     esac
cannam@126:   done
cannam@126: 
cannam@126:   "$@" -E |
cannam@126:     sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
cannam@126:        -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
cannam@126:     sed '$ s: \\$::' > "$tmpdepfile"
cannam@126:   rm -f "$depfile"
cannam@126:   echo "$object : \\" > "$depfile"
cannam@126:   cat < "$tmpdepfile" >> "$depfile"
cannam@126:   sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
cannam@126:   rm -f "$tmpdepfile"
cannam@126:   ;;
cannam@126: 
cannam@126: msvisualcpp)
cannam@126:   # Important note: in order to support this mode, a compiler *must*
cannam@126:   # always write the preprocessed file to stdout.
cannam@126:   "$@" || exit $?
cannam@126: 
cannam@126:   # Remove the call to Libtool.
cannam@126:   if test "$libtool" = yes; then
cannam@126:     while test "X$1" != 'X--mode=compile'; do
cannam@126:       shift
cannam@126:     done
cannam@126:     shift
cannam@126:   fi
cannam@126: 
cannam@126:   IFS=" "
cannam@126:   for arg
cannam@126:   do
cannam@126:     case "$arg" in
cannam@126:     -o)
cannam@126:       shift
cannam@126:       ;;
cannam@126:     $object)
cannam@126:       shift
cannam@126:       ;;
cannam@126:     "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
cannam@126: 	set fnord "$@"
cannam@126: 	shift
cannam@126: 	shift
cannam@126: 	;;
cannam@126:     *)
cannam@126: 	set fnord "$@" "$arg"
cannam@126: 	shift
cannam@126: 	shift
cannam@126: 	;;
cannam@126:     esac
cannam@126:   done
cannam@126:   "$@" -E 2>/dev/null |
cannam@126:   sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
cannam@126:   rm -f "$depfile"
cannam@126:   echo "$object : \\" > "$depfile"
cannam@126:   sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
cannam@126:   echo "	" >> "$depfile"
cannam@126:   sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
cannam@126:   rm -f "$tmpdepfile"
cannam@126:   ;;
cannam@126: 
cannam@126: msvcmsys)
cannam@126:   # This case exists only to let depend.m4 do its work.  It works by
cannam@126:   # looking at the text of this script.  This case will never be run,
cannam@126:   # since it is checked for above.
cannam@126:   exit 1
cannam@126:   ;;
cannam@126: 
cannam@126: none)
cannam@126:   exec "$@"
cannam@126:   ;;
cannam@126: 
cannam@126: *)
cannam@126:   echo "Unknown depmode $depmode" 1>&2
cannam@126:   exit 1
cannam@126:   ;;
cannam@126: esac
cannam@126: 
cannam@126: exit 0
cannam@126: 
cannam@126: # Local Variables:
cannam@126: # mode: shell-script
cannam@126: # sh-indentation: 2
cannam@126: # eval: (add-hook 'write-file-hooks 'time-stamp)
cannam@126: # time-stamp-start: "scriptversion="
cannam@126: # time-stamp-format: "%:y-%02m-%02d.%02H"
cannam@126: # time-stamp-time-zone: "UTC"
cannam@126: # time-stamp-end: "; # UTC"
cannam@126: # End: