3
3
# depcomp - compile a program generating dependencies as side-effects
4
# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
4
# Copyright 1999, 2000 Free Software Foundation, Inc.
6
6
# This program is free software; you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
32
32
# `libtool' can also be set to `yes' or `no'.
34
if test -z "$depfile"; then
35
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
36
dir=`echo "$object" | sed 's,/.*$,/,'`
37
if test "$dir" = "$object"; then
40
# FIXME: should be _deps on DOS.
41
depfile="$dir.deps/$base"
34
depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
44
35
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
46
37
rm -f "$tmpdepfile"
174
165
# The C for AIX Compiler uses -M and outputs the dependencies
175
# in a .u file. In older versions, this file always lives in the
176
# current directory. Also, the AIX compiler puts `$object:' at the
177
# start of each line; $object doesn't have directory information.
178
# Version 6 uses the directory in both cases.
179
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
166
# in a .u file. This file always lives in the current directory.
167
# Also, the AIX compiler puts `$object:' at the start of each line;
168
# $object doesn't have directory information.
169
stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
180
170
tmpdepfile="$stripped.u"
171
outname="$stripped.o"
181
172
if test "$libtool" = yes; then
188
if test -f "$tmpdepfile"; then :
190
stripped=`echo "$stripped" | sed 's,^.*/,,'`
191
tmpdepfile="$stripped.u"
194
179
if test $stat -eq 0; then :
196
181
rm -f "$tmpdepfile"
200
185
if test -f "$tmpdepfile"; then
201
outname="$stripped.o"
202
186
# Each line is of the form `foo.o: dependent.h'.
203
187
# Do two passes, one to just change these to
204
188
# `$object: dependent.h' and one to simply `dependent.h:'.
213
197
rm -f "$tmpdepfile"
217
# Intel's C compiler understands `-MD -MF file'. However on
218
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
219
# ICC 7.0 will fill foo.d with something like
222
# which is wrong. We want:
223
# sub/foo.o: sub/foo.c
224
# sub/foo.o: sub/foo.h
227
# ICC 7.1 will output
228
# foo.o: sub/foo.c sub/foo.h
229
# and will wrap long lines using \ :
230
# foo.o: sub/foo.c ... \
234
"$@" -MD -MF "$tmpdepfile"
236
if test $stat -eq 0; then :
242
# Each line is of the form `foo.o: dependent.h',
243
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
244
# Do two passes, one to just change these to
245
# `$object: dependent.h' and one to simply `dependent.h:'.
246
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
247
# Some versions of the HPUX 10.20 sed can't process this invocation
248
# correctly. Breaking it into two sed invocations is a workaround.
249
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
250
sed -e 's/$/ :/' >> "$depfile"
255
# The Tru64 compiler uses -MD to generate dependencies as a side
201
# The Tru64 AIX compiler uses -MD to generate dependencies as a side
256
202
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
257
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
203
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
258
204
# dependencies in `foo.d' instead, so we check for that too.
259
205
# Subdirectories are respected.
260
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
261
test "x$dir" = "x$object" && dir=
262
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
207
tmpdepfile1="$object.d"
208
tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
264
209
if test "$libtool" = yes; then
265
tmpdepfile1="$dir.libs/$base.lo.d"
266
tmpdepfile2="$dir.libs/$base.d"
269
tmpdepfile1="$dir$base.o.d"
270
tmpdepfile2="$dir$base.d"
286
227
if test -f "$tmpdepfile"; then
287
228
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
288
# That's a tab and a space in the [].
289
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
229
# That's a space and a tab in the [].
230
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
291
232
echo "#dummy" > "$depfile"
301
242
# Important note: in order to support this mode, a compiler *must*
302
# always write the preprocessed file to stdout, regardless of -o.
305
# Remove the call to Libtool.
306
if test "$libtool" = yes; then
307
while test $1 != '--mode=compile'; do
313
# Remove `-o $object'.
325
set fnord "$@" "$arg"
243
# always write the proprocessed file to stdout, regardless of -o,
244
# because we must use -o when running libtool.
332
245
test -z "$dashmflag" && dashmflag=-M
333
# Require at least two characters before searching for `:'
334
# in the target name. This is to cope with DOS-style filenames:
335
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
337
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
248
*" --mode=compile "*) # this is libtool, let us make it quiet
250
do # cycle over the arguments
253
# insert --quiet before "--mode=compile"
254
set fnord "$@" --quiet
258
set fnord "$@" "$arg"
264
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
270
if test "$stat" != 0; then exit $stat; fi
339
272
cat < "$tmpdepfile" > "$depfile"
356
# Remove any Libtool call
357
if test "$libtool" = yes; then
358
while test $1 != '--mode=compile'; do
374
set fnord "$@" "$arg"; shift ;;
375
# Strip any option that makedepend may not understand. Remove
376
# the object too, otherwise makedepend will parse it as a source file.
380
set fnord "$@" "$arg"; shift ;;
383
obj_suffix="`echo $object | sed 's/^.*\././'`"
385
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
299
set fnord "$@" "$arg"; shift;;
303
set fnord "$@" "$arg"; shift;;
306
obj_suffix="`echo $object | sed 's/^.*\././'`"
308
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
314
if test "$stat" != 0; then exit $stat; fi
387
316
cat < "$tmpdepfile" > "$depfile"
388
sed '1,2d' "$tmpdepfile" | tr ' ' '
317
tail +3 "$tmpdepfile" | tr ' ' '
390
319
## Some versions of the HPUX 10.20 sed can't process this invocation
391
320
## correctly. Breaking it into two sed invocations is a workaround.
397
326
# Important note: in order to support this mode, a compiler *must*
398
# always write the preprocessed file to stdout.
401
# Remove the call to Libtool.
402
if test "$libtool" = yes; then
403
while test $1 != '--mode=compile'; do
409
# Remove `-o $object'.
421
set fnord "$@" "$arg"
327
# always write the proprocessed file to stdout, regardless of -o,
328
# because we must use -o when running libtool.
331
*" --mode=compile "*)
333
do # cycle over the arguments
336
# insert --quiet before "--mode=compile"
337
set fnord "$@" --quiet
341
set fnord "$@" "$arg"
429
348
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
430
349
sed '$ s: \\$::' > "$tmpdepfile"
355
if test "$stat" != 0; then exit $stat; fi
432
357
echo "$object : \\" > "$depfile"
433
358
cat < "$tmpdepfile" >> "$depfile"
439
364
# Important note: in order to support this mode, a compiler *must*
440
# always write the preprocessed file to stdout, regardless of -o,
365
# always write the proprocessed file to stdout, regardless of -o,
441
366
# because we must use -o when running libtool.
447
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
369
*" --mode=compile "*)
371
do # cycle over the arguments
374
# insert --quiet before "--mode=compile"
375
set fnord "$@" --quiet
453
379
set fnord "$@" "$arg"
460
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
386
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
392
if test "$stat" != 0; then exit $stat; fi
462
394
echo "$object : \\" > "$depfile"
463
395
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"