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