3
2
# depcomp - compile a program generating dependencies as side-effects
4
# Copyright 1999, 2000 Free Software Foundation, Inc.
4
scriptversion=2006-10-15.18
6
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
6
9
# This program is free software; you can redistribute it and/or modify
7
10
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2, or (at your option)
11
# the Free Software Foundation; either version 3, or (at your option)
9
12
# any later version.
11
14
# This program is distributed in the hope that it will be useful,
14
17
# GNU General Public License for more details.
16
19
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20
# along with this program; if not, see <http://www.gnu.org/licenses/>.
21
22
# As a special exception to the GNU General Public License, if you
22
23
# distribute this file as part of a program that contains a
26
27
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
31
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
36
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
38
Run PROGRAMS ARGS to compile a file, generating dependencies
41
Environment variables:
42
depmode Dependency tracking mode.
43
source Source file read by `PROGRAMS ARGS'.
44
object Object file output by `PROGRAMS ARGS'.
45
DEPDIR directory where to store dependencies.
46
depfile Dependency file to output.
47
tmpdepfile Temporary file to use when outputing dependencies.
48
libtool Whether libtool is used (yes/no).
50
Report bugs to <bug-automake@gnu.org>.
55
echo "depcomp $scriptversion"
28
60
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
29
61
echo "depcomp: Variables source, object and depmode must be set" 1>&2
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"
65
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66
depfile=${depfile-`echo "$object" |
67
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
44
68
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
46
70
rm -f "$tmpdepfile"
66
90
## gcc 3 implements dependency tracking that does exactly what
67
91
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
68
92
## it if -MD -MP comes after the -MF stuff. Hmm.
69
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
93
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
94
## the command line argument order; so add the flags where they
95
## appear in depend2.am. Note that the slowdown incurred here
96
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
100
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
101
*) set fnord "$@" "$arg" ;;
71
108
if test $stat -eq 0; then :
174
211
# The C for AIX Compiler uses -M and outputs the dependencies
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/'`
212
# in a .u file. In older versions, this file always lives in the
213
# current directory. Also, the AIX compiler puts `$object:' at the
214
# start of each line; $object doesn't have directory information.
215
# Version 6 uses the directory in both cases.
216
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
179
217
tmpdepfile="$stripped.u"
180
outname="$stripped.o"
181
218
if test "$libtool" = yes; then
225
if test -f "$tmpdepfile"; then :
227
stripped=`echo "$stripped" | sed 's,^.*/,,'`
228
tmpdepfile="$stripped.u"
188
231
if test $stat -eq 0; then :
190
233
rm -f "$tmpdepfile"
244
288
rm -f "$tmpdepfile"
292
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
293
# compilers, which have integrated preprocessors. The correct option
294
# to use with these is +Maked; it writes dependencies to a file named
295
# 'foo.d', which lands next to the object file, wherever that
297
# Much of this is similar to the tru64 case; see comments there.
298
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
299
test "x$dir" = "x$object" && dir=
300
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
301
if test "$libtool" = yes; then
302
tmpdepfile1=$dir$base.d
303
tmpdepfile2=$dir.libs/$base.d
306
tmpdepfile1=$dir$base.d
307
tmpdepfile2=$dir$base.d
311
if test $stat -eq 0; then :
313
rm -f "$tmpdepfile1" "$tmpdepfile2"
317
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
319
test -f "$tmpdepfile" && break
321
if test -f "$tmpdepfile"; then
322
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
323
# Add `dependent.h:' lines.
324
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
326
echo "#dummy" > "$depfile"
328
rm -f "$tmpdepfile" "$tmpdepfile2"
248
332
# The Tru64 compiler uses -MD to generate dependencies as a side
249
333
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
255
339
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
257
341
if test "$libtool" = yes; then
258
tmpdepfile1="$dir.libs/$base.lo.d"
259
tmpdepfile2="$dir.libs/$base.d"
342
# With Tru64 cc, shared objects can also be used to make a
343
# static library. This mechanism is used in libtool 1.4 series to
344
# handle both shared and static libraries in a single compilation.
345
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
347
# With libtool 1.5 this exception was removed, and libtool now
348
# generates 2 separate objects for the 2 libraries. These two
349
# compilations output dependencies in $dir.libs/$base.o.d and
350
# in $dir$base.o.d. We have to check for both files, because
351
# one of the two compilations can be disabled. We should prefer
352
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
353
# automatically cleaned when .libs/ is deleted, while ignoring
354
# the former would cause a distcleancheck panic.
355
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
356
tmpdepfile2=$dir$base.o.d # libtool 1.5
357
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
358
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
262
tmpdepfile1="$dir$base.o.d"
263
tmpdepfile2="$dir$base.d"
361
tmpdepfile1=$dir$base.o.d
362
tmpdepfile2=$dir$base.d
363
tmpdepfile3=$dir$base.d
364
tmpdepfile4=$dir$base.d
268
369
if test $stat -eq 0; then :
270
rm -f "$tmpdepfile1" "$tmpdepfile2"
371
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
274
if test -f "$tmpdepfile1"; then
275
tmpdepfile="$tmpdepfile1"
277
tmpdepfile="$tmpdepfile2"
375
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
377
test -f "$tmpdepfile" && break
279
379
if test -f "$tmpdepfile"; then
280
380
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
281
# That's a space and a tab in the [].
282
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
381
# That's a tab and a space in the [].
382
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
284
384
echo "#dummy" > "$depfile"
432
533
# Important note: in order to support this mode, a compiler *must*
433
# always write the proprocessed file to stdout, regardless of -o,
534
# always write the preprocessed file to stdout, regardless of -o,
434
535
# because we must use -o when running libtool.