annotate depcomp @ 38:8d23d76b5d48

Stop setting an id callback
author Adam Chlipala <adam@chlipala.net>
date Mon, 16 May 2011 22:31:26 -0400
parents 3c209338e596
children
rev   line source
adam@0 1 #! /bin/sh
adam@0 2 # depcomp - compile a program generating dependencies as side-effects
adam@0 3
adam@0 4 scriptversion=2009-04-28.21; # UTC
adam@0 5
adam@0 6 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
adam@0 7 # Software Foundation, Inc.
adam@0 8
adam@0 9 # This program is free software; you can redistribute it and/or modify
adam@0 10 # it under the terms of the GNU General Public License as published by
adam@0 11 # the Free Software Foundation; either version 2, or (at your option)
adam@0 12 # any later version.
adam@0 13
adam@0 14 # This program is distributed in the hope that it will be useful,
adam@0 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
adam@0 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
adam@0 17 # GNU General Public License for more details.
adam@0 18
adam@0 19 # You should have received a copy of the GNU General Public License
adam@0 20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
adam@0 21
adam@0 22 # As a special exception to the GNU General Public License, if you
adam@0 23 # distribute this file as part of a program that contains a
adam@0 24 # configuration script generated by Autoconf, you may include it under
adam@0 25 # the same distribution terms that you use for the rest of that program.
adam@0 26
adam@0 27 # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
adam@0 28
adam@0 29 case $1 in
adam@0 30 '')
adam@0 31 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
adam@0 32 exit 1;
adam@0 33 ;;
adam@0 34 -h | --h*)
adam@0 35 cat <<\EOF
adam@0 36 Usage: depcomp [--help] [--version] PROGRAM [ARGS]
adam@0 37
adam@0 38 Run PROGRAMS ARGS to compile a file, generating dependencies
adam@0 39 as side-effects.
adam@0 40
adam@0 41 Environment variables:
adam@0 42 depmode Dependency tracking mode.
adam@0 43 source Source file read by `PROGRAMS ARGS'.
adam@0 44 object Object file output by `PROGRAMS ARGS'.
adam@0 45 DEPDIR directory where to store dependencies.
adam@0 46 depfile Dependency file to output.
adam@0 47 tmpdepfile Temporary file to use when outputing dependencies.
adam@0 48 libtool Whether libtool is used (yes/no).
adam@0 49
adam@0 50 Report bugs to <bug-automake@gnu.org>.
adam@0 51 EOF
adam@0 52 exit $?
adam@0 53 ;;
adam@0 54 -v | --v*)
adam@0 55 echo "depcomp $scriptversion"
adam@0 56 exit $?
adam@0 57 ;;
adam@0 58 esac
adam@0 59
adam@0 60 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
adam@0 61 echo "depcomp: Variables source, object and depmode must be set" 1>&2
adam@0 62 exit 1
adam@0 63 fi
adam@0 64
adam@0 65 # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
adam@0 66 depfile=${depfile-`echo "$object" |
adam@0 67 sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
adam@0 68 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
adam@0 69
adam@0 70 rm -f "$tmpdepfile"
adam@0 71
adam@0 72 # Some modes work just like other modes, but use different flags. We
adam@0 73 # parameterize here, but still list the modes in the big case below,
adam@0 74 # to make depend.m4 easier to write. Note that we *cannot* use a case
adam@0 75 # here, because this file can only contain one case statement.
adam@0 76 if test "$depmode" = hp; then
adam@0 77 # HP compiler uses -M and no extra arg.
adam@0 78 gccflag=-M
adam@0 79 depmode=gcc
adam@0 80 fi
adam@0 81
adam@0 82 if test "$depmode" = dashXmstdout; then
adam@0 83 # This is just like dashmstdout with a different argument.
adam@0 84 dashmflag=-xM
adam@0 85 depmode=dashmstdout
adam@0 86 fi
adam@0 87
adam@0 88 cygpath_u="cygpath -u -f -"
adam@0 89 if test "$depmode" = msvcmsys; then
adam@0 90 # This is just like msvisualcpp but w/o cygpath translation.
adam@0 91 # Just convert the backslash-escaped backslashes to single forward
adam@0 92 # slashes to satisfy depend.m4
adam@0 93 cygpath_u="sed s,\\\\\\\\,/,g"
adam@0 94 depmode=msvisualcpp
adam@0 95 fi
adam@0 96
adam@0 97 case "$depmode" in
adam@0 98 gcc3)
adam@0 99 ## gcc 3 implements dependency tracking that does exactly what
adam@0 100 ## we want. Yay! Note: for some reason libtool 1.4 doesn't like
adam@0 101 ## it if -MD -MP comes after the -MF stuff. Hmm.
adam@0 102 ## Unfortunately, FreeBSD c89 acceptance of flags depends upon
adam@0 103 ## the command line argument order; so add the flags where they
adam@0 104 ## appear in depend2.am. Note that the slowdown incurred here
adam@0 105 ## affects only configure: in makefiles, %FASTDEP% shortcuts this.
adam@0 106 for arg
adam@0 107 do
adam@0 108 case $arg in
adam@0 109 -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
adam@0 110 *) set fnord "$@" "$arg" ;;
adam@0 111 esac
adam@0 112 shift # fnord
adam@0 113 shift # $arg
adam@0 114 done
adam@0 115 "$@"
adam@0 116 stat=$?
adam@0 117 if test $stat -eq 0; then :
adam@0 118 else
adam@0 119 rm -f "$tmpdepfile"
adam@0 120 exit $stat
adam@0 121 fi
adam@0 122 mv "$tmpdepfile" "$depfile"
adam@0 123 ;;
adam@0 124
adam@0 125 gcc)
adam@0 126 ## There are various ways to get dependency output from gcc. Here's
adam@0 127 ## why we pick this rather obscure method:
adam@0 128 ## - Don't want to use -MD because we'd like the dependencies to end
adam@0 129 ## up in a subdir. Having to rename by hand is ugly.
adam@0 130 ## (We might end up doing this anyway to support other compilers.)
adam@0 131 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
adam@0 132 ## -MM, not -M (despite what the docs say).
adam@0 133 ## - Using -M directly means running the compiler twice (even worse
adam@0 134 ## than renaming).
adam@0 135 if test -z "$gccflag"; then
adam@0 136 gccflag=-MD,
adam@0 137 fi
adam@0 138 "$@" -Wp,"$gccflag$tmpdepfile"
adam@0 139 stat=$?
adam@0 140 if test $stat -eq 0; then :
adam@0 141 else
adam@0 142 rm -f "$tmpdepfile"
adam@0 143 exit $stat
adam@0 144 fi
adam@0 145 rm -f "$depfile"
adam@0 146 echo "$object : \\" > "$depfile"
adam@0 147 alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
adam@0 148 ## The second -e expression handles DOS-style file names with drive letters.
adam@0 149 sed -e 's/^[^:]*: / /' \
adam@0 150 -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
adam@0 151 ## This next piece of magic avoids the `deleted header file' problem.
adam@0 152 ## The problem is that when a header file which appears in a .P file
adam@0 153 ## is deleted, the dependency causes make to die (because there is
adam@0 154 ## typically no way to rebuild the header). We avoid this by adding
adam@0 155 ## dummy dependencies for each header file. Too bad gcc doesn't do
adam@0 156 ## this for us directly.
adam@0 157 tr ' ' '
adam@0 158 ' < "$tmpdepfile" |
adam@0 159 ## Some versions of gcc put a space before the `:'. On the theory
adam@0 160 ## that the space means something, we add a space to the output as
adam@0 161 ## well.
adam@0 162 ## Some versions of the HPUX 10.20 sed can't process this invocation
adam@0 163 ## correctly. Breaking it into two sed invocations is a workaround.
adam@0 164 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
adam@0 165 rm -f "$tmpdepfile"
adam@0 166 ;;
adam@0 167
adam@0 168 hp)
adam@0 169 # This case exists only to let depend.m4 do its work. It works by
adam@0 170 # looking at the text of this script. This case will never be run,
adam@0 171 # since it is checked for above.
adam@0 172 exit 1
adam@0 173 ;;
adam@0 174
adam@0 175 sgi)
adam@0 176 if test "$libtool" = yes; then
adam@0 177 "$@" "-Wp,-MDupdate,$tmpdepfile"
adam@0 178 else
adam@0 179 "$@" -MDupdate "$tmpdepfile"
adam@0 180 fi
adam@0 181 stat=$?
adam@0 182 if test $stat -eq 0; then :
adam@0 183 else
adam@0 184 rm -f "$tmpdepfile"
adam@0 185 exit $stat
adam@0 186 fi
adam@0 187 rm -f "$depfile"
adam@0 188
adam@0 189 if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
adam@0 190 echo "$object : \\" > "$depfile"
adam@0 191
adam@0 192 # Clip off the initial element (the dependent). Don't try to be
adam@0 193 # clever and replace this with sed code, as IRIX sed won't handle
adam@0 194 # lines with more than a fixed number of characters (4096 in
adam@0 195 # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
adam@0 196 # the IRIX cc adds comments like `#:fec' to the end of the
adam@0 197 # dependency line.
adam@0 198 tr ' ' '
adam@0 199 ' < "$tmpdepfile" \
adam@0 200 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
adam@0 201 tr '
adam@0 202 ' ' ' >> "$depfile"
adam@0 203 echo >> "$depfile"
adam@0 204
adam@0 205 # The second pass generates a dummy entry for each header file.
adam@0 206 tr ' ' '
adam@0 207 ' < "$tmpdepfile" \
adam@0 208 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
adam@0 209 >> "$depfile"
adam@0 210 else
adam@0 211 # The sourcefile does not contain any dependencies, so just
adam@0 212 # store a dummy comment line, to avoid errors with the Makefile
adam@0 213 # "include basename.Plo" scheme.
adam@0 214 echo "#dummy" > "$depfile"
adam@0 215 fi
adam@0 216 rm -f "$tmpdepfile"
adam@0 217 ;;
adam@0 218
adam@0 219 aix)
adam@0 220 # The C for AIX Compiler uses -M and outputs the dependencies
adam@0 221 # in a .u file. In older versions, this file always lives in the
adam@0 222 # current directory. Also, the AIX compiler puts `$object:' at the
adam@0 223 # start of each line; $object doesn't have directory information.
adam@0 224 # Version 6 uses the directory in both cases.
adam@0 225 dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
adam@0 226 test "x$dir" = "x$object" && dir=
adam@0 227 base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
adam@0 228 if test "$libtool" = yes; then
adam@0 229 tmpdepfile1=$dir$base.u
adam@0 230 tmpdepfile2=$base.u
adam@0 231 tmpdepfile3=$dir.libs/$base.u
adam@0 232 "$@" -Wc,-M
adam@0 233 else
adam@0 234 tmpdepfile1=$dir$base.u
adam@0 235 tmpdepfile2=$dir$base.u
adam@0 236 tmpdepfile3=$dir$base.u
adam@0 237 "$@" -M
adam@0 238 fi
adam@0 239 stat=$?
adam@0 240
adam@0 241 if test $stat -eq 0; then :
adam@0 242 else
adam@0 243 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
adam@0 244 exit $stat
adam@0 245 fi
adam@0 246
adam@0 247 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
adam@0 248 do
adam@0 249 test -f "$tmpdepfile" && break
adam@0 250 done
adam@0 251 if test -f "$tmpdepfile"; then
adam@0 252 # Each line is of the form `foo.o: dependent.h'.
adam@0 253 # Do two passes, one to just change these to
adam@0 254 # `$object: dependent.h' and one to simply `dependent.h:'.
adam@0 255 sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
adam@0 256 # That's a tab and a space in the [].
adam@0 257 sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
adam@0 258 else
adam@0 259 # The sourcefile does not contain any dependencies, so just
adam@0 260 # store a dummy comment line, to avoid errors with the Makefile
adam@0 261 # "include basename.Plo" scheme.
adam@0 262 echo "#dummy" > "$depfile"
adam@0 263 fi
adam@0 264 rm -f "$tmpdepfile"
adam@0 265 ;;
adam@0 266
adam@0 267 icc)
adam@0 268 # Intel's C compiler understands `-MD -MF file'. However on
adam@0 269 # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
adam@0 270 # ICC 7.0 will fill foo.d with something like
adam@0 271 # foo.o: sub/foo.c
adam@0 272 # foo.o: sub/foo.h
adam@0 273 # which is wrong. We want:
adam@0 274 # sub/foo.o: sub/foo.c
adam@0 275 # sub/foo.o: sub/foo.h
adam@0 276 # sub/foo.c:
adam@0 277 # sub/foo.h:
adam@0 278 # ICC 7.1 will output
adam@0 279 # foo.o: sub/foo.c sub/foo.h
adam@0 280 # and will wrap long lines using \ :
adam@0 281 # foo.o: sub/foo.c ... \
adam@0 282 # sub/foo.h ... \
adam@0 283 # ...
adam@0 284
adam@0 285 "$@" -MD -MF "$tmpdepfile"
adam@0 286 stat=$?
adam@0 287 if test $stat -eq 0; then :
adam@0 288 else
adam@0 289 rm -f "$tmpdepfile"
adam@0 290 exit $stat
adam@0 291 fi
adam@0 292 rm -f "$depfile"
adam@0 293 # Each line is of the form `foo.o: dependent.h',
adam@0 294 # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
adam@0 295 # Do two passes, one to just change these to
adam@0 296 # `$object: dependent.h' and one to simply `dependent.h:'.
adam@0 297 sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
adam@0 298 # Some versions of the HPUX 10.20 sed can't process this invocation
adam@0 299 # correctly. Breaking it into two sed invocations is a workaround.
adam@0 300 sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
adam@0 301 sed -e 's/$/ :/' >> "$depfile"
adam@0 302 rm -f "$tmpdepfile"
adam@0 303 ;;
adam@0 304
adam@0 305 hp2)
adam@0 306 # The "hp" stanza above does not work with aCC (C++) and HP's ia64
adam@0 307 # compilers, which have integrated preprocessors. The correct option
adam@0 308 # to use with these is +Maked; it writes dependencies to a file named
adam@0 309 # 'foo.d', which lands next to the object file, wherever that
adam@0 310 # happens to be.
adam@0 311 # Much of this is similar to the tru64 case; see comments there.
adam@0 312 dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
adam@0 313 test "x$dir" = "x$object" && dir=
adam@0 314 base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
adam@0 315 if test "$libtool" = yes; then
adam@0 316 tmpdepfile1=$dir$base.d
adam@0 317 tmpdepfile2=$dir.libs/$base.d
adam@0 318 "$@" -Wc,+Maked
adam@0 319 else
adam@0 320 tmpdepfile1=$dir$base.d
adam@0 321 tmpdepfile2=$dir$base.d
adam@0 322 "$@" +Maked
adam@0 323 fi
adam@0 324 stat=$?
adam@0 325 if test $stat -eq 0; then :
adam@0 326 else
adam@0 327 rm -f "$tmpdepfile1" "$tmpdepfile2"
adam@0 328 exit $stat
adam@0 329 fi
adam@0 330
adam@0 331 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
adam@0 332 do
adam@0 333 test -f "$tmpdepfile" && break
adam@0 334 done
adam@0 335 if test -f "$tmpdepfile"; then
adam@0 336 sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
adam@0 337 # Add `dependent.h:' lines.
adam@0 338 sed -ne '2,${
adam@0 339 s/^ *//
adam@0 340 s/ \\*$//
adam@0 341 s/$/:/
adam@0 342 p
adam@0 343 }' "$tmpdepfile" >> "$depfile"
adam@0 344 else
adam@0 345 echo "#dummy" > "$depfile"
adam@0 346 fi
adam@0 347 rm -f "$tmpdepfile" "$tmpdepfile2"
adam@0 348 ;;
adam@0 349
adam@0 350 tru64)
adam@0 351 # The Tru64 compiler uses -MD to generate dependencies as a side
adam@0 352 # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
adam@0 353 # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
adam@0 354 # dependencies in `foo.d' instead, so we check for that too.
adam@0 355 # Subdirectories are respected.
adam@0 356 dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
adam@0 357 test "x$dir" = "x$object" && dir=
adam@0 358 base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
adam@0 359
adam@0 360 if test "$libtool" = yes; then
adam@0 361 # With Tru64 cc, shared objects can also be used to make a
adam@0 362 # static library. This mechanism is used in libtool 1.4 series to
adam@0 363 # handle both shared and static libraries in a single compilation.
adam@0 364 # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
adam@0 365 #
adam@0 366 # With libtool 1.5 this exception was removed, and libtool now
adam@0 367 # generates 2 separate objects for the 2 libraries. These two
adam@0 368 # compilations output dependencies in $dir.libs/$base.o.d and
adam@0 369 # in $dir$base.o.d. We have to check for both files, because
adam@0 370 # one of the two compilations can be disabled. We should prefer
adam@0 371 # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
adam@0 372 # automatically cleaned when .libs/ is deleted, while ignoring
adam@0 373 # the former would cause a distcleancheck panic.
adam@0 374 tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
adam@0 375 tmpdepfile2=$dir$base.o.d # libtool 1.5
adam@0 376 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
adam@0 377 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
adam@0 378 "$@" -Wc,-MD
adam@0 379 else
adam@0 380 tmpdepfile1=$dir$base.o.d
adam@0 381 tmpdepfile2=$dir$base.d
adam@0 382 tmpdepfile3=$dir$base.d
adam@0 383 tmpdepfile4=$dir$base.d
adam@0 384 "$@" -MD
adam@0 385 fi
adam@0 386
adam@0 387 stat=$?
adam@0 388 if test $stat -eq 0; then :
adam@0 389 else
adam@0 390 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
adam@0 391 exit $stat
adam@0 392 fi
adam@0 393
adam@0 394 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
adam@0 395 do
adam@0 396 test -f "$tmpdepfile" && break
adam@0 397 done
adam@0 398 if test -f "$tmpdepfile"; then
adam@0 399 sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
adam@0 400 # That's a tab and a space in the [].
adam@0 401 sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
adam@0 402 else
adam@0 403 echo "#dummy" > "$depfile"
adam@0 404 fi
adam@0 405 rm -f "$tmpdepfile"
adam@0 406 ;;
adam@0 407
adam@0 408 #nosideeffect)
adam@0 409 # This comment above is used by automake to tell side-effect
adam@0 410 # dependency tracking mechanisms from slower ones.
adam@0 411
adam@0 412 dashmstdout)
adam@0 413 # Important note: in order to support this mode, a compiler *must*
adam@0 414 # always write the preprocessed file to stdout, regardless of -o.
adam@0 415 "$@" || exit $?
adam@0 416
adam@0 417 # Remove the call to Libtool.
adam@0 418 if test "$libtool" = yes; then
adam@0 419 while test "X$1" != 'X--mode=compile'; do
adam@0 420 shift
adam@0 421 done
adam@0 422 shift
adam@0 423 fi
adam@0 424
adam@0 425 # Remove `-o $object'.
adam@0 426 IFS=" "
adam@0 427 for arg
adam@0 428 do
adam@0 429 case $arg in
adam@0 430 -o)
adam@0 431 shift
adam@0 432 ;;
adam@0 433 $object)
adam@0 434 shift
adam@0 435 ;;
adam@0 436 *)
adam@0 437 set fnord "$@" "$arg"
adam@0 438 shift # fnord
adam@0 439 shift # $arg
adam@0 440 ;;
adam@0 441 esac
adam@0 442 done
adam@0 443
adam@0 444 test -z "$dashmflag" && dashmflag=-M
adam@0 445 # Require at least two characters before searching for `:'
adam@0 446 # in the target name. This is to cope with DOS-style filenames:
adam@0 447 # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
adam@0 448 "$@" $dashmflag |
adam@0 449 sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
adam@0 450 rm -f "$depfile"
adam@0 451 cat < "$tmpdepfile" > "$depfile"
adam@0 452 tr ' ' '
adam@0 453 ' < "$tmpdepfile" | \
adam@0 454 ## Some versions of the HPUX 10.20 sed can't process this invocation
adam@0 455 ## correctly. Breaking it into two sed invocations is a workaround.
adam@0 456 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
adam@0 457 rm -f "$tmpdepfile"
adam@0 458 ;;
adam@0 459
adam@0 460 dashXmstdout)
adam@0 461 # This case only exists to satisfy depend.m4. It is never actually
adam@0 462 # run, as this mode is specially recognized in the preamble.
adam@0 463 exit 1
adam@0 464 ;;
adam@0 465
adam@0 466 makedepend)
adam@0 467 "$@" || exit $?
adam@0 468 # Remove any Libtool call
adam@0 469 if test "$libtool" = yes; then
adam@0 470 while test "X$1" != 'X--mode=compile'; do
adam@0 471 shift
adam@0 472 done
adam@0 473 shift
adam@0 474 fi
adam@0 475 # X makedepend
adam@0 476 shift
adam@0 477 cleared=no eat=no
adam@0 478 for arg
adam@0 479 do
adam@0 480 case $cleared in
adam@0 481 no)
adam@0 482 set ""; shift
adam@0 483 cleared=yes ;;
adam@0 484 esac
adam@0 485 if test $eat = yes; then
adam@0 486 eat=no
adam@0 487 continue
adam@0 488 fi
adam@0 489 case "$arg" in
adam@0 490 -D*|-I*)
adam@0 491 set fnord "$@" "$arg"; shift ;;
adam@0 492 # Strip any option that makedepend may not understand. Remove
adam@0 493 # the object too, otherwise makedepend will parse it as a source file.
adam@0 494 -arch)
adam@0 495 eat=yes ;;
adam@0 496 -*|$object)
adam@0 497 ;;
adam@0 498 *)
adam@0 499 set fnord "$@" "$arg"; shift ;;
adam@0 500 esac
adam@0 501 done
adam@0 502 obj_suffix=`echo "$object" | sed 's/^.*\././'`
adam@0 503 touch "$tmpdepfile"
adam@0 504 ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
adam@0 505 rm -f "$depfile"
adam@0 506 cat < "$tmpdepfile" > "$depfile"
adam@0 507 sed '1,2d' "$tmpdepfile" | tr ' ' '
adam@0 508 ' | \
adam@0 509 ## Some versions of the HPUX 10.20 sed can't process this invocation
adam@0 510 ## correctly. Breaking it into two sed invocations is a workaround.
adam@0 511 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
adam@0 512 rm -f "$tmpdepfile" "$tmpdepfile".bak
adam@0 513 ;;
adam@0 514
adam@0 515 cpp)
adam@0 516 # Important note: in order to support this mode, a compiler *must*
adam@0 517 # always write the preprocessed file to stdout.
adam@0 518 "$@" || exit $?
adam@0 519
adam@0 520 # Remove the call to Libtool.
adam@0 521 if test "$libtool" = yes; then
adam@0 522 while test "X$1" != 'X--mode=compile'; do
adam@0 523 shift
adam@0 524 done
adam@0 525 shift
adam@0 526 fi
adam@0 527
adam@0 528 # Remove `-o $object'.
adam@0 529 IFS=" "
adam@0 530 for arg
adam@0 531 do
adam@0 532 case $arg in
adam@0 533 -o)
adam@0 534 shift
adam@0 535 ;;
adam@0 536 $object)
adam@0 537 shift
adam@0 538 ;;
adam@0 539 *)
adam@0 540 set fnord "$@" "$arg"
adam@0 541 shift # fnord
adam@0 542 shift # $arg
adam@0 543 ;;
adam@0 544 esac
adam@0 545 done
adam@0 546
adam@0 547 "$@" -E |
adam@0 548 sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
adam@0 549 -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
adam@0 550 sed '$ s: \\$::' > "$tmpdepfile"
adam@0 551 rm -f "$depfile"
adam@0 552 echo "$object : \\" > "$depfile"
adam@0 553 cat < "$tmpdepfile" >> "$depfile"
adam@0 554 sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
adam@0 555 rm -f "$tmpdepfile"
adam@0 556 ;;
adam@0 557
adam@0 558 msvisualcpp)
adam@0 559 # Important note: in order to support this mode, a compiler *must*
adam@0 560 # always write the preprocessed file to stdout.
adam@0 561 "$@" || exit $?
adam@0 562
adam@0 563 # Remove the call to Libtool.
adam@0 564 if test "$libtool" = yes; then
adam@0 565 while test "X$1" != 'X--mode=compile'; do
adam@0 566 shift
adam@0 567 done
adam@0 568 shift
adam@0 569 fi
adam@0 570
adam@0 571 IFS=" "
adam@0 572 for arg
adam@0 573 do
adam@0 574 case "$arg" in
adam@0 575 -o)
adam@0 576 shift
adam@0 577 ;;
adam@0 578 $object)
adam@0 579 shift
adam@0 580 ;;
adam@0 581 "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
adam@0 582 set fnord "$@"
adam@0 583 shift
adam@0 584 shift
adam@0 585 ;;
adam@0 586 *)
adam@0 587 set fnord "$@" "$arg"
adam@0 588 shift
adam@0 589 shift
adam@0 590 ;;
adam@0 591 esac
adam@0 592 done
adam@0 593 "$@" -E 2>/dev/null |
adam@0 594 sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
adam@0 595 rm -f "$depfile"
adam@0 596 echo "$object : \\" > "$depfile"
adam@0 597 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
adam@0 598 echo " " >> "$depfile"
adam@0 599 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
adam@0 600 rm -f "$tmpdepfile"
adam@0 601 ;;
adam@0 602
adam@0 603 msvcmsys)
adam@0 604 # This case exists only to let depend.m4 do its work. It works by
adam@0 605 # looking at the text of this script. This case will never be run,
adam@0 606 # since it is checked for above.
adam@0 607 exit 1
adam@0 608 ;;
adam@0 609
adam@0 610 none)
adam@0 611 exec "$@"
adam@0 612 ;;
adam@0 613
adam@0 614 *)
adam@0 615 echo "Unknown depmode $depmode" 1>&2
adam@0 616 exit 1
adam@0 617 ;;
adam@0 618 esac
adam@0 619
adam@0 620 exit 0
adam@0 621
adam@0 622 # Local Variables:
adam@0 623 # mode: shell-script
adam@0 624 # sh-indentation: 2
adam@0 625 # eval: (add-hook 'write-file-hooks 'time-stamp)
adam@0 626 # time-stamp-start: "scriptversion="
adam@0 627 # time-stamp-format: "%:y-%02m-%02d.%02H"
adam@0 628 # time-stamp-time-zone: "UTC"
adam@0 629 # time-stamp-end: "; # UTC"
adam@0 630 # End: