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
174
174
# 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/'`
175
# in a .u file. This file always lives in the current directory.
176
# Also, the AIX compiler puts `$object:' at the start of each line;
177
# $object doesn't have directory information.
178
stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
180
179
tmpdepfile="$stripped.u"
180
outname="$stripped.o"
181
181
if test "$libtool" = yes; then
188
if test -f "$tmpdepfile"; then :
190
stripped=`echo "$stripped" | sed 's,^.*/,,'`
191
tmpdepfile="$stripped.u"
194
188
if test $stat -eq 0; then :
196
190
rm -f "$tmpdepfile"
200
194
if test -f "$tmpdepfile"; then
201
outname="$stripped.o"
202
195
# Each line is of the form `foo.o: dependent.h'.
203
196
# Do two passes, one to just change these to
204
197
# `$object: dependent.h' and one to simply `dependent.h:'.
213
206
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
210
# The Tru64 compiler uses -MD to generate dependencies as a side
256
211
# 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
212
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
258
213
# dependencies in `foo.d' instead, so we check for that too.
259
214
# 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$//'`
216
base=`echo "$object" | sed -e 's/\.o$//' -e 's/\.lo$//'`
217
tmpdepfile1="$base.o.d"
218
tmpdepfile2="$base.d"
264
219
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
237
if test -f "$tmpdepfile"; then
287
238
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"
239
# That's a space and a tab in the [].
240
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
291
242
echo "#dummy" > "$depfile"
301
252
# 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"
253
# always write the proprocessed file to stdout, regardless of -o,
254
# because we must use -o when running libtool.
332
255
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"
258
*" --mode=compile "*) # this is libtool, let us make it quiet
260
do # cycle over the arguments
263
# insert --quiet before "--mode=compile"
264
set fnord "$@" --quiet
268
set fnord "$@" "$arg"
274
"$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
280
if test "$stat" != 0; then exit $stat; fi
339
282
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" "$@"
309
set fnord "$@" "$arg"; shift;;
313
set fnord "$@" "$arg"; shift;;
316
obj_suffix="`echo $object | sed 's/^.*\././'`"
318
${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
324
if test "$stat" != 0; then exit $stat; fi
387
326
cat < "$tmpdepfile" > "$depfile"
388
327
sed '1,2d' "$tmpdepfile" | tr ' ' '
397
336
# 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"
337
# always write the proprocessed file to stdout, regardless of -o,
338
# because we must use -o when running libtool.
341
*" --mode=compile "*)
343
do # cycle over the arguments
346
# insert --quiet before "--mode=compile"
347
set fnord "$@" --quiet
351
set fnord "$@" "$arg"
429
358
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
430
359
sed '$ s: \\$::' > "$tmpdepfile"
365
if test "$stat" != 0; then exit $stat; fi
432
367
echo "$object : \\" > "$depfile"
433
368
cat < "$tmpdepfile" >> "$depfile"
439
374
# Important note: in order to support this mode, a compiler *must*
440
# always write the preprocessed file to stdout, regardless of -o,
375
# always write the proprocessed file to stdout, regardless of -o,
441
376
# because we must use -o when running libtool.
447
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
379
*" --mode=compile "*)
381
do # cycle over the arguments
384
# insert --quiet before "--mode=compile"
385
set fnord "$@" --quiet
389
set fnord "$@" "$arg"
398
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
453
404
set fnord "$@" "$arg"
460
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
411
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
417
if test "$stat" != 0; then exit $stat; fi
462
419
echo "$object : \\" > "$depfile"
463
420
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"