annotate depcomp @ 1806:40557fb08e98

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