1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/depcomp Mon Jul 28 04:51:04 2008 +0000
1.6 +# depcomp - compile a program generating dependencies as side-effects
1.7 +# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
1.9 +# This program is free software; you can redistribute it and/or modify
1.10 +# it under the terms of the GNU General Public License as published by
1.11 +# the Free Software Foundation; either version 2, or (at your option)
1.12 +# any later version.
1.14 +# This program is distributed in the hope that it will be useful,
1.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 +# GNU General Public License for more details.
1.19 +# You should have received a copy of the GNU General Public License
1.20 +# along with this program; if not, write to the Free Software
1.21 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1.24 +# As a special exception to the GNU General Public License, if you
1.25 +# distribute this file as part of a program that contains a
1.26 +# configuration script generated by Autoconf, you may include it under
1.27 +# the same distribution terms that you use for the rest of that program.
1.29 +# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
1.31 +if test -z "$depmode" || test -z "$source" || test -z "$object"; then
1.32 + echo "depcomp: Variables source, object and depmode must be set" 1>&2
1.35 +# `libtool' can also be set to `yes' or `no'.
1.37 +if test -z "$depfile"; then
1.38 + base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
1.39 + dir=`echo "$object" | sed 's,/.*$,/,'`
1.40 + if test "$dir" = "$object"; then
1.43 + # FIXME: should be _deps on DOS.
1.44 + depfile="$dir.deps/$base"
1.47 +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
1.49 +rm -f "$tmpdepfile"
1.51 +# Some modes work just like other modes, but use different flags. We
1.52 +# parameterize here, but still list the modes in the big case below,
1.53 +# to make depend.m4 easier to write. Note that we *cannot* use a case
1.54 +# here, because this file can only contain one case statement.
1.55 +if test "$depmode" = hp; then
1.56 + # HP compiler uses -M and no extra arg.
1.61 +if test "$depmode" = dashXmstdout; then
1.62 + # This is just like dashmstdout with a different argument.
1.64 + depmode=dashmstdout
1.69 +## gcc 3 implements dependency tracking that does exactly what
1.70 +## we want. Yay! Note: for some reason libtool 1.4 doesn't like
1.71 +## it if -MD -MP comes after the -MF stuff. Hmm.
1.72 + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
1.74 + if test $stat -eq 0; then :
1.76 + rm -f "$tmpdepfile"
1.79 + mv "$tmpdepfile" "$depfile"
1.83 +## There are various ways to get dependency output from gcc. Here's
1.84 +## why we pick this rather obscure method:
1.85 +## - Don't want to use -MD because we'd like the dependencies to end
1.86 +## up in a subdir. Having to rename by hand is ugly.
1.87 +## (We might end up doing this anyway to support other compilers.)
1.88 +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1.89 +## -MM, not -M (despite what the docs say).
1.90 +## - Using -M directly means running the compiler twice (even worse
1.92 + if test -z "$gccflag"; then
1.95 + "$@" -Wp,"$gccflag$tmpdepfile"
1.97 + if test $stat -eq 0; then :
1.99 + rm -f "$tmpdepfile"
1.103 + echo "$object : \\" > "$depfile"
1.104 + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1.105 +## The second -e expression handles DOS-style file names with drive letters.
1.106 + sed -e 's/^[^:]*: / /' \
1.107 + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1.108 +## This next piece of magic avoids the `deleted header file' problem.
1.109 +## The problem is that when a header file which appears in a .P file
1.110 +## is deleted, the dependency causes make to die (because there is
1.111 +## typically no way to rebuild the header). We avoid this by adding
1.112 +## dummy dependencies for each header file. Too bad gcc doesn't do
1.113 +## this for us directly.
1.115 +' < "$tmpdepfile" |
1.116 +## Some versions of gcc put a space before the `:'. On the theory
1.117 +## that the space means something, we add a space to the output as
1.119 +## Some versions of the HPUX 10.20 sed can't process this invocation
1.120 +## correctly. Breaking it into two sed invocations is a workaround.
1.121 + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1.122 + rm -f "$tmpdepfile"
1.126 + # This case exists only to let depend.m4 do its work. It works by
1.127 + # looking at the text of this script. This case will never be run,
1.128 + # since it is checked for above.
1.133 + if test "$libtool" = yes; then
1.134 + "$@" "-Wp,-MDupdate,$tmpdepfile"
1.136 + "$@" -MDupdate "$tmpdepfile"
1.139 + if test $stat -eq 0; then :
1.141 + rm -f "$tmpdepfile"
1.146 + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
1.147 + echo "$object : \\" > "$depfile"
1.149 + # Clip off the initial element (the dependent). Don't try to be
1.150 + # clever and replace this with sed code, as IRIX sed won't handle
1.151 + # lines with more than a fixed number of characters (4096 in
1.152 + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
1.153 + # the IRIX cc adds comments like `#:fec' to the end of the
1.154 + # dependency line.
1.156 +' < "$tmpdepfile" \
1.157 + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
1.162 + # The second pass generates a dummy entry for each header file.
1.164 +' < "$tmpdepfile" \
1.165 + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
1.168 + # The sourcefile does not contain any dependencies, so just
1.169 + # store a dummy comment line, to avoid errors with the Makefile
1.170 + # "include basename.Plo" scheme.
1.171 + echo "#dummy" > "$depfile"
1.173 + rm -f "$tmpdepfile"
1.177 + # The C for AIX Compiler uses -M and outputs the dependencies
1.178 + # in a .u file. In older versions, this file always lives in the
1.179 + # current directory. Also, the AIX compiler puts `$object:' at the
1.180 + # start of each line; $object doesn't have directory information.
1.181 + # Version 6 uses the directory in both cases.
1.182 + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
1.183 + tmpdepfile="$stripped.u"
1.184 + if test "$libtool" = yes; then
1.191 + if test -f "$tmpdepfile"; then :
1.193 + stripped=`echo "$stripped" | sed 's,^.*/,,'`
1.194 + tmpdepfile="$stripped.u"
1.197 + if test $stat -eq 0; then :
1.199 + rm -f "$tmpdepfile"
1.203 + if test -f "$tmpdepfile"; then
1.204 + outname="$stripped.o"
1.205 + # Each line is of the form `foo.o: dependent.h'.
1.206 + # Do two passes, one to just change these to
1.207 + # `$object: dependent.h' and one to simply `dependent.h:'.
1.208 + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
1.209 + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
1.211 + # The sourcefile does not contain any dependencies, so just
1.212 + # store a dummy comment line, to avoid errors with the Makefile
1.213 + # "include basename.Plo" scheme.
1.214 + echo "#dummy" > "$depfile"
1.216 + rm -f "$tmpdepfile"
1.220 + # Intel's C compiler understands `-MD -MF file'. However on
1.221 + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
1.222 + # ICC 7.0 will fill foo.d with something like
1.223 + # foo.o: sub/foo.c
1.224 + # foo.o: sub/foo.h
1.225 + # which is wrong. We want:
1.226 + # sub/foo.o: sub/foo.c
1.227 + # sub/foo.o: sub/foo.h
1.230 + # ICC 7.1 will output
1.231 + # foo.o: sub/foo.c sub/foo.h
1.232 + # and will wrap long lines using \ :
1.233 + # foo.o: sub/foo.c ... \
1.234 + # sub/foo.h ... \
1.237 + "$@" -MD -MF "$tmpdepfile"
1.239 + if test $stat -eq 0; then :
1.241 + rm -f "$tmpdepfile"
1.245 + # Each line is of the form `foo.o: dependent.h',
1.246 + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
1.247 + # Do two passes, one to just change these to
1.248 + # `$object: dependent.h' and one to simply `dependent.h:'.
1.249 + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
1.250 + # Some versions of the HPUX 10.20 sed can't process this invocation
1.251 + # correctly. Breaking it into two sed invocations is a workaround.
1.252 + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
1.253 + sed -e 's/$/ :/' >> "$depfile"
1.254 + rm -f "$tmpdepfile"
1.258 + # The Tru64 compiler uses -MD to generate dependencies as a side
1.259 + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
1.260 + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
1.261 + # dependencies in `foo.d' instead, so we check for that too.
1.262 + # Subdirectories are respected.
1.263 + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
1.264 + test "x$dir" = "x$object" && dir=
1.265 + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
1.267 + if test "$libtool" = yes; then
1.268 + tmpdepfile1="$dir.libs/$base.lo.d"
1.269 + tmpdepfile2="$dir.libs/$base.d"
1.272 + tmpdepfile1="$dir$base.o.d"
1.273 + tmpdepfile2="$dir$base.d"
1.278 + if test $stat -eq 0; then :
1.280 + rm -f "$tmpdepfile1" "$tmpdepfile2"
1.284 + if test -f "$tmpdepfile1"; then
1.285 + tmpdepfile="$tmpdepfile1"
1.287 + tmpdepfile="$tmpdepfile2"
1.289 + if test -f "$tmpdepfile"; then
1.290 + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
1.291 + # That's a tab and a space in the [].
1.292 + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
1.294 + echo "#dummy" > "$depfile"
1.296 + rm -f "$tmpdepfile"
1.300 + # This comment above is used by automake to tell side-effect
1.301 + # dependency tracking mechanisms from slower ones.
1.304 + # Important note: in order to support this mode, a compiler *must*
1.305 + # always write the preprocessed file to stdout, regardless of -o.
1.308 + # Remove the call to Libtool.
1.309 + if test "$libtool" = yes; then
1.310 + while test $1 != '--mode=compile'; do
1.316 + # Remove `-o $object'.
1.328 + set fnord "$@" "$arg"
1.335 + test -z "$dashmflag" && dashmflag=-M
1.336 + # Require at least two characters before searching for `:'
1.337 + # in the target name. This is to cope with DOS-style filenames:
1.338 + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
1.339 + "$@" $dashmflag |
1.340 + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
1.342 + cat < "$tmpdepfile" > "$depfile"
1.344 +' < "$tmpdepfile" | \
1.345 +## Some versions of the HPUX 10.20 sed can't process this invocation
1.346 +## correctly. Breaking it into two sed invocations is a workaround.
1.347 + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1.348 + rm -f "$tmpdepfile"
1.352 + # This case only exists to satisfy depend.m4. It is never actually
1.353 + # run, as this mode is specially recognized in the preamble.
1.359 + # Remove any Libtool call
1.360 + if test "$libtool" = yes; then
1.361 + while test $1 != '--mode=compile'; do
1.369 + for arg in "$@"; do
1.377 + set fnord "$@" "$arg"; shift ;;
1.378 + # Strip any option that makedepend may not understand. Remove
1.379 + # the object too, otherwise makedepend will parse it as a source file.
1.383 + set fnord "$@" "$arg"; shift ;;
1.386 + obj_suffix="`echo $object | sed 's/^.*\././'`"
1.387 + touch "$tmpdepfile"
1.388 + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
1.390 + cat < "$tmpdepfile" > "$depfile"
1.391 + sed '1,2d' "$tmpdepfile" | tr ' ' '
1.393 +## Some versions of the HPUX 10.20 sed can't process this invocation
1.394 +## correctly. Breaking it into two sed invocations is a workaround.
1.395 + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1.396 + rm -f "$tmpdepfile" "$tmpdepfile".bak
1.400 + # Important note: in order to support this mode, a compiler *must*
1.401 + # always write the preprocessed file to stdout.
1.404 + # Remove the call to Libtool.
1.405 + if test "$libtool" = yes; then
1.406 + while test $1 != '--mode=compile'; do
1.412 + # Remove `-o $object'.
1.424 + set fnord "$@" "$arg"
1.432 + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
1.433 + sed '$ s: \\$::' > "$tmpdepfile"
1.435 + echo "$object : \\" > "$depfile"
1.436 + cat < "$tmpdepfile" >> "$depfile"
1.437 + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
1.438 + rm -f "$tmpdepfile"
1.442 + # Important note: in order to support this mode, a compiler *must*
1.443 + # always write the preprocessed file to stdout, regardless of -o,
1.444 + # because we must use -o when running libtool.
1.450 + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
1.456 + set fnord "$@" "$arg"
1.463 + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
1.465 + echo "$object : \\" > "$depfile"
1.466 + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
1.467 + echo " " >> "$depfile"
1.468 + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
1.469 + rm -f "$tmpdepfile"
1.477 + echo "Unknown depmode $depmode" 1>&2