filename | depcomp |
changeset | 179:18dacd91aa73 |
author | nkeynes |
date | Tue Sep 12 13:33:18 2006 +0000 (17 years ago) |
permissions | -rw-r--r-- |
last change | Bug #0002 Implement VQ compression Implemented based on KOS code. |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/depcomp Tue Sep 12 13:33:18 2006 +00001.3 @@ -0,0 +1,479 @@1.4 +#! /bin/sh1.5 +1.6 +# depcomp - compile a program generating dependencies as side-effects1.7 +# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.1.8 +1.9 +# This program is free software; you can redistribute it and/or modify1.10 +# it under the terms of the GNU General Public License as published by1.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 of1.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1.17 +# GNU General Public License for more details.1.18 +1.19 +# You should have received a copy of the GNU General Public License1.20 +# along with this program; if not, write to the Free Software1.21 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA1.22 +# 02111-1307, USA.1.23 +1.24 +# As a special exception to the GNU General Public License, if you1.25 +# distribute this file as part of a program that contains a1.26 +# configuration script generated by Autoconf, you may include it under1.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"; then1.32 + echo "depcomp: Variables source, object and depmode must be set" 1>&21.33 + exit 11.34 +fi1.35 +# `libtool' can also be set to `yes' or `no'.1.36 +1.37 +if test -z "$depfile"; then1.38 + base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`1.39 + dir=`echo "$object" | sed 's,/.*$,/,'`1.40 + if test "$dir" = "$object"; then1.41 + dir=1.42 + fi1.43 + # FIXME: should be _deps on DOS.1.44 + depfile="$dir.deps/$base"1.45 +fi1.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. We1.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 case1.54 +# here, because this file can only contain one case statement.1.55 +if test "$depmode" = hp; then1.56 + # HP compiler uses -M and no extra arg.1.57 + gccflag=-M1.58 + depmode=gcc1.59 +fi1.60 +1.61 +if test "$depmode" = dashXmstdout; then1.62 + # This is just like dashmstdout with a different argument.1.63 + dashmflag=-xM1.64 + depmode=dashmstdout1.65 +fi1.66 +1.67 +case "$depmode" in1.68 +gcc3)1.69 +## gcc 3 implements dependency tracking that does exactly what1.70 +## we want. Yay! Note: for some reason libtool 1.4 doesn't like1.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 + else1.76 + rm -f "$tmpdepfile"1.77 + exit $stat1.78 + fi1.79 + mv "$tmpdepfile" "$depfile"1.80 + ;;1.81 +1.82 +gcc)1.83 +## There are various ways to get dependency output from gcc. Here's1.84 +## why we pick this rather obscure method:1.85 +## - Don't want to use -MD because we'd like the dependencies to end1.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 like1.89 +## -MM, not -M (despite what the docs say).1.90 +## - Using -M directly means running the compiler twice (even worse1.91 +## than renaming).1.92 + if test -z "$gccflag"; then1.93 + gccflag=-MD,1.94 + fi1.95 + "$@" -Wp,"$gccflag$tmpdepfile"1.96 + stat=$?1.97 + if test $stat -eq 0; then :1.98 + else1.99 + rm -f "$tmpdepfile"1.100 + exit $stat1.101 + fi1.102 + rm -f "$depfile"1.103 + echo "$object : \\" > "$depfile"1.104 + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1.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 file1.110 +## is deleted, the dependency causes make to die (because there is1.111 +## typically no way to rebuild the header). We avoid this by adding1.112 +## dummy dependencies for each header file. Too bad gcc doesn't do1.113 +## this for us directly.1.114 + tr ' ' '1.115 +' < "$tmpdepfile" |1.116 +## Some versions of gcc put a space before the `:'. On the theory1.117 +## that the space means something, we add a space to the output as1.118 +## well.1.119 +## Some versions of the HPUX 10.20 sed can't process this invocation1.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 by1.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 11.130 + ;;1.131 +1.132 +sgi)1.133 + if test "$libtool" = yes; then1.134 + "$@" "-Wp,-MDupdate,$tmpdepfile"1.135 + else1.136 + "$@" -MDupdate "$tmpdepfile"1.137 + fi1.138 + stat=$?1.139 + if test $stat -eq 0; then :1.140 + else1.141 + rm -f "$tmpdepfile"1.142 + exit $stat1.143 + fi1.144 + rm -f "$depfile"1.145 +1.146 + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files1.147 + echo "$object : \\" > "$depfile"1.148 +1.149 + # Clip off the initial element (the dependent). Don't try to be1.150 + # clever and replace this with sed code, as IRIX sed won't handle1.151 + # lines with more than a fixed number of characters (4096 in1.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 the1.154 + # dependency line.1.155 + tr ' ' '1.156 +' < "$tmpdepfile" \1.157 + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \1.158 + tr '1.159 +' ' ' >> $depfile1.160 + echo >> $depfile1.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 + >> $depfile1.167 + else1.168 + # The sourcefile does not contain any dependencies, so just1.169 + # store a dummy comment line, to avoid errors with the Makefile1.170 + # "include basename.Plo" scheme.1.171 + echo "#dummy" > "$depfile"1.172 + fi1.173 + rm -f "$tmpdepfile"1.174 + ;;1.175 +1.176 +aix)1.177 + # The C for AIX Compiler uses -M and outputs the dependencies1.178 + # in a .u file. In older versions, this file always lives in the1.179 + # current directory. Also, the AIX compiler puts `$object:' at the1.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; then1.185 + "$@" -Wc,-M1.186 + else1.187 + "$@" -M1.188 + fi1.189 + stat=$?1.190 +1.191 + if test -f "$tmpdepfile"; then :1.192 + else1.193 + stripped=`echo "$stripped" | sed 's,^.*/,,'`1.194 + tmpdepfile="$stripped.u"1.195 + fi1.196 +1.197 + if test $stat -eq 0; then :1.198 + else1.199 + rm -f "$tmpdepfile"1.200 + exit $stat1.201 + fi1.202 +1.203 + if test -f "$tmpdepfile"; then1.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 to1.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 + else1.211 + # The sourcefile does not contain any dependencies, so just1.212 + # store a dummy comment line, to avoid errors with the Makefile1.213 + # "include basename.Plo" scheme.1.214 + echo "#dummy" > "$depfile"1.215 + fi1.216 + rm -f "$tmpdepfile"1.217 + ;;1.218 +1.219 +icc)1.220 + # Intel's C compiler understands `-MD -MF file'. However on1.221 + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c1.222 + # ICC 7.0 will fill foo.d with something like1.223 + # foo.o: sub/foo.c1.224 + # foo.o: sub/foo.h1.225 + # which is wrong. We want:1.226 + # sub/foo.o: sub/foo.c1.227 + # sub/foo.o: sub/foo.h1.228 + # sub/foo.c:1.229 + # sub/foo.h:1.230 + # ICC 7.1 will output1.231 + # foo.o: sub/foo.c sub/foo.h1.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 + else1.241 + rm -f "$tmpdepfile"1.242 + exit $stat1.243 + fi1.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 to1.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 invocation1.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 side1.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 put1.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; then1.268 + tmpdepfile1="$dir.libs/$base.lo.d"1.269 + tmpdepfile2="$dir.libs/$base.d"1.270 + "$@" -Wc,-MD1.271 + else1.272 + tmpdepfile1="$dir$base.o.d"1.273 + tmpdepfile2="$dir$base.d"1.274 + "$@" -MD1.275 + fi1.276 +1.277 + stat=$?1.278 + if test $stat -eq 0; then :1.279 + else1.280 + rm -f "$tmpdepfile1" "$tmpdepfile2"1.281 + exit $stat1.282 + fi1.283 +1.284 + if test -f "$tmpdepfile1"; then1.285 + tmpdepfile="$tmpdepfile1"1.286 + else1.287 + tmpdepfile="$tmpdepfile2"1.288 + fi1.289 + if test -f "$tmpdepfile"; then1.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 + else1.294 + echo "#dummy" > "$depfile"1.295 + fi1.296 + rm -f "$tmpdepfile"1.297 + ;;1.298 +1.299 +#nosideeffect)1.300 + # This comment above is used by automake to tell side-effect1.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; then1.310 + while test $1 != '--mode=compile'; do1.311 + shift1.312 + done1.313 + shift1.314 + fi1.315 +1.316 + # Remove `-o $object'.1.317 + IFS=" "1.318 + for arg1.319 + do1.320 + case $arg in1.321 + -o)1.322 + shift1.323 + ;;1.324 + $object)1.325 + shift1.326 + ;;1.327 + *)1.328 + set fnord "$@" "$arg"1.329 + shift # fnord1.330 + shift # $arg1.331 + ;;1.332 + esac1.333 + done1.334 +1.335 + test -z "$dashmflag" && dashmflag=-M1.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 invocation1.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 actually1.353 + # run, as this mode is specially recognized in the preamble.1.354 + exit 11.355 + ;;1.356 +1.357 +makedepend)1.358 + "$@" || exit $?1.359 + # Remove any Libtool call1.360 + if test "$libtool" = yes; then1.361 + while test $1 != '--mode=compile'; do1.362 + shift1.363 + done1.364 + shift1.365 + fi1.366 + # X makedepend1.367 + shift1.368 + cleared=no1.369 + for arg in "$@"; do1.370 + case $cleared in1.371 + no)1.372 + set ""; shift1.373 + cleared=yes ;;1.374 + esac1.375 + case "$arg" in1.376 + -D*|-I*)1.377 + set fnord "$@" "$arg"; shift ;;1.378 + # Strip any option that makedepend may not understand. Remove1.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 + esac1.385 + done1.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 invocation1.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".bak1.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; then1.406 + while test $1 != '--mode=compile'; do1.407 + shift1.408 + done1.409 + shift1.410 + fi1.411 +1.412 + # Remove `-o $object'.1.413 + IFS=" "1.414 + for arg1.415 + do1.416 + case $arg in1.417 + -o)1.418 + shift1.419 + ;;1.420 + $object)1.421 + shift1.422 + ;;1.423 + *)1.424 + set fnord "$@" "$arg"1.425 + shift # fnord1.426 + shift # $arg1.427 + ;;1.428 + esac1.429 + done1.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 arg1.448 + do1.449 + case "$arg" in1.450 + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")1.451 + set fnord "$@"1.452 + shift1.453 + shift1.454 + ;;1.455 + *)1.456 + set fnord "$@" "$arg"1.457 + shift1.458 + shift1.459 + ;;1.460 + esac1.461 + done1.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>&21.478 + exit 11.479 + ;;1.480 +esac1.481 +1.482 +exit 0
.