annotate src/portaudio_20161030_catalina_patch/depcomp @ 83:ae30d91d2ffe

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