annotate src/libsndfile-1.0.27/Cfg/depcomp @ 40:1df64224f5ac

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