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