annotate src/opus-1.3/depcomp @ 73:02caadb7509e

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