diff depcomp @ 0:d39e1d0d75b6

initial add
author paulo@hit-nxdomain.opendns.com
date Sat, 20 Feb 2010 21:18:28 -0800
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/depcomp	Sat Feb 20 21:18:28 2010 -0800
     1.3 @@ -0,0 +1,479 @@
     1.4 +#! /bin/sh
     1.5 +
     1.6 +# depcomp - compile a program generating dependencies as side-effects
     1.7 +# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
     1.8 +
     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.13 +
    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.18 +
    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.22 +# 02111-1307, USA.
    1.23 +
    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.28 +
    1.29 +# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
    1.30 +
    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.33 +  exit 1
    1.34 +fi
    1.35 +# `libtool' can also be set to `yes' or `no'.
    1.36 +
    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.41 +      dir=
    1.42 +   fi
    1.43 +   # FIXME: should be _deps on DOS.
    1.44 +   depfile="$dir.deps/$base"
    1.45 +fi
    1.46 +
    1.47 +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
    1.48 +
    1.49 +rm -f "$tmpdepfile"
    1.50 +
    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.57 +  gccflag=-M
    1.58 +  depmode=gcc
    1.59 +fi
    1.60 +
    1.61 +if test "$depmode" = dashXmstdout; then
    1.62 +   # This is just like dashmstdout with a different argument.
    1.63 +   dashmflag=-xM
    1.64 +   depmode=dashmstdout
    1.65 +fi
    1.66 +
    1.67 +case "$depmode" in
    1.68 +gcc3)
    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.73 +  stat=$?
    1.74 +  if test $stat -eq 0; then :
    1.75 +  else
    1.76 +    rm -f "$tmpdepfile"
    1.77 +    exit $stat
    1.78 +  fi
    1.79 +  mv "$tmpdepfile" "$depfile"
    1.80 +  ;;
    1.81 +
    1.82 +gcc)
    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.91 +##   than renaming).
    1.92 +  if test -z "$gccflag"; then
    1.93 +    gccflag=-MD,
    1.94 +  fi
    1.95 +  "$@" -Wp,"$gccflag$tmpdepfile"
    1.96 +  stat=$?
    1.97 +  if test $stat -eq 0; then :
    1.98 +  else
    1.99 +    rm -f "$tmpdepfile"
   1.100 +    exit $stat
   1.101 +  fi
   1.102 +  rm -f "$depfile"
   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.114 +  tr ' ' '
   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.118 +## well.
   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.123 +  ;;
   1.124 +
   1.125 +hp)
   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.129 +  exit 1
   1.130 +  ;;
   1.131 +
   1.132 +sgi)
   1.133 +  if test "$libtool" = yes; then
   1.134 +    "$@" "-Wp,-MDupdate,$tmpdepfile"
   1.135 +  else
   1.136 +    "$@" -MDupdate "$tmpdepfile"
   1.137 +  fi
   1.138 +  stat=$?
   1.139 +  if test $stat -eq 0; then :
   1.140 +  else
   1.141 +    rm -f "$tmpdepfile"
   1.142 +    exit $stat
   1.143 +  fi
   1.144 +  rm -f "$depfile"
   1.145 +
   1.146 +  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
   1.147 +    echo "$object : \\" > "$depfile"
   1.148 +
   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.155 +    tr ' ' '
   1.156 +' < "$tmpdepfile" \
   1.157 +    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
   1.158 +    tr '
   1.159 +' ' ' >> $depfile
   1.160 +    echo >> $depfile
   1.161 +
   1.162 +    # The second pass generates a dummy entry for each header file.
   1.163 +    tr ' ' '
   1.164 +' < "$tmpdepfile" \
   1.165 +   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
   1.166 +   >> $depfile
   1.167 +  else
   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.172 +  fi
   1.173 +  rm -f "$tmpdepfile"
   1.174 +  ;;
   1.175 +
   1.176 +aix)
   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.185 +    "$@" -Wc,-M
   1.186 +  else
   1.187 +    "$@" -M
   1.188 +  fi
   1.189 +  stat=$?
   1.190 +
   1.191 +  if test -f "$tmpdepfile"; then :
   1.192 +  else
   1.193 +    stripped=`echo "$stripped" | sed 's,^.*/,,'`
   1.194 +    tmpdepfile="$stripped.u"
   1.195 +  fi
   1.196 +
   1.197 +  if test $stat -eq 0; then :
   1.198 +  else
   1.199 +    rm -f "$tmpdepfile"
   1.200 +    exit $stat
   1.201 +  fi
   1.202 +
   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.210 +  else
   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.215 +  fi
   1.216 +  rm -f "$tmpdepfile"
   1.217 +  ;;
   1.218 +
   1.219 +icc)
   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.228 +  #    sub/foo.c:
   1.229 +  #    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.235 +  #     ...
   1.236 +
   1.237 +  "$@" -MD -MF "$tmpdepfile"
   1.238 +  stat=$?
   1.239 +  if test $stat -eq 0; then :
   1.240 +  else
   1.241 +    rm -f "$tmpdepfile"
   1.242 +    exit $stat
   1.243 +  fi
   1.244 +  rm -f "$depfile"
   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.255 +  ;;
   1.256 +
   1.257 +tru64)
   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.266 +
   1.267 +   if test "$libtool" = yes; then
   1.268 +      tmpdepfile1="$dir.libs/$base.lo.d"
   1.269 +      tmpdepfile2="$dir.libs/$base.d"
   1.270 +      "$@" -Wc,-MD
   1.271 +   else
   1.272 +      tmpdepfile1="$dir$base.o.d"
   1.273 +      tmpdepfile2="$dir$base.d"
   1.274 +      "$@" -MD
   1.275 +   fi
   1.276 +
   1.277 +   stat=$?
   1.278 +   if test $stat -eq 0; then :
   1.279 +   else
   1.280 +      rm -f "$tmpdepfile1" "$tmpdepfile2"
   1.281 +      exit $stat
   1.282 +   fi
   1.283 +
   1.284 +   if test -f "$tmpdepfile1"; then
   1.285 +      tmpdepfile="$tmpdepfile1"
   1.286 +   else
   1.287 +      tmpdepfile="$tmpdepfile2"
   1.288 +   fi
   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.293 +   else
   1.294 +      echo "#dummy" > "$depfile"
   1.295 +   fi
   1.296 +   rm -f "$tmpdepfile"
   1.297 +   ;;
   1.298 +
   1.299 +#nosideeffect)
   1.300 +  # This comment above is used by automake to tell side-effect
   1.301 +  # dependency tracking mechanisms from slower ones.
   1.302 +
   1.303 +dashmstdout)
   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.306 +  "$@" || exit $?
   1.307 +
   1.308 +  # Remove the call to Libtool.
   1.309 +  if test "$libtool" = yes; then
   1.310 +    while test $1 != '--mode=compile'; do
   1.311 +      shift
   1.312 +    done
   1.313 +    shift
   1.314 +  fi
   1.315 +
   1.316 +  # Remove `-o $object'.
   1.317 +  IFS=" "
   1.318 +  for arg
   1.319 +  do
   1.320 +    case $arg in
   1.321 +    -o)
   1.322 +      shift
   1.323 +      ;;
   1.324 +    $object)
   1.325 +      shift
   1.326 +      ;;
   1.327 +    *)
   1.328 +      set fnord "$@" "$arg"
   1.329 +      shift # fnord
   1.330 +      shift # $arg
   1.331 +      ;;
   1.332 +    esac
   1.333 +  done
   1.334 +
   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.341 +  rm -f "$depfile"
   1.342 +  cat < "$tmpdepfile" > "$depfile"
   1.343 +  tr ' ' '
   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.349 +  ;;
   1.350 +
   1.351 +dashXmstdout)
   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.354 +  exit 1
   1.355 +  ;;
   1.356 +
   1.357 +makedepend)
   1.358 +  "$@" || exit $?
   1.359 +  # Remove any Libtool call
   1.360 +  if test "$libtool" = yes; then
   1.361 +    while test $1 != '--mode=compile'; do
   1.362 +      shift
   1.363 +    done
   1.364 +    shift
   1.365 +  fi
   1.366 +  # X makedepend
   1.367 +  shift
   1.368 +  cleared=no
   1.369 +  for arg in "$@"; do
   1.370 +    case $cleared in
   1.371 +    no)
   1.372 +      set ""; shift
   1.373 +      cleared=yes ;;
   1.374 +    esac
   1.375 +    case "$arg" in
   1.376 +    -D*|-I*)
   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.380 +    -*|$object)
   1.381 +      ;;
   1.382 +    *)
   1.383 +      set fnord "$@" "$arg"; shift ;;
   1.384 +    esac
   1.385 +  done
   1.386 +  obj_suffix="`echo $object | sed 's/^.*\././'`"
   1.387 +  touch "$tmpdepfile"
   1.388 +  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
   1.389 +  rm -f "$depfile"
   1.390 +  cat < "$tmpdepfile" > "$depfile"
   1.391 +  sed '1,2d' "$tmpdepfile" | tr ' ' '
   1.392 +' | \
   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.397 +  ;;
   1.398 +
   1.399 +cpp)
   1.400 +  # Important note: in order to support this mode, a compiler *must*
   1.401 +  # always write the preprocessed file to stdout.
   1.402 +  "$@" || exit $?
   1.403 +
   1.404 +  # Remove the call to Libtool.
   1.405 +  if test "$libtool" = yes; then
   1.406 +    while test $1 != '--mode=compile'; do
   1.407 +      shift
   1.408 +    done
   1.409 +    shift
   1.410 +  fi
   1.411 +
   1.412 +  # Remove `-o $object'.
   1.413 +  IFS=" "
   1.414 +  for arg
   1.415 +  do
   1.416 +    case $arg in
   1.417 +    -o)
   1.418 +      shift
   1.419 +      ;;
   1.420 +    $object)
   1.421 +      shift
   1.422 +      ;;
   1.423 +    *)
   1.424 +      set fnord "$@" "$arg"
   1.425 +      shift # fnord
   1.426 +      shift # $arg
   1.427 +      ;;
   1.428 +    esac
   1.429 +  done
   1.430 +
   1.431 +  "$@" -E |
   1.432 +    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
   1.433 +    sed '$ s: \\$::' > "$tmpdepfile"
   1.434 +  rm -f "$depfile"
   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.439 +  ;;
   1.440 +
   1.441 +msvisualcpp)
   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.445 +  "$@" || exit $?
   1.446 +  IFS=" "
   1.447 +  for arg
   1.448 +  do
   1.449 +    case "$arg" in
   1.450 +    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
   1.451 +	set fnord "$@"
   1.452 +	shift
   1.453 +	shift
   1.454 +	;;
   1.455 +    *)
   1.456 +	set fnord "$@" "$arg"
   1.457 +	shift
   1.458 +	shift
   1.459 +	;;
   1.460 +    esac
   1.461 +  done
   1.462 +  "$@" -E |
   1.463 +  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
   1.464 +  rm -f "$depfile"
   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.470 +  ;;
   1.471 +
   1.472 +none)
   1.473 +  exec "$@"
   1.474 +  ;;
   1.475 +
   1.476 +*)
   1.477 +  echo "Unknown depmode $depmode" 1>&2
   1.478 +  exit 1
   1.479 +  ;;
   1.480 +esac
   1.481 +
   1.482 +exit 0