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