annotate depcomp @ 1767:1bbad32cb4a8

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