annotate src/fftw-3.3.5/depcomp @ 42:2cd0e3b3e1fd

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