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