toolkit/crashreporter/google-breakpad/autotools/depcomp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial