annotate src/libsndfile-1.0.27/Cfg/depcomp @ 125:cd6cdf86811e

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