1 |
#! /bin/sh |
#! /bin/sh |
2 |
# depcomp - compile a program generating dependencies as side-effects |
# depcomp - compile a program generating dependencies as side-effects |
3 |
|
|
4 |
scriptversion=2003-11-08.23 |
scriptversion=2004-05-31.23 |
5 |
|
|
6 |
# Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. |
# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. |
7 |
|
|
8 |
# This program is free software; you can redistribute it and/or modify |
# 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 |
# it under the terms of the GNU General Public License as published by |
43 |
depmode Dependency tracking mode. |
depmode Dependency tracking mode. |
44 |
source Source file read by `PROGRAMS ARGS'. |
source Source file read by `PROGRAMS ARGS'. |
45 |
object Object file output by `PROGRAMS ARGS'. |
object Object file output by `PROGRAMS ARGS'. |
46 |
|
DEPDIR directory where to store dependencies. |
47 |
depfile Dependency file to output. |
depfile Dependency file to output. |
48 |
tmpdepfile Temporary file to use when outputing dependencies. |
tmpdepfile Temporary file to use when outputing dependencies. |
49 |
libtool Whether libtool is used (yes/no). |
libtool Whether libtool is used (yes/no). |
62 |
echo "depcomp: Variables source, object and depmode must be set" 1>&2 |
echo "depcomp: Variables source, object and depmode must be set" 1>&2 |
63 |
exit 1 |
exit 1 |
64 |
fi |
fi |
|
# `libtool' can also be set to `yes' or `no'. |
|
|
|
|
|
if test -z "$depfile"; then |
|
|
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` |
|
|
dir=`echo "$object" | sed 's,/.*$,/,'` |
|
|
if test "$dir" = "$object"; then |
|
|
dir= |
|
|
fi |
|
|
# FIXME: should be _deps on DOS. |
|
|
depfile="$dir.deps/$base" |
|
|
fi |
|
65 |
|
|
66 |
|
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. |
67 |
|
depfile=${depfile-`echo "$object" | |
68 |
|
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} |
69 |
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} |
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} |
70 |
|
|
71 |
rm -f "$tmpdepfile" |
rm -f "$tmpdepfile" |
287 |
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` |
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` |
288 |
|
|
289 |
if test "$libtool" = yes; then |
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 |
294 |
|
# erased. |
295 |
tmpdepfile1="$dir.libs/$base.lo.d" |
tmpdepfile1="$dir.libs/$base.lo.d" |
296 |
tmpdepfile2="$dir.libs/$base.d" |
tmpdepfile2="$dir$base.o.d" |
297 |
|
tmpdepfile3="$dir.libs/$base.d" |
298 |
"$@" -Wc,-MD |
"$@" -Wc,-MD |
299 |
else |
else |
300 |
tmpdepfile1="$dir$base.o.d" |
tmpdepfile1="$dir$base.o.d" |
301 |
tmpdepfile2="$dir$base.d" |
tmpdepfile2="$dir$base.d" |
302 |
|
tmpdepfile3="$dir$base.d" |
303 |
"$@" -MD |
"$@" -MD |
304 |
fi |
fi |
305 |
|
|
306 |
stat=$? |
stat=$? |
307 |
if test $stat -eq 0; then : |
if test $stat -eq 0; then : |
308 |
else |
else |
309 |
rm -f "$tmpdepfile1" "$tmpdepfile2" |
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" |
310 |
exit $stat |
exit $stat |
311 |
fi |
fi |
312 |
|
|
313 |
if test -f "$tmpdepfile1"; then |
if test -f "$tmpdepfile1"; then |
314 |
tmpdepfile="$tmpdepfile1" |
tmpdepfile="$tmpdepfile1" |
315 |
else |
elif test -f "$tmpdepfile2"; then |
316 |
tmpdepfile="$tmpdepfile2" |
tmpdepfile="$tmpdepfile2" |
317 |
|
else |
318 |
|
tmpdepfile="$tmpdepfile3" |
319 |
fi |
fi |
320 |
if test -f "$tmpdepfile"; then |
if test -f "$tmpdepfile"; then |
321 |
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" |
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" |