42
40
Environment variables:
43
41
depmode Dependency tracking mode.
44
source Source file read by `PROGRAMS ARGS'.
45
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.
46
45
depfile Dependency file to output.
47
tmpdepfile Temporary file to use when outputing dependencies.
46
tmpdepfile Temporary file to use when outputting dependencies.
48
47
libtool Whether libtool is used (yes/no).
50
49
Report bugs to <bug-automake@gnu.org>.
55
54
echo "depcomp $scriptversion"
59
# A tabulation character.
61
# A newline character.
60
65
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
61
66
echo "depcomp: Variables source, object and depmode must be set" 1>&2
64
# `libtool' can also be set to `yes' or `no'.
66
if test -z "$depfile"; then
67
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
68
dir=`echo "$object" | sed 's,/.*$,/,'`
69
if test "$dir" = "$object"; then
72
# FIXME: should be _deps on DOS.
73
depfile="$dir.deps/$base"
70
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
71
depfile=${depfile-`echo "$object" |
72
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
76
73
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
78
75
rm -f "$tmpdepfile"
93
90
depmode=dashmstdout
93
cygpath_u="cygpath -u -f -"
94
if test "$depmode" = msvcmsys; then
95
# This is just like msvisualcpp but w/o cygpath translation.
96
# Just convert the backslash-escaped backslashes to single forward
97
# slashes to satisfy depend.m4
98
cygpath_u='sed s,\\\\,/,g'
102
if test "$depmode" = msvc7msys; then
103
# This is just like msvc7 but w/o cygpath translation.
104
# Just convert the backslash-escaped backslashes to single forward
105
# slashes to satisfy depend.m4
106
cygpath_u='sed s,\\\\,/,g'
110
if test "$depmode" = xlc; then
111
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
112
gccflag=-qmakedep=gcc,-MF
96
116
case "$depmode" in
98
118
## gcc 3 implements dependency tracking that does exactly what
99
119
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
100
120
## it if -MD -MP comes after the -MF stuff. Hmm.
101
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
121
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
122
## the command line argument order; so add the flags where they
123
## appear in depend2.am. Note that the slowdown incurred here
124
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
128
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
129
*) set fnord "$@" "$arg" ;;
103
136
if test $stat -eq 0; then :
134
167
## The second -e expression handles DOS-style file names with drive letters.
135
168
sed -e 's/^[^:]*: / /' \
136
169
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
137
## This next piece of magic avoids the `deleted header file' problem.
170
## This next piece of magic avoids the "deleted header file" problem.
138
171
## The problem is that when a header file which appears in a .P file
139
172
## is deleted, the dependency causes make to die (because there is
140
173
## typically no way to rebuild the header). We avoid this by adding
141
174
## dummy dependencies for each header file. Too bad gcc doesn't do
142
175
## this for us directly.
145
## 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
146
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.
148
181
## Some versions of the HPUX 10.20 sed can't process this invocation
149
182
## correctly. Breaking it into two sed invocations is a workaround.
150
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
183
sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
184
| sed -e 's/$/ :/' >> "$depfile"
151
185
rm -f "$tmpdepfile"
202
233
rm -f "$tmpdepfile"
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.
206
244
# The C for AIX Compiler uses -M and outputs the dependencies
207
245
# in a .u file. In older versions, this file always lives in the
208
# current directory. Also, the AIX compiler puts `$object:' at the
246
# current directory. Also, the AIX compiler puts '$object:' at the
209
247
# start of each line; $object doesn't have directory information.
210
248
# Version 6 uses the directory in both cases.
211
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
212
tmpdepfile="$stripped.u"
249
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
250
test "x$dir" = "x$object" && dir=
251
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
213
252
if test "$libtool" = yes; then
253
tmpdepfile1=$dir$base.u
255
tmpdepfile3=$dir.libs/$base.u
258
tmpdepfile1=$dir$base.u
259
tmpdepfile2=$dir$base.u
260
tmpdepfile3=$dir$base.u
220
if test -f "$tmpdepfile"; then :
222
stripped=`echo "$stripped" | sed 's,^.*/,,'`
223
tmpdepfile="$stripped.u"
226
265
if test $stat -eq 0; then :
267
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
271
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
273
test -f "$tmpdepfile" && break
232
275
if test -f "$tmpdepfile"; then
233
outname="$stripped.o"
234
# Each line is of the form `foo.o: dependent.h'.
276
# Each line is of the form 'foo.o: dependent.h'.
235
277
# Do two passes, one to just change these to
236
# `$object: dependent.h' and one to simply `dependent.h:'.
237
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
238
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
278
# '$object: dependent.h' and one to simply 'dependent.h:'.
279
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
280
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
240
282
# The sourcefile does not contain any dependencies, so just
241
283
# store a dummy comment line, to avoid errors with the Makefile
274
# Each line is of the form `foo.o: dependent.h',
275
# 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 \'.
276
321
# Do two passes, one to just change these to
277
# `$object: dependent.h' and one to simply `dependent.h:'.
278
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
279
# Some versions of the HPUX 10.20 sed can't process this invocation
280
# correctly. Breaking it into two sed invocations is a workaround.
281
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
282
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"
326
s/[ '"$tab"'][ '"$tab"']*/ /g
333
' < "$tmpdepfile" >> "$depfile"
283
334
rm -f "$tmpdepfile"
338
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
339
# compilers, which have integrated preprocessors. The correct option
340
# to use with these is +Maked; it writes dependencies to a file named
341
# 'foo.d', which lands next to the object file, wherever that
343
# Much of this is similar to the tru64 case; see comments there.
344
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
345
test "x$dir" = "x$object" && dir=
346
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
347
if test "$libtool" = yes; then
348
tmpdepfile1=$dir$base.d
349
tmpdepfile2=$dir.libs/$base.d
352
tmpdepfile1=$dir$base.d
353
tmpdepfile2=$dir$base.d
357
if test $stat -eq 0; then :
359
rm -f "$tmpdepfile1" "$tmpdepfile2"
363
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
365
test -f "$tmpdepfile" && break
367
if test -f "$tmpdepfile"; then
368
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
369
# Add 'dependent.h:' lines.
375
}' "$tmpdepfile" >> "$depfile"
377
echo "#dummy" > "$depfile"
379
rm -f "$tmpdepfile" "$tmpdepfile2"
287
383
# The Tru64 compiler uses -MD to generate dependencies as a side
288
# 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'.
289
385
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
290
# dependencies in `foo.d' instead, so we check for that too.
386
# dependencies in 'foo.d' instead, so we check for that too.
291
387
# Subdirectories are respected.
292
388
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
293
389
test "x$dir" = "x$object" && dir=
294
390
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
296
392
if test "$libtool" = yes; then
297
tmpdepfile1="$dir.libs/$base.lo.d"
298
tmpdepfile2="$dir.libs/$base.d"
393
# With Tru64 cc, shared objects can also be used to make a
394
# static library. This mechanism is used in libtool 1.4 series to
395
# handle both shared and static libraries in a single compilation.
396
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
398
# With libtool 1.5 this exception was removed, and libtool now
399
# generates 2 separate objects for the 2 libraries. These two
400
# compilations output dependencies in $dir.libs/$base.o.d and
401
# in $dir$base.o.d. We have to check for both files, because
402
# one of the two compilations can be disabled. We should prefer
403
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
404
# automatically cleaned when .libs/ is deleted, while ignoring
405
# the former would cause a distcleancheck panic.
406
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
407
tmpdepfile2=$dir$base.o.d # libtool 1.5
408
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
409
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
301
tmpdepfile1="$dir$base.o.d"
302
tmpdepfile2="$dir$base.d"
412
tmpdepfile1=$dir$base.o.d
413
tmpdepfile2=$dir$base.d
414
tmpdepfile3=$dir$base.d
415
tmpdepfile4=$dir$base.d
307
420
if test $stat -eq 0; then :
309
rm -f "$tmpdepfile1" "$tmpdepfile2"
422
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
313
if test -f "$tmpdepfile1"; then
314
tmpdepfile="$tmpdepfile1"
316
tmpdepfile="$tmpdepfile2"
426
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
428
test -f "$tmpdepfile" && break
318
430
if test -f "$tmpdepfile"; then
319
431
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
320
# That's a tab and a space in the [].
321
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
432
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
323
434
echo "#dummy" > "$depfile"
325
436
rm -f "$tmpdepfile"
440
if test "$libtool" = yes; then
441
showIncludes=-Wc,-showIncludes
443
showIncludes=-showIncludes
445
"$@" $showIncludes > "$tmpdepfile"
447
grep -v '^Note: including file: ' "$tmpdepfile"
448
if test "$stat" = 0; then :
454
echo "$object : \\" > "$depfile"
455
# The first sed program below extracts the file names and escapes
456
# backslashes for cygpath. The second sed program outputs the file
457
# name when reading, but also accumulates all include files in the
458
# hold buffer in order to output them again at the end. This only
459
# works with sed implementations that can handle large buffers.
460
sed < "$tmpdepfile" -n '
461
/^Note: including file: *\(.*\)/ {
465
}' | $cygpath_u | sort -u | sed -n '
467
s/\(.*\)/'"$tab"'\1 \\/p
479
# This case exists only to let depend.m4 do its work. It works by
480
# looking at the text of this script. This case will never be run,
481
# since it is checked for above.
329
486
# This comment above is used by automake to tell side-effect
330
487
# dependency tracking mechanisms from slower ones.
388
544
# Remove any Libtool call
389
545
if test "$libtool" = yes; then
390
while test $1 != '--mode=compile'; do
546
while test "X$1" != 'X--mode=compile'; do
561
if test $eat = yes; then
406
567
set fnord "$@" "$arg"; shift ;;
407
568
# Strip any option that makedepend may not understand. Remove
408
569
# the object too, otherwise makedepend will parse it as a source file.
412
575
set fnord "$@" "$arg"; shift ;;
415
obj_suffix="`echo $object | sed 's/^.*\././'`"
578
obj_suffix=`echo "$object" | sed 's/^.*\././'`
416
579
touch "$tmpdepfile"
417
580
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
419
cat < "$tmpdepfile" > "$depfile"
420
sed '1,2d' "$tmpdepfile" | tr ' ' '
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 ' ' "$nl" | \
422
586
## Some versions of the HPUX 10.20 sed can't process this invocation
423
587
## correctly. Breaking it into two sed invocations is a workaround.
424
588
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"