2
2
# depcomp - compile a program generating dependencies as side-effects
4
scriptversion=2004-05-31.23
4
scriptversion=2011-12-04.11; # UTC
6
# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
6
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
7
# 2011 Free Software Foundation, Inc.
8
9
# This program is free software; you can redistribute it and/or modify
9
10
# it under the terms of the GNU General Public License as published by
86
85
depmode=dashmstdout
88
cygpath_u="cygpath -u -f -"
89
if test "$depmode" = msvcmsys; then
90
# This is just like msvisualcpp but w/o cygpath translation.
91
# Just convert the backslash-escaped backslashes to single forward
92
# slashes to satisfy depend.m4
93
cygpath_u='sed s,\\\\,/,g'
97
if test "$depmode" = msvc7msys; then
98
# This is just like msvc7 but w/o cygpath translation.
99
# Just convert the backslash-escaped backslashes to single forward
100
# slashes to satisfy depend.m4
101
cygpath_u='sed s,\\\\,/,g'
89
105
case "$depmode" in
91
107
## gcc 3 implements dependency tracking that does exactly what
92
108
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
93
109
## it if -MD -MP comes after the -MF stuff. Hmm.
94
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
110
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
111
## the command line argument order; so add the flags where they
112
## appear in depend2.am. Note that the slowdown incurred here
113
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
117
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
118
*) set fnord "$@" "$arg" ;;
96
125
if test $stat -eq 0; then :
199
230
# The C for AIX Compiler uses -M and outputs the dependencies
200
231
# in a .u file. In older versions, this file always lives in the
201
# current directory. Also, the AIX compiler puts `$object:' at the
232
# current directory. Also, the AIX compiler puts '$object:' at the
202
233
# start of each line; $object doesn't have directory information.
203
234
# Version 6 uses the directory in both cases.
204
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
205
tmpdepfile="$stripped.u"
235
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
236
test "x$dir" = "x$object" && dir=
237
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
206
238
if test "$libtool" = yes; then
239
tmpdepfile1=$dir$base.u
241
tmpdepfile3=$dir.libs/$base.u
244
tmpdepfile1=$dir$base.u
245
tmpdepfile2=$dir$base.u
246
tmpdepfile3=$dir$base.u
213
if test -f "$tmpdepfile"; then :
215
stripped=`echo "$stripped" | sed 's,^.*/,,'`
216
tmpdepfile="$stripped.u"
219
251
if test $stat -eq 0; then :
253
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
257
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
259
test -f "$tmpdepfile" && break
225
261
if test -f "$tmpdepfile"; then
226
outname="$stripped.o"
227
# Each line is of the form `foo.o: dependent.h'.
262
# Each line is of the form 'foo.o: dependent.h'.
228
263
# Do two passes, one to just change these to
229
# `$object: dependent.h' and one to simply `dependent.h:'.
230
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
231
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
264
# '$object: dependent.h' and one to simply 'dependent.h:'.
265
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
266
# That's a tab and a space in the [].
267
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
233
269
# The sourcefile does not contain any dependencies, so just
234
270
# store a dummy comment line, to avoid errors with the Makefile
267
# Each line is of the form `foo.o: dependent.h',
268
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
303
# Each line is of the form 'foo.o: dependent.h',
304
# or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
269
305
# Do two passes, one to just change these to
270
# `$object: dependent.h' and one to simply `dependent.h:'.
306
# '$object: dependent.h' and one to simply 'dependent.h:'.
271
307
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
272
308
# Some versions of the HPUX 10.20 sed can't process this invocation
273
309
# correctly. Breaking it into two sed invocations is a workaround.
276
312
rm -f "$tmpdepfile"
316
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
317
# compilers, which have integrated preprocessors. The correct option
318
# to use with these is +Maked; it writes dependencies to a file named
319
# 'foo.d', which lands next to the object file, wherever that
321
# Much of this is similar to the tru64 case; see comments there.
322
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
323
test "x$dir" = "x$object" && dir=
324
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
325
if test "$libtool" = yes; then
326
tmpdepfile1=$dir$base.d
327
tmpdepfile2=$dir.libs/$base.d
330
tmpdepfile1=$dir$base.d
331
tmpdepfile2=$dir$base.d
335
if test $stat -eq 0; then :
337
rm -f "$tmpdepfile1" "$tmpdepfile2"
341
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
343
test -f "$tmpdepfile" && break
345
if test -f "$tmpdepfile"; then
346
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
347
# Add 'dependent.h:' lines.
353
}' "$tmpdepfile" >> "$depfile"
355
echo "#dummy" > "$depfile"
357
rm -f "$tmpdepfile" "$tmpdepfile2"
280
361
# The Tru64 compiler uses -MD to generate dependencies as a side
281
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
362
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
282
363
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
283
# dependencies in `foo.d' instead, so we check for that too.
364
# dependencies in 'foo.d' instead, so we check for that too.
284
365
# Subdirectories are respected.
285
366
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
286
367
test "x$dir" = "x$object" && dir=
287
368
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
289
370
if test "$libtool" = yes; then
290
# Dependencies are output in .lo.d with libtool 1.4.
291
# With libtool 1.5 they are output both in $dir.libs/$base.o.d
292
# and in $dir.libs/$base.o.d and $dir$base.o.d. We process the
293
# latter, because the former will be cleaned when $dir.libs is
295
tmpdepfile1="$dir.libs/$base.lo.d"
296
tmpdepfile2="$dir$base.o.d"
297
tmpdepfile3="$dir.libs/$base.d"
371
# With Tru64 cc, shared objects can also be used to make a
372
# static library. This mechanism is used in libtool 1.4 series to
373
# handle both shared and static libraries in a single compilation.
374
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
376
# With libtool 1.5 this exception was removed, and libtool now
377
# generates 2 separate objects for the 2 libraries. These two
378
# compilations output dependencies in $dir.libs/$base.o.d and
379
# in $dir$base.o.d. We have to check for both files, because
380
# one of the two compilations can be disabled. We should prefer
381
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
382
# automatically cleaned when .libs/ is deleted, while ignoring
383
# the former would cause a distcleancheck panic.
384
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
385
tmpdepfile2=$dir$base.o.d # libtool 1.5
386
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
387
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
300
tmpdepfile1="$dir$base.o.d"
301
tmpdepfile2="$dir$base.d"
302
tmpdepfile3="$dir$base.d"
390
tmpdepfile1=$dir$base.o.d
391
tmpdepfile2=$dir$base.d
392
tmpdepfile3=$dir$base.d
393
tmpdepfile4=$dir$base.d
307
398
if test $stat -eq 0; then :
309
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
400
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
313
if test -f "$tmpdepfile1"; then
314
tmpdepfile="$tmpdepfile1"
315
elif test -f "$tmpdepfile2"; then
316
tmpdepfile="$tmpdepfile2"
318
tmpdepfile="$tmpdepfile3"
404
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
406
test -f "$tmpdepfile" && break
320
408
if test -f "$tmpdepfile"; then
321
409
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
322
410
# That's a tab and a space in the [].
327
415
rm -f "$tmpdepfile"
419
if test "$libtool" = yes; then
420
showIncludes=-Wc,-showIncludes
422
showIncludes=-showIncludes
424
"$@" $showIncludes > "$tmpdepfile"
426
grep -v '^Note: including file: ' "$tmpdepfile"
427
if test "$stat" = 0; then :
433
echo "$object : \\" > "$depfile"
434
# The first sed program below extracts the file names and escapes
435
# backslashes for cygpath. The second sed program outputs the file
436
# name when reading, but also accumulates all include files in the
437
# hold buffer in order to output them again at the end. This only
438
# works with sed implementations that can handle large buffers.
439
sed < "$tmpdepfile" -n '
440
/^Note: including file: *\(.*\)/ {
444
}' | $cygpath_u | sort -u | sed -n '
458
# This case exists only to let depend.m4 do its work. It works by
459
# looking at the text of this script. This case will never be run,
460
# since it is checked for above.
331
465
# This comment above is used by automake to tell side-effect
332
466
# dependency tracking mechanisms from slower ones.
390
524
# Remove any Libtool call
391
525
if test "$libtool" = yes; then
392
while test $1 != '--mode=compile'; do
526
while test "X$1" != 'X--mode=compile'; do
541
if test $eat = yes; then
408
547
set fnord "$@" "$arg"; shift ;;
409
548
# Strip any option that makedepend may not understand. Remove
410
549
# the object too, otherwise makedepend will parse it as a source file.
414
555
set fnord "$@" "$arg"; shift ;;
417
obj_suffix="`echo $object | sed 's/^.*\././'`"
558
obj_suffix=`echo "$object" | sed 's/^.*\././'`
418
559
touch "$tmpdepfile"
419
560
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
421
cat < "$tmpdepfile" > "$depfile"
562
# makedepend may prepend the VPATH from the source file name to the object.
563
# No need to regex-escape $object, excess matching of '.' is harmless.
564
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
422
565
sed '1,2d' "$tmpdepfile" | tr ' ' '
424
567
## Some versions of the HPUX 10.20 sed can't process this invocation