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