| 1 |
|
#! /bin/sh |
| 2 |
|
# depcomp - compile a program generating dependencies as side-effects |
| 3 |
|
|
| 4 |
< |
scriptversion=2011-12-04.11; # UTC |
| 4 |
> |
scriptversion=2012-03-27.16; # UTC |
| 5 |
|
|
| 6 |
< |
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, |
| 7 |
< |
# 2011 Free Software Foundation, Inc. |
| 6 |
> |
# Copyright (C) 1999-2012 Free Software Foundation, Inc. |
| 7 |
|
|
| 8 |
|
# This program is free software; you can redistribute it and/or modify |
| 9 |
|
# it under the terms of the GNU General Public License as published by |
| 27 |
|
|
| 28 |
|
case $1 in |
| 29 |
|
'') |
| 30 |
< |
echo "$0: No command. Try \`$0 --help' for more information." 1>&2 |
| 30 |
> |
echo "$0: No command. Try '$0 --help' for more information." 1>&2 |
| 31 |
|
exit 1; |
| 32 |
|
;; |
| 33 |
|
-h | --h*) |
| 39 |
|
|
| 40 |
|
Environment variables: |
| 41 |
|
depmode Dependency tracking mode. |
| 42 |
< |
source Source file read by `PROGRAMS ARGS'. |
| 43 |
< |
object Object file output by `PROGRAMS ARGS'. |
| 42 |
> |
source Source file read by 'PROGRAMS ARGS'. |
| 43 |
> |
object Object file output by 'PROGRAMS ARGS'. |
| 44 |
|
DEPDIR directory where to store dependencies. |
| 45 |
|
depfile Dependency file to output. |
| 46 |
|
tmpdepfile Temporary file to use when outputting dependencies. |
| 56 |
|
;; |
| 57 |
|
esac |
| 58 |
|
|
| 59 |
+ |
# A tabulation character. |
| 60 |
+ |
tab=' ' |
| 61 |
+ |
# A newline character. |
| 62 |
+ |
nl=' |
| 63 |
+ |
' |
| 64 |
+ |
|
| 65 |
|
if test -z "$depmode" || test -z "$source" || test -z "$object"; then |
| 66 |
|
echo "depcomp: Variables source, object and depmode must be set" 1>&2 |
| 67 |
|
exit 1 |
| 107 |
|
depmode=msvc7 |
| 108 |
|
fi |
| 109 |
|
|
| 110 |
+ |
if test "$depmode" = xlc; then |
| 111 |
+ |
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. |
| 112 |
+ |
gccflag=-qmakedep=gcc,-MF |
| 113 |
+ |
depmode=gcc |
| 114 |
+ |
fi |
| 115 |
+ |
|
| 116 |
|
case "$depmode" in |
| 117 |
|
gcc3) |
| 118 |
|
## gcc 3 implements dependency tracking that does exactly what |
| 167 |
|
## The second -e expression handles DOS-style file names with drive letters. |
| 168 |
|
sed -e 's/^[^:]*: / /' \ |
| 169 |
|
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" |
| 170 |
< |
## This next piece of magic avoids the `deleted header file' problem. |
| 170 |
> |
## This next piece of magic avoids the "deleted header file" problem. |
| 171 |
|
## The problem is that when a header file which appears in a .P file |
| 172 |
|
## is deleted, the dependency causes make to die (because there is |
| 173 |
|
## typically no way to rebuild the header). We avoid this by adding |
| 174 |
|
## dummy dependencies for each header file. Too bad gcc doesn't do |
| 175 |
|
## this for us directly. |
| 176 |
< |
tr ' ' ' |
| 177 |
< |
' < "$tmpdepfile" | |
| 167 |
< |
## Some versions of gcc put a space before the `:'. On the theory |
| 176 |
> |
tr ' ' "$nl" < "$tmpdepfile" | |
| 177 |
> |
## Some versions of gcc put a space before the ':'. On the theory |
| 178 |
|
## that the space means something, we add a space to the output as |
| 179 |
|
## well. hp depmode also adds that space, but also prefixes the VPATH |
| 180 |
|
## to the object. Take care to not repeat it in the output. |
| 213 |
|
# clever and replace this with sed code, as IRIX sed won't handle |
| 214 |
|
# lines with more than a fixed number of characters (4096 in |
| 215 |
|
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; |
| 216 |
< |
# the IRIX cc adds comments like `#:fec' to the end of the |
| 216 |
> |
# the IRIX cc adds comments like '#:fec' to the end of the |
| 217 |
|
# dependency line. |
| 218 |
< |
tr ' ' ' |
| 209 |
< |
' < "$tmpdepfile" \ |
| 218 |
> |
tr ' ' "$nl" < "$tmpdepfile" \ |
| 219 |
|
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ |
| 220 |
< |
tr ' |
| 212 |
< |
' ' ' >> "$depfile" |
| 220 |
> |
tr "$nl" ' ' >> "$depfile" |
| 221 |
|
echo >> "$depfile" |
| 222 |
|
|
| 223 |
|
# The second pass generates a dummy entry for each header file. |
| 224 |
< |
tr ' ' ' |
| 217 |
< |
' < "$tmpdepfile" \ |
| 224 |
> |
tr ' ' "$nl" < "$tmpdepfile" \ |
| 225 |
|
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ |
| 226 |
|
>> "$depfile" |
| 227 |
|
else |
| 233 |
|
rm -f "$tmpdepfile" |
| 234 |
|
;; |
| 235 |
|
|
| 236 |
+ |
xlc) |
| 237 |
+ |
# This case exists only to let depend.m4 do its work. It works by |
| 238 |
+ |
# looking at the text of this script. This case will never be run, |
| 239 |
+ |
# since it is checked for above. |
| 240 |
+ |
exit 1 |
| 241 |
+ |
;; |
| 242 |
+ |
|
| 243 |
|
aix) |
| 244 |
|
# The C for AIX Compiler uses -M and outputs the dependencies |
| 245 |
|
# in a .u file. In older versions, this file always lives in the |
| 246 |
< |
# current directory. Also, the AIX compiler puts `$object:' at the |
| 246 |
> |
# current directory. Also, the AIX compiler puts '$object:' at the |
| 247 |
|
# start of each line; $object doesn't have directory information. |
| 248 |
|
# Version 6 uses the directory in both cases. |
| 249 |
|
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` |
| 273 |
|
test -f "$tmpdepfile" && break |
| 274 |
|
done |
| 275 |
|
if test -f "$tmpdepfile"; then |
| 276 |
< |
# Each line is of the form `foo.o: dependent.h'. |
| 276 |
> |
# Each line is of the form 'foo.o: dependent.h'. |
| 277 |
|
# Do two passes, one to just change these to |
| 278 |
< |
# `$object: dependent.h' and one to simply `dependent.h:'. |
| 278 |
> |
# '$object: dependent.h' and one to simply 'dependent.h:'. |
| 279 |
|
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" |
| 280 |
< |
# That's a tab and a space in the []. |
| 267 |
< |
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" |
| 280 |
> |
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" |
| 281 |
|
else |
| 282 |
|
# The sourcefile does not contain any dependencies, so just |
| 283 |
|
# store a dummy comment line, to avoid errors with the Makefile |
| 288 |
|
;; |
| 289 |
|
|
| 290 |
|
icc) |
| 291 |
< |
# Intel's C compiler understands `-MD -MF file'. However on |
| 292 |
< |
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c |
| 291 |
> |
# Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. |
| 292 |
> |
# However on |
| 293 |
> |
# $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c |
| 294 |
|
# ICC 7.0 will fill foo.d with something like |
| 295 |
|
# foo.o: sub/foo.c |
| 296 |
|
# foo.o: sub/foo.h |
| 297 |
< |
# which is wrong. We want: |
| 297 |
> |
# which is wrong. We want |
| 298 |
|
# sub/foo.o: sub/foo.c |
| 299 |
|
# sub/foo.o: sub/foo.h |
| 300 |
|
# sub/foo.c: |
| 301 |
|
# sub/foo.h: |
| 302 |
|
# ICC 7.1 will output |
| 303 |
|
# foo.o: sub/foo.c sub/foo.h |
| 304 |
< |
# and will wrap long lines using \ : |
| 304 |
> |
# and will wrap long lines using '\': |
| 305 |
|
# foo.o: sub/foo.c ... \ |
| 306 |
|
# sub/foo.h ... \ |
| 307 |
|
# ... |
| 308 |
< |
|
| 308 |
> |
# tcc 0.9.26 (FIXME still under development at the moment of writing) |
| 309 |
> |
# will emit a similar output, but also prepend the continuation lines |
| 310 |
> |
# with horizontal tabulation characters. |
| 311 |
|
"$@" -MD -MF "$tmpdepfile" |
| 312 |
|
stat=$? |
| 313 |
|
if test $stat -eq 0; then : |
| 316 |
|
exit $stat |
| 317 |
|
fi |
| 318 |
|
rm -f "$depfile" |
| 319 |
< |
# Each line is of the form `foo.o: dependent.h', |
| 320 |
< |
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. |
| 319 |
> |
# Each line is of the form 'foo.o: dependent.h', |
| 320 |
> |
# or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. |
| 321 |
|
# Do two passes, one to just change these to |
| 322 |
< |
# `$object: dependent.h' and one to simply `dependent.h:'. |
| 323 |
< |
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" |
| 324 |
< |
# Some versions of the HPUX 10.20 sed can't process this invocation |
| 325 |
< |
# correctly. Breaking it into two sed invocations is a workaround. |
| 326 |
< |
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | |
| 327 |
< |
sed -e 's/$/ :/' >> "$depfile" |
| 322 |
> |
# '$object: dependent.h' and one to simply 'dependent.h:'. |
| 323 |
> |
sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ |
| 324 |
> |
< "$tmpdepfile" > "$depfile" |
| 325 |
> |
sed ' |
| 326 |
> |
s/[ '"$tab"'][ '"$tab"']*/ /g |
| 327 |
> |
s/^ *// |
| 328 |
> |
s/ *\\*$// |
| 329 |
> |
s/^[^:]*: *// |
| 330 |
> |
/^$/d |
| 331 |
> |
/:$/d |
| 332 |
> |
s/$/ :/ |
| 333 |
> |
' < "$tmpdepfile" >> "$depfile" |
| 334 |
|
rm -f "$tmpdepfile" |
| 335 |
|
;; |
| 336 |
|
|
| 366 |
|
done |
| 367 |
|
if test -f "$tmpdepfile"; then |
| 368 |
|
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" |
| 369 |
< |
# Add `dependent.h:' lines. |
| 369 |
> |
# Add 'dependent.h:' lines. |
| 370 |
|
sed -ne '2,${ |
| 371 |
|
s/^ *// |
| 372 |
|
s/ \\*$// |
| 381 |
|
|
| 382 |
|
tru64) |
| 383 |
|
# The Tru64 compiler uses -MD to generate dependencies as a side |
| 384 |
< |
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. |
| 384 |
> |
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. |
| 385 |
|
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put |
| 386 |
< |
# dependencies in `foo.d' instead, so we check for that too. |
| 386 |
> |
# dependencies in 'foo.d' instead, so we check for that too. |
| 387 |
|
# Subdirectories are respected. |
| 388 |
|
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` |
| 389 |
|
test "x$dir" = "x$object" && dir= |
| 429 |
|
done |
| 430 |
|
if test -f "$tmpdepfile"; then |
| 431 |
|
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" |
| 432 |
< |
# That's a tab and a space in the []. |
| 411 |
< |
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" |
| 432 |
> |
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" |
| 433 |
|
else |
| 434 |
|
echo "#dummy" > "$depfile" |
| 435 |
|
fi |
| 464 |
|
p |
| 465 |
|
}' | $cygpath_u | sort -u | sed -n ' |
| 466 |
|
s/ /\\ /g |
| 467 |
< |
s/\(.*\)/ \1 \\/p |
| 467 |
> |
s/\(.*\)/'"$tab"'\1 \\/p |
| 468 |
|
s/.\(.*\) \\/\1:/ |
| 469 |
|
H |
| 470 |
|
$ { |
| 471 |
< |
s/.*/ / |
| 471 |
> |
s/.*/'"$tab"'/ |
| 472 |
|
G |
| 473 |
|
p |
| 474 |
|
}' >> "$depfile" |
| 499 |
|
shift |
| 500 |
|
fi |
| 501 |
|
|
| 502 |
< |
# Remove `-o $object'. |
| 502 |
> |
# Remove '-o $object'. |
| 503 |
|
IFS=" " |
| 504 |
|
for arg |
| 505 |
|
do |
| 519 |
|
done |
| 520 |
|
|
| 521 |
|
test -z "$dashmflag" && dashmflag=-M |
| 522 |
< |
# Require at least two characters before searching for `:' |
| 522 |
> |
# Require at least two characters before searching for ':' |
| 523 |
|
# in the target name. This is to cope with DOS-style filenames: |
| 524 |
< |
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. |
| 524 |
> |
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. |
| 525 |
|
"$@" $dashmflag | |
| 526 |
< |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" |
| 526 |
> |
sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" |
| 527 |
|
rm -f "$depfile" |
| 528 |
|
cat < "$tmpdepfile" > "$depfile" |
| 529 |
< |
tr ' ' ' |
| 509 |
< |
' < "$tmpdepfile" | \ |
| 529 |
> |
tr ' ' "$nl" < "$tmpdepfile" | \ |
| 530 |
|
## Some versions of the HPUX 10.20 sed can't process this invocation |
| 531 |
|
## correctly. Breaking it into two sed invocations is a workaround. |
| 532 |
|
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" |
| 582 |
|
# makedepend may prepend the VPATH from the source file name to the object. |
| 583 |
|
# No need to regex-escape $object, excess matching of '.' is harmless. |
| 584 |
|
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" |
| 585 |
< |
sed '1,2d' "$tmpdepfile" | tr ' ' ' |
| 566 |
< |
' | \ |
| 585 |
> |
sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ |
| 586 |
|
## Some versions of the HPUX 10.20 sed can't process this invocation |
| 587 |
|
## correctly. Breaking it into two sed invocations is a workaround. |
| 588 |
|
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" |
| 602 |
|
shift |
| 603 |
|
fi |
| 604 |
|
|
| 605 |
< |
# Remove `-o $object'. |
| 605 |
> |
# Remove '-o $object'. |
| 606 |
|
IFS=" " |
| 607 |
|
for arg |
| 608 |
|
do |
| 671 |
|
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" |
| 672 |
|
rm -f "$depfile" |
| 673 |
|
echo "$object : \\" > "$depfile" |
| 674 |
< |
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" |
| 675 |
< |
echo " " >> "$depfile" |
| 674 |
> |
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" |
| 675 |
> |
echo "$tab" >> "$depfile" |
| 676 |
|
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" |
| 677 |
|
rm -f "$tmpdepfile" |
| 678 |
|
;; |