annotate depcomp @ 21:7275f59cab61

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