adamc@1133: #! /bin/sh
adamc@1133: # depcomp - compile a program generating dependencies as side-effects
adamc@1133:
adam@1806: scriptversion=2012-03-27.16; # UTC
adamc@1133:
adam@1693: # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
adam@1806: # 2011, 2012 Free 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@1806: 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@1806: source Source file read by 'PROGRAMS ARGS'.
adam@1806: object Object file output by 'PROGRAMS ARGS'.
adamc@1133: DEPDIR directory where to store dependencies.
adamc@1133: depfile Dependency file to output.
adam@1693: tmpdepfile Temporary file to use when outputting 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:
adam@1806: # A tabulation character.
adam@1806: tab=' '
adam@1806: # A newline character.
adam@1806: nl='
adam@1806: '
adam@1806:
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@1693: cygpath_u='sed s,\\\\,/,g'
adamc@1133: depmode=msvisualcpp
adamc@1133: fi
adamc@1133:
adam@1693: if test "$depmode" = msvc7msys; then
adam@1693: # This is just like msvc7 but w/o cygpath translation.
adam@1693: # Just convert the backslash-escaped backslashes to single forward
adam@1693: # slashes to satisfy depend.m4
adam@1693: cygpath_u='sed s,\\\\,/,g'
adam@1693: depmode=msvc7
adam@1693: fi
adam@1693:
adam@1806: if test "$depmode" = xlc; then
adam@1806: # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
adam@1806: gccflag=-qmakedep=gcc,-MF
adam@1806: depmode=gcc
adam@1806: fi
adam@1806:
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@1806: ## 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@1806: tr ' ' "$nl" < "$tmpdepfile" |
adam@1806: ## 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@1693: ## well. hp depmode also adds that space, but also prefixes the VPATH
adam@1693: ## to the object. Take care to not repeat it in the output.
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@1693: sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
adam@1693: | 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@1806: # the IRIX cc adds comments like '#:fec' to the end of the
adamc@1133: # dependency line.
adam@1806: tr ' ' "$nl" < "$tmpdepfile" \
adamc@1133: | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
adam@1806: tr "$nl" ' ' >> "$depfile"
adamc@1133: echo >> "$depfile"
adamc@1133:
adamc@1133: # The second pass generates a dummy entry for each header file.
adam@1806: tr ' ' "$nl" < "$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:
adam@1806: xlc)
adam@1806: # This case exists only to let depend.m4 do its work. It works by
adam@1806: # looking at the text of this script. This case will never be run,
adam@1806: # since it is checked for above.
adam@1806: exit 1
adam@1806: ;;
adam@1806:
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@1806: # 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@1806: # Each line is of the form 'foo.o: dependent.h'.
adamc@1133: # Do two passes, one to just change these to
adam@1806: # '$object: dependent.h' and one to simply 'dependent.h:'.
adamc@1133: sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
adam@1806: sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -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@1806: # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
adam@1806: # However on
adam@1806: # $CC -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@1806: # 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@1806: # and will wrap long lines using '\':
adamc@1133: # foo.o: sub/foo.c ... \
adamc@1133: # sub/foo.h ... \
adamc@1133: # ...
adam@1806: # tcc 0.9.26 (FIXME still under development at the moment of writing)
adam@1806: # will emit a similar output, but also prepend the continuation lines
adam@1806: # with horizontal tabulation characters.
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@1806: # Each line is of the form 'foo.o: dependent.h',
adam@1806: # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
adamc@1133: # Do two passes, one to just change these to
adam@1806: # '$object: dependent.h' and one to simply 'dependent.h:'.
adam@1806: sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
adam@1806: < "$tmpdepfile" > "$depfile"
adam@1806: sed '
adam@1806: s/[ '"$tab"'][ '"$tab"']*/ /g
adam@1806: s/^ *//
adam@1806: s/ *\\*$//
adam@1806: s/^[^:]*: *//
adam@1806: /^$/d
adam@1806: /:$/d
adam@1806: s/$/ :/
adam@1806: ' < "$tmpdepfile" >> "$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@1806: # 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@1806: # 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@1806: # 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@1806: sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
adamc@1133: else
adamc@1133: echo "#dummy" > "$depfile"
adamc@1133: fi
adamc@1133: rm -f "$tmpdepfile"
adamc@1133: ;;
adamc@1133:
adam@1693: msvc7)
adam@1693: if test "$libtool" = yes; then
adam@1693: showIncludes=-Wc,-showIncludes
adam@1693: else
adam@1693: showIncludes=-showIncludes
adam@1693: fi
adam@1693: "$@" $showIncludes > "$tmpdepfile"
adam@1693: stat=$?
adam@1693: grep -v '^Note: including file: ' "$tmpdepfile"
adam@1693: if test "$stat" = 0; then :
adam@1693: else
adam@1693: rm -f "$tmpdepfile"
adam@1693: exit $stat
adam@1693: fi
adam@1693: rm -f "$depfile"
adam@1693: echo "$object : \\" > "$depfile"
adam@1693: # The first sed program below extracts the file names and escapes
adam@1693: # backslashes for cygpath. The second sed program outputs the file
adam@1693: # name when reading, but also accumulates all include files in the
adam@1693: # hold buffer in order to output them again at the end. This only
adam@1693: # works with sed implementations that can handle large buffers.
adam@1693: sed < "$tmpdepfile" -n '
adam@1693: /^Note: including file: *\(.*\)/ {
adam@1693: s//\1/
adam@1693: s/\\/\\\\/g
adam@1693: p
adam@1693: }' | $cygpath_u | sort -u | sed -n '
adam@1693: s/ /\\ /g
adam@1806: s/\(.*\)/'"$tab"'\1 \\/p
adam@1693: s/.\(.*\) \\/\1:/
adam@1693: H
adam@1693: $ {
adam@1806: s/.*/'"$tab"'/
adam@1693: G
adam@1693: p
adam@1693: }' >> "$depfile"
adam@1693: rm -f "$tmpdepfile"
adam@1693: ;;
adam@1693:
adam@1693: msvc7msys)
adam@1693: # This case exists only to let depend.m4 do its work. It works by
adam@1693: # looking at the text of this script. This case will never be run,
adam@1693: # since it is checked for above.
adam@1693: exit 1
adam@1693: ;;
adam@1693:
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@1806: # 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@1806: # Require at least two characters before searching for ':'
adamc@1133: # in the target name. This is to cope with DOS-style filenames:
adam@1806: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
adamc@1133: "$@" $dashmflag |
adam@1806: sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
adamc@1133: rm -f "$depfile"
adamc@1133: cat < "$tmpdepfile" > "$depfile"
adam@1806: tr ' ' "$nl" < "$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@1693: # makedepend may prepend the VPATH from the source file name to the object.
adam@1693: # No need to regex-escape $object, excess matching of '.' is harmless.
adam@1693: sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
adam@1806: sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
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@1806: # 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@1806: sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
adam@1806: echo "$tab" >> "$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: