annotate depcomp @ 1579:e1f4ac9ca34b

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