18
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
# As a special exception to the GNU General Public License, if you
22
# distribute this file as part of a program that contains a
23
# configuration script generated by Autoconf, you may include it under
24
# the same distribution terms that you use for the rest of that program.
21
26
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
23
28
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
52
57
## gcc 3 implements dependency tracking that does exactly what
54
if "$@" -MT "$object" -MF "$tmpdepfile" -MD -MP; then :
58
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
59
## it if -MD -MP comes after the -MF stuff. Hmm.
60
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
62
if test $stat -eq 0; then :
57
64
rm -f "$tmpdepfile"
73
80
if test -z "$gccflag"; then
76
if "$@" -Wp,"$gccflag$tmpdepfile"; then :
83
"$@" -Wp,"$gccflag$tmpdepfile"
85
if test $stat -eq 0; then :
79
87
rm -f "$tmpdepfile"
126
134
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
127
135
echo "$object : \\" > "$depfile"
129
# Clip off the initial element (the dependent). Don't try to be
137
# Clip off the initial element (the dependent). Don't try to be
130
138
# clever and replace this with sed code, as IRIX sed won't handle
131
139
# lines with more than a fixed number of characters (4096 in
132
# IRIX 6.2 sed, 8192 in IRIX 6.5).
140
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
141
# the IRIX cc adds comments like `#:fec' to the end of the
134
' < "$tmpdepfile" | sed 's/^[^\.]*\.o://' | tr '
145
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
135
147
' ' ' >> $depfile
150
# The second pass generates a dummy entry for each header file.
138
' < "$tmpdepfile" | \
139
## Some versions of the HPUX 10.20 sed can't process this invocation
140
## correctly. Breaking it into two sed invocations is a workaround.
141
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
153
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
143
156
# The sourcefile does not contain any dependencies, so just
144
157
# store a dummy comment line, to avoid errors with the Makefile
152
165
# The C for AIX Compiler uses -M and outputs the dependencies
154
tmpdepfile=`echo "$object" | sed 's/\(.*\)\..*$/\1.u/'`
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/'`
170
tmpdepfile="$stripped.u"
171
outname="$stripped.o"
155
172
if test "$libtool" = yes; then
168
185
if test -f "$tmpdepfile"; then
169
echo "$object : \\" > "$depfile"
171
# Clip off the initial element (the dependent). Don't try to be
172
# clever and replace this with sed code, as IRIX sed won't handle
173
# lines with more than a fixed number of characters (4096 in
174
# IRIX 6.2 sed, 8192 in IRIX 6.5).
176
' < "$tmpdepfile" | sed 's/^[^\.]*\.o://' | tr '
180
' < "$tmpdepfile" | \
181
## Some versions of the HPUX 10.20 sed can't process this invocation
182
## correctly. Breaking it into two sed invocations is a workaround.
183
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
186
# Each line is of the form `foo.o: dependent.h'.
187
# Do two passes, one to just change these to
188
# `$object: dependent.h' and one to simply `dependent.h:'.
189
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
190
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
185
192
# The sourcefile does not contain any dependencies, so just
186
193
# store a dummy comment line, to avoid errors with the Makefile
190
197
rm -f "$tmpdepfile"
201
# Must come before tru64.
203
# Intel's C compiler understands `-MD -MF file'. However
204
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
205
# will fill foo.d with something like
208
# which is wrong. We want:
209
# sub/foo.o: sub/foo.c
210
# sub/foo.o: sub/foo.h
214
"$@" -MD -MF "$tmpdepfile"
216
if test $stat -eq 0; then :
222
# Each line is of the form `foo.o: dependent.h'.
223
# Do two passes, one to just change these to
224
# `$object: dependent.h' and one to simply `dependent.h:'.
225
sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
226
sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
231
# The Tru64 AIX compiler uses -MD to generate dependencies as a side
232
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
233
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
234
# dependencies in `foo.d' instead, so we check for that too.
235
# Subdirectories are respected.
237
tmpdepfile1="$object.d"
238
tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
239
if test "$libtool" = yes; then
246
if test $stat -eq 0; then :
248
rm -f "$tmpdepfile1" "$tmpdepfile2"
252
if test -f "$tmpdepfile1"; then
253
tmpdepfile="$tmpdepfile1"
255
tmpdepfile="$tmpdepfile2"
257
if test -f "$tmpdepfile"; then
258
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
259
# That's a space and a tab in the [].
260
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
262
echo "#dummy" > "$depfile"
194
268
# This comment above is used by automake to tell side-effect
195
269
# dependency tracking mechanisms from slower ones.