annotate src/portaudio_20161030_catalina_patch/depcomp @ 169:223a55898ab9 tip default

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