annotate depcomp @ 33:ee9553116dbf

gpl3
author carl
date Sun, 09 Sep 2007 11:28:31 -0700
parents 551433a01cab
children c6c8a2102a3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
551433a01cab initial coding
carl
parents:
diff changeset
1 #! /bin/sh
551433a01cab initial coding
carl
parents:
diff changeset
2
551433a01cab initial coding
carl
parents:
diff changeset
3 # depcomp - compile a program generating dependencies as side-effects
551433a01cab initial coding
carl
parents:
diff changeset
4 # Copyright 1999, 2000 Free Software Foundation, Inc.
551433a01cab initial coding
carl
parents:
diff changeset
5
551433a01cab initial coding
carl
parents:
diff changeset
6 # This program is free software; you can redistribute it and/or modify
551433a01cab initial coding
carl
parents:
diff changeset
7 # it under the terms of the GNU General Public License as published by
551433a01cab initial coding
carl
parents:
diff changeset
8 # the Free Software Foundation; either version 2, or (at your option)
551433a01cab initial coding
carl
parents:
diff changeset
9 # any later version.
551433a01cab initial coding
carl
parents:
diff changeset
10
551433a01cab initial coding
carl
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
551433a01cab initial coding
carl
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
551433a01cab initial coding
carl
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
551433a01cab initial coding
carl
parents:
diff changeset
14 # GNU General Public License for more details.
551433a01cab initial coding
carl
parents:
diff changeset
15
551433a01cab initial coding
carl
parents:
diff changeset
16 # You should have received a copy of the GNU General Public License
551433a01cab initial coding
carl
parents:
diff changeset
17 # along with this program; if not, write to the Free Software
551433a01cab initial coding
carl
parents:
diff changeset
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
551433a01cab initial coding
carl
parents:
diff changeset
19 # 02111-1307, USA.
551433a01cab initial coding
carl
parents:
diff changeset
20
551433a01cab initial coding
carl
parents:
diff changeset
21 # As a special exception to the GNU General Public License, if you
551433a01cab initial coding
carl
parents:
diff changeset
22 # distribute this file as part of a program that contains a
551433a01cab initial coding
carl
parents:
diff changeset
23 # configuration script generated by Autoconf, you may include it under
551433a01cab initial coding
carl
parents:
diff changeset
24 # the same distribution terms that you use for the rest of that program.
551433a01cab initial coding
carl
parents:
diff changeset
25
551433a01cab initial coding
carl
parents:
diff changeset
26 # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
551433a01cab initial coding
carl
parents:
diff changeset
27
551433a01cab initial coding
carl
parents:
diff changeset
28 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
551433a01cab initial coding
carl
parents:
diff changeset
29 echo "depcomp: Variables source, object and depmode must be set" 1>&2
551433a01cab initial coding
carl
parents:
diff changeset
30 exit 1
551433a01cab initial coding
carl
parents:
diff changeset
31 fi
551433a01cab initial coding
carl
parents:
diff changeset
32 # `libtool' can also be set to `yes' or `no'.
551433a01cab initial coding
carl
parents:
diff changeset
33
551433a01cab initial coding
carl
parents:
diff changeset
34 depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
551433a01cab initial coding
carl
parents:
diff changeset
35 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
551433a01cab initial coding
carl
parents:
diff changeset
36
551433a01cab initial coding
carl
parents:
diff changeset
37 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
38
551433a01cab initial coding
carl
parents:
diff changeset
39 # Some modes work just like other modes, but use different flags. We
551433a01cab initial coding
carl
parents:
diff changeset
40 # parameterize here, but still list the modes in the big case below,
551433a01cab initial coding
carl
parents:
diff changeset
41 # to make depend.m4 easier to write. Note that we *cannot* use a case
551433a01cab initial coding
carl
parents:
diff changeset
42 # here, because this file can only contain one case statement.
551433a01cab initial coding
carl
parents:
diff changeset
43 if test "$depmode" = hp; then
551433a01cab initial coding
carl
parents:
diff changeset
44 # HP compiler uses -M and no extra arg.
551433a01cab initial coding
carl
parents:
diff changeset
45 gccflag=-M
551433a01cab initial coding
carl
parents:
diff changeset
46 depmode=gcc
551433a01cab initial coding
carl
parents:
diff changeset
47 fi
551433a01cab initial coding
carl
parents:
diff changeset
48
551433a01cab initial coding
carl
parents:
diff changeset
49 if test "$depmode" = dashXmstdout; then
551433a01cab initial coding
carl
parents:
diff changeset
50 # This is just like dashmstdout with a different argument.
551433a01cab initial coding
carl
parents:
diff changeset
51 dashmflag=-xM
551433a01cab initial coding
carl
parents:
diff changeset
52 depmode=dashmstdout
551433a01cab initial coding
carl
parents:
diff changeset
53 fi
551433a01cab initial coding
carl
parents:
diff changeset
54
551433a01cab initial coding
carl
parents:
diff changeset
55 case "$depmode" in
551433a01cab initial coding
carl
parents:
diff changeset
56 gcc3)
551433a01cab initial coding
carl
parents:
diff changeset
57 ## gcc 3 implements dependency tracking that does exactly what
551433a01cab initial coding
carl
parents:
diff changeset
58 ## we want. Yay! Note: for some reason libtool 1.4 doesn't like
551433a01cab initial coding
carl
parents:
diff changeset
59 ## it if -MD -MP comes after the -MF stuff. Hmm.
551433a01cab initial coding
carl
parents:
diff changeset
60 "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
61 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
62 if test $stat -eq 0; then :
551433a01cab initial coding
carl
parents:
diff changeset
63 else
551433a01cab initial coding
carl
parents:
diff changeset
64 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
65 exit $stat
551433a01cab initial coding
carl
parents:
diff changeset
66 fi
551433a01cab initial coding
carl
parents:
diff changeset
67 mv "$tmpdepfile" "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
68 ;;
551433a01cab initial coding
carl
parents:
diff changeset
69
551433a01cab initial coding
carl
parents:
diff changeset
70 gcc)
551433a01cab initial coding
carl
parents:
diff changeset
71 ## There are various ways to get dependency output from gcc. Here's
551433a01cab initial coding
carl
parents:
diff changeset
72 ## why we pick this rather obscure method:
551433a01cab initial coding
carl
parents:
diff changeset
73 ## - Don't want to use -MD because we'd like the dependencies to end
551433a01cab initial coding
carl
parents:
diff changeset
74 ## up in a subdir. Having to rename by hand is ugly.
551433a01cab initial coding
carl
parents:
diff changeset
75 ## (We might end up doing this anyway to support other compilers.)
551433a01cab initial coding
carl
parents:
diff changeset
76 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
551433a01cab initial coding
carl
parents:
diff changeset
77 ## -MM, not -M (despite what the docs say).
551433a01cab initial coding
carl
parents:
diff changeset
78 ## - Using -M directly means running the compiler twice (even worse
551433a01cab initial coding
carl
parents:
diff changeset
79 ## than renaming).
551433a01cab initial coding
carl
parents:
diff changeset
80 if test -z "$gccflag"; then
551433a01cab initial coding
carl
parents:
diff changeset
81 gccflag=-MD,
551433a01cab initial coding
carl
parents:
diff changeset
82 fi
551433a01cab initial coding
carl
parents:
diff changeset
83 "$@" -Wp,"$gccflag$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
84 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
85 if test $stat -eq 0; then :
551433a01cab initial coding
carl
parents:
diff changeset
86 else
551433a01cab initial coding
carl
parents:
diff changeset
87 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
88 exit $stat
551433a01cab initial coding
carl
parents:
diff changeset
89 fi
551433a01cab initial coding
carl
parents:
diff changeset
90 rm -f "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
91 echo "$object : \\" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
92 alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
551433a01cab initial coding
carl
parents:
diff changeset
93 ## The second -e expression handles DOS-style file names with drive letters.
551433a01cab initial coding
carl
parents:
diff changeset
94 sed -e 's/^[^:]*: / /' \
551433a01cab initial coding
carl
parents:
diff changeset
95 -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
96 ## This next piece of magic avoids the `deleted header file' problem.
551433a01cab initial coding
carl
parents:
diff changeset
97 ## The problem is that when a header file which appears in a .P file
551433a01cab initial coding
carl
parents:
diff changeset
98 ## is deleted, the dependency causes make to die (because there is
551433a01cab initial coding
carl
parents:
diff changeset
99 ## typically no way to rebuild the header). We avoid this by adding
551433a01cab initial coding
carl
parents:
diff changeset
100 ## dummy dependencies for each header file. Too bad gcc doesn't do
551433a01cab initial coding
carl
parents:
diff changeset
101 ## this for us directly.
551433a01cab initial coding
carl
parents:
diff changeset
102 tr ' ' '
551433a01cab initial coding
carl
parents:
diff changeset
103 ' < "$tmpdepfile" |
551433a01cab initial coding
carl
parents:
diff changeset
104 ## Some versions of gcc put a space before the `:'. On the theory
551433a01cab initial coding
carl
parents:
diff changeset
105 ## that the space means something, we add a space to the output as
551433a01cab initial coding
carl
parents:
diff changeset
106 ## well.
551433a01cab initial coding
carl
parents:
diff changeset
107 ## Some versions of the HPUX 10.20 sed can't process this invocation
551433a01cab initial coding
carl
parents:
diff changeset
108 ## correctly. Breaking it into two sed invocations is a workaround.
551433a01cab initial coding
carl
parents:
diff changeset
109 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
110 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
111 ;;
551433a01cab initial coding
carl
parents:
diff changeset
112
551433a01cab initial coding
carl
parents:
diff changeset
113 hp)
551433a01cab initial coding
carl
parents:
diff changeset
114 # This case exists only to let depend.m4 do its work. It works by
551433a01cab initial coding
carl
parents:
diff changeset
115 # looking at the text of this script. This case will never be run,
551433a01cab initial coding
carl
parents:
diff changeset
116 # since it is checked for above.
551433a01cab initial coding
carl
parents:
diff changeset
117 exit 1
551433a01cab initial coding
carl
parents:
diff changeset
118 ;;
551433a01cab initial coding
carl
parents:
diff changeset
119
551433a01cab initial coding
carl
parents:
diff changeset
120 sgi)
551433a01cab initial coding
carl
parents:
diff changeset
121 if test "$libtool" = yes; then
551433a01cab initial coding
carl
parents:
diff changeset
122 "$@" "-Wp,-MDupdate,$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
123 else
551433a01cab initial coding
carl
parents:
diff changeset
124 "$@" -MDupdate "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
125 fi
551433a01cab initial coding
carl
parents:
diff changeset
126 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
127 if test $stat -eq 0; then :
551433a01cab initial coding
carl
parents:
diff changeset
128 else
551433a01cab initial coding
carl
parents:
diff changeset
129 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
130 exit $stat
551433a01cab initial coding
carl
parents:
diff changeset
131 fi
551433a01cab initial coding
carl
parents:
diff changeset
132 rm -f "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
133
551433a01cab initial coding
carl
parents:
diff changeset
134 if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
551433a01cab initial coding
carl
parents:
diff changeset
135 echo "$object : \\" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
136
551433a01cab initial coding
carl
parents:
diff changeset
137 # Clip off the initial element (the dependent). Don't try to be
551433a01cab initial coding
carl
parents:
diff changeset
138 # clever and replace this with sed code, as IRIX sed won't handle
551433a01cab initial coding
carl
parents:
diff changeset
139 # lines with more than a fixed number of characters (4096 in
551433a01cab initial coding
carl
parents:
diff changeset
140 # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
551433a01cab initial coding
carl
parents:
diff changeset
141 # the IRIX cc adds comments like `#:fec' to the end of the
551433a01cab initial coding
carl
parents:
diff changeset
142 # dependency line.
551433a01cab initial coding
carl
parents:
diff changeset
143 tr ' ' '
551433a01cab initial coding
carl
parents:
diff changeset
144 ' < "$tmpdepfile" \
551433a01cab initial coding
carl
parents:
diff changeset
145 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
551433a01cab initial coding
carl
parents:
diff changeset
146 tr '
551433a01cab initial coding
carl
parents:
diff changeset
147 ' ' ' >> $depfile
551433a01cab initial coding
carl
parents:
diff changeset
148 echo >> $depfile
551433a01cab initial coding
carl
parents:
diff changeset
149
551433a01cab initial coding
carl
parents:
diff changeset
150 # The second pass generates a dummy entry for each header file.
551433a01cab initial coding
carl
parents:
diff changeset
151 tr ' ' '
551433a01cab initial coding
carl
parents:
diff changeset
152 ' < "$tmpdepfile" \
551433a01cab initial coding
carl
parents:
diff changeset
153 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
551433a01cab initial coding
carl
parents:
diff changeset
154 >> $depfile
551433a01cab initial coding
carl
parents:
diff changeset
155 else
551433a01cab initial coding
carl
parents:
diff changeset
156 # The sourcefile does not contain any dependencies, so just
551433a01cab initial coding
carl
parents:
diff changeset
157 # store a dummy comment line, to avoid errors with the Makefile
551433a01cab initial coding
carl
parents:
diff changeset
158 # "include basename.Plo" scheme.
551433a01cab initial coding
carl
parents:
diff changeset
159 echo "#dummy" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
160 fi
551433a01cab initial coding
carl
parents:
diff changeset
161 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
162 ;;
551433a01cab initial coding
carl
parents:
diff changeset
163
551433a01cab initial coding
carl
parents:
diff changeset
164 aix)
551433a01cab initial coding
carl
parents:
diff changeset
165 # The C for AIX Compiler uses -M and outputs the dependencies
551433a01cab initial coding
carl
parents:
diff changeset
166 # in a .u file. This file always lives in the current directory.
551433a01cab initial coding
carl
parents:
diff changeset
167 # Also, the AIX compiler puts `$object:' at the start of each line;
551433a01cab initial coding
carl
parents:
diff changeset
168 # $object doesn't have directory information.
551433a01cab initial coding
carl
parents:
diff changeset
169 stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
551433a01cab initial coding
carl
parents:
diff changeset
170 tmpdepfile="$stripped.u"
551433a01cab initial coding
carl
parents:
diff changeset
171 outname="$stripped.o"
551433a01cab initial coding
carl
parents:
diff changeset
172 if test "$libtool" = yes; then
551433a01cab initial coding
carl
parents:
diff changeset
173 "$@" -Wc,-M
551433a01cab initial coding
carl
parents:
diff changeset
174 else
551433a01cab initial coding
carl
parents:
diff changeset
175 "$@" -M
551433a01cab initial coding
carl
parents:
diff changeset
176 fi
551433a01cab initial coding
carl
parents:
diff changeset
177
551433a01cab initial coding
carl
parents:
diff changeset
178 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
179 if test $stat -eq 0; then :
551433a01cab initial coding
carl
parents:
diff changeset
180 else
551433a01cab initial coding
carl
parents:
diff changeset
181 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
182 exit $stat
551433a01cab initial coding
carl
parents:
diff changeset
183 fi
551433a01cab initial coding
carl
parents:
diff changeset
184
551433a01cab initial coding
carl
parents:
diff changeset
185 if test -f "$tmpdepfile"; then
551433a01cab initial coding
carl
parents:
diff changeset
186 # Each line is of the form `foo.o: dependent.h'.
551433a01cab initial coding
carl
parents:
diff changeset
187 # Do two passes, one to just change these to
551433a01cab initial coding
carl
parents:
diff changeset
188 # `$object: dependent.h' and one to simply `dependent.h:'.
551433a01cab initial coding
carl
parents:
diff changeset
189 sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
190 sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
191 else
551433a01cab initial coding
carl
parents:
diff changeset
192 # The sourcefile does not contain any dependencies, so just
551433a01cab initial coding
carl
parents:
diff changeset
193 # store a dummy comment line, to avoid errors with the Makefile
551433a01cab initial coding
carl
parents:
diff changeset
194 # "include basename.Plo" scheme.
551433a01cab initial coding
carl
parents:
diff changeset
195 echo "#dummy" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
196 fi
551433a01cab initial coding
carl
parents:
diff changeset
197 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
198 ;;
551433a01cab initial coding
carl
parents:
diff changeset
199
551433a01cab initial coding
carl
parents:
diff changeset
200 icc)
551433a01cab initial coding
carl
parents:
diff changeset
201 # Must come before tru64.
551433a01cab initial coding
carl
parents:
diff changeset
202
551433a01cab initial coding
carl
parents:
diff changeset
203 # Intel's C compiler understands `-MD -MF file'. However
551433a01cab initial coding
carl
parents:
diff changeset
204 # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
551433a01cab initial coding
carl
parents:
diff changeset
205 # will fill foo.d with something like
551433a01cab initial coding
carl
parents:
diff changeset
206 # foo.o: sub/foo.c
551433a01cab initial coding
carl
parents:
diff changeset
207 # foo.o: sub/foo.h
551433a01cab initial coding
carl
parents:
diff changeset
208 # which is wrong. We want:
551433a01cab initial coding
carl
parents:
diff changeset
209 # sub/foo.o: sub/foo.c
551433a01cab initial coding
carl
parents:
diff changeset
210 # sub/foo.o: sub/foo.h
551433a01cab initial coding
carl
parents:
diff changeset
211 # sub/foo.c:
551433a01cab initial coding
carl
parents:
diff changeset
212 # sub/foo.h:
551433a01cab initial coding
carl
parents:
diff changeset
213
551433a01cab initial coding
carl
parents:
diff changeset
214 "$@" -MD -MF "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
215 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
216 if test $stat -eq 0; then :
551433a01cab initial coding
carl
parents:
diff changeset
217 else
551433a01cab initial coding
carl
parents:
diff changeset
218 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
219 exit $stat
551433a01cab initial coding
carl
parents:
diff changeset
220 fi
551433a01cab initial coding
carl
parents:
diff changeset
221 rm -f "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
222 # Each line is of the form `foo.o: dependent.h'.
551433a01cab initial coding
carl
parents:
diff changeset
223 # Do two passes, one to just change these to
551433a01cab initial coding
carl
parents:
diff changeset
224 # `$object: dependent.h' and one to simply `dependent.h:'.
551433a01cab initial coding
carl
parents:
diff changeset
225 sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
226 sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
227 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
228 ;;
551433a01cab initial coding
carl
parents:
diff changeset
229
551433a01cab initial coding
carl
parents:
diff changeset
230 tru64)
551433a01cab initial coding
carl
parents:
diff changeset
231 # The Tru64 AIX compiler uses -MD to generate dependencies as a side
551433a01cab initial coding
carl
parents:
diff changeset
232 # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
551433a01cab initial coding
carl
parents:
diff changeset
233 # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
551433a01cab initial coding
carl
parents:
diff changeset
234 # dependencies in `foo.d' instead, so we check for that too.
551433a01cab initial coding
carl
parents:
diff changeset
235 # Subdirectories are respected.
551433a01cab initial coding
carl
parents:
diff changeset
236
551433a01cab initial coding
carl
parents:
diff changeset
237 tmpdepfile1="$object.d"
551433a01cab initial coding
carl
parents:
diff changeset
238 tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
551433a01cab initial coding
carl
parents:
diff changeset
239 if test "$libtool" = yes; then
551433a01cab initial coding
carl
parents:
diff changeset
240 "$@" -Wc,-MD
551433a01cab initial coding
carl
parents:
diff changeset
241 else
551433a01cab initial coding
carl
parents:
diff changeset
242 "$@" -MD
551433a01cab initial coding
carl
parents:
diff changeset
243 fi
551433a01cab initial coding
carl
parents:
diff changeset
244
551433a01cab initial coding
carl
parents:
diff changeset
245 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
246 if test $stat -eq 0; then :
551433a01cab initial coding
carl
parents:
diff changeset
247 else
551433a01cab initial coding
carl
parents:
diff changeset
248 rm -f "$tmpdepfile1" "$tmpdepfile2"
551433a01cab initial coding
carl
parents:
diff changeset
249 exit $stat
551433a01cab initial coding
carl
parents:
diff changeset
250 fi
551433a01cab initial coding
carl
parents:
diff changeset
251
551433a01cab initial coding
carl
parents:
diff changeset
252 if test -f "$tmpdepfile1"; then
551433a01cab initial coding
carl
parents:
diff changeset
253 tmpdepfile="$tmpdepfile1"
551433a01cab initial coding
carl
parents:
diff changeset
254 else
551433a01cab initial coding
carl
parents:
diff changeset
255 tmpdepfile="$tmpdepfile2"
551433a01cab initial coding
carl
parents:
diff changeset
256 fi
551433a01cab initial coding
carl
parents:
diff changeset
257 if test -f "$tmpdepfile"; then
551433a01cab initial coding
carl
parents:
diff changeset
258 sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
259 # That's a space and a tab in the [].
551433a01cab initial coding
carl
parents:
diff changeset
260 sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
261 else
551433a01cab initial coding
carl
parents:
diff changeset
262 echo "#dummy" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
263 fi
551433a01cab initial coding
carl
parents:
diff changeset
264 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
265 ;;
551433a01cab initial coding
carl
parents:
diff changeset
266
551433a01cab initial coding
carl
parents:
diff changeset
267 #nosideeffect)
551433a01cab initial coding
carl
parents:
diff changeset
268 # This comment above is used by automake to tell side-effect
551433a01cab initial coding
carl
parents:
diff changeset
269 # dependency tracking mechanisms from slower ones.
551433a01cab initial coding
carl
parents:
diff changeset
270
551433a01cab initial coding
carl
parents:
diff changeset
271 dashmstdout)
551433a01cab initial coding
carl
parents:
diff changeset
272 # Important note: in order to support this mode, a compiler *must*
551433a01cab initial coding
carl
parents:
diff changeset
273 # always write the proprocessed file to stdout, regardless of -o,
551433a01cab initial coding
carl
parents:
diff changeset
274 # because we must use -o when running libtool.
551433a01cab initial coding
carl
parents:
diff changeset
275 test -z "$dashmflag" && dashmflag=-M
551433a01cab initial coding
carl
parents:
diff changeset
276 ( IFS=" "
551433a01cab initial coding
carl
parents:
diff changeset
277 case " $* " in
551433a01cab initial coding
carl
parents:
diff changeset
278 *" --mode=compile "*) # this is libtool, let us make it quiet
551433a01cab initial coding
carl
parents:
diff changeset
279 for arg
551433a01cab initial coding
carl
parents:
diff changeset
280 do # cycle over the arguments
551433a01cab initial coding
carl
parents:
diff changeset
281 case "$arg" in
551433a01cab initial coding
carl
parents:
diff changeset
282 "--mode=compile")
551433a01cab initial coding
carl
parents:
diff changeset
283 # insert --quiet before "--mode=compile"
551433a01cab initial coding
carl
parents:
diff changeset
284 set fnord "$@" --quiet
551433a01cab initial coding
carl
parents:
diff changeset
285 shift # fnord
551433a01cab initial coding
carl
parents:
diff changeset
286 ;;
551433a01cab initial coding
carl
parents:
diff changeset
287 esac
551433a01cab initial coding
carl
parents:
diff changeset
288 set fnord "$@" "$arg"
551433a01cab initial coding
carl
parents:
diff changeset
289 shift # fnord
551433a01cab initial coding
carl
parents:
diff changeset
290 shift # "$arg"
551433a01cab initial coding
carl
parents:
diff changeset
291 done
551433a01cab initial coding
carl
parents:
diff changeset
292 ;;
551433a01cab initial coding
carl
parents:
diff changeset
293 esac
551433a01cab initial coding
carl
parents:
diff changeset
294 "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
295 ) &
551433a01cab initial coding
carl
parents:
diff changeset
296 proc=$!
551433a01cab initial coding
carl
parents:
diff changeset
297 "$@"
551433a01cab initial coding
carl
parents:
diff changeset
298 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
299 wait "$proc"
551433a01cab initial coding
carl
parents:
diff changeset
300 if test "$stat" != 0; then exit $stat; fi
551433a01cab initial coding
carl
parents:
diff changeset
301 rm -f "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
302 cat < "$tmpdepfile" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
303 tr ' ' '
551433a01cab initial coding
carl
parents:
diff changeset
304 ' < "$tmpdepfile" | \
551433a01cab initial coding
carl
parents:
diff changeset
305 ## Some versions of the HPUX 10.20 sed can't process this invocation
551433a01cab initial coding
carl
parents:
diff changeset
306 ## correctly. Breaking it into two sed invocations is a workaround.
551433a01cab initial coding
carl
parents:
diff changeset
307 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
308 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
309 ;;
551433a01cab initial coding
carl
parents:
diff changeset
310
551433a01cab initial coding
carl
parents:
diff changeset
311 dashXmstdout)
551433a01cab initial coding
carl
parents:
diff changeset
312 # This case only exists to satisfy depend.m4. It is never actually
551433a01cab initial coding
carl
parents:
diff changeset
313 # run, as this mode is specially recognized in the preamble.
551433a01cab initial coding
carl
parents:
diff changeset
314 exit 1
551433a01cab initial coding
carl
parents:
diff changeset
315 ;;
551433a01cab initial coding
carl
parents:
diff changeset
316
551433a01cab initial coding
carl
parents:
diff changeset
317 makedepend)
551433a01cab initial coding
carl
parents:
diff changeset
318 # X makedepend
551433a01cab initial coding
carl
parents:
diff changeset
319 (
551433a01cab initial coding
carl
parents:
diff changeset
320 shift
551433a01cab initial coding
carl
parents:
diff changeset
321 cleared=no
551433a01cab initial coding
carl
parents:
diff changeset
322 for arg in "$@"; do
551433a01cab initial coding
carl
parents:
diff changeset
323 case $cleared in no)
551433a01cab initial coding
carl
parents:
diff changeset
324 set ""; shift
551433a01cab initial coding
carl
parents:
diff changeset
325 cleared=yes
551433a01cab initial coding
carl
parents:
diff changeset
326 esac
551433a01cab initial coding
carl
parents:
diff changeset
327 case "$arg" in
551433a01cab initial coding
carl
parents:
diff changeset
328 -D*|-I*)
551433a01cab initial coding
carl
parents:
diff changeset
329 set fnord "$@" "$arg"; shift;;
551433a01cab initial coding
carl
parents:
diff changeset
330 -*)
551433a01cab initial coding
carl
parents:
diff changeset
331 ;;
551433a01cab initial coding
carl
parents:
diff changeset
332 *)
551433a01cab initial coding
carl
parents:
diff changeset
333 set fnord "$@" "$arg"; shift;;
551433a01cab initial coding
carl
parents:
diff changeset
334 esac
551433a01cab initial coding
carl
parents:
diff changeset
335 done
551433a01cab initial coding
carl
parents:
diff changeset
336 obj_suffix="`echo $object | sed 's/^.*\././'`"
551433a01cab initial coding
carl
parents:
diff changeset
337 touch "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
338 ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
551433a01cab initial coding
carl
parents:
diff changeset
339 ) &
551433a01cab initial coding
carl
parents:
diff changeset
340 proc=$!
551433a01cab initial coding
carl
parents:
diff changeset
341 "$@"
551433a01cab initial coding
carl
parents:
diff changeset
342 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
343 wait "$proc"
551433a01cab initial coding
carl
parents:
diff changeset
344 if test "$stat" != 0; then exit $stat; fi
551433a01cab initial coding
carl
parents:
diff changeset
345 rm -f "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
346 cat < "$tmpdepfile" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
347 tail +3 "$tmpdepfile" | tr ' ' '
551433a01cab initial coding
carl
parents:
diff changeset
348 ' | \
551433a01cab initial coding
carl
parents:
diff changeset
349 ## Some versions of the HPUX 10.20 sed can't process this invocation
551433a01cab initial coding
carl
parents:
diff changeset
350 ## correctly. Breaking it into two sed invocations is a workaround.
551433a01cab initial coding
carl
parents:
diff changeset
351 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
352 rm -f "$tmpdepfile" "$tmpdepfile".bak
551433a01cab initial coding
carl
parents:
diff changeset
353 ;;
551433a01cab initial coding
carl
parents:
diff changeset
354
551433a01cab initial coding
carl
parents:
diff changeset
355 cpp)
551433a01cab initial coding
carl
parents:
diff changeset
356 # Important note: in order to support this mode, a compiler *must*
551433a01cab initial coding
carl
parents:
diff changeset
357 # always write the proprocessed file to stdout, regardless of -o,
551433a01cab initial coding
carl
parents:
diff changeset
358 # because we must use -o when running libtool.
551433a01cab initial coding
carl
parents:
diff changeset
359 ( IFS=" "
551433a01cab initial coding
carl
parents:
diff changeset
360 case " $* " in
551433a01cab initial coding
carl
parents:
diff changeset
361 *" --mode=compile "*)
551433a01cab initial coding
carl
parents:
diff changeset
362 for arg
551433a01cab initial coding
carl
parents:
diff changeset
363 do # cycle over the arguments
551433a01cab initial coding
carl
parents:
diff changeset
364 case $arg in
551433a01cab initial coding
carl
parents:
diff changeset
365 "--mode=compile")
551433a01cab initial coding
carl
parents:
diff changeset
366 # insert --quiet before "--mode=compile"
551433a01cab initial coding
carl
parents:
diff changeset
367 set fnord "$@" --quiet
551433a01cab initial coding
carl
parents:
diff changeset
368 shift # fnord
551433a01cab initial coding
carl
parents:
diff changeset
369 ;;
551433a01cab initial coding
carl
parents:
diff changeset
370 esac
551433a01cab initial coding
carl
parents:
diff changeset
371 set fnord "$@" "$arg"
551433a01cab initial coding
carl
parents:
diff changeset
372 shift # fnord
551433a01cab initial coding
carl
parents:
diff changeset
373 shift # "$arg"
551433a01cab initial coding
carl
parents:
diff changeset
374 done
551433a01cab initial coding
carl
parents:
diff changeset
375 ;;
551433a01cab initial coding
carl
parents:
diff changeset
376 esac
551433a01cab initial coding
carl
parents:
diff changeset
377 "$@" -E |
551433a01cab initial coding
carl
parents:
diff changeset
378 sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
551433a01cab initial coding
carl
parents:
diff changeset
379 sed '$ s: \\$::' > "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
380 ) &
551433a01cab initial coding
carl
parents:
diff changeset
381 proc=$!
551433a01cab initial coding
carl
parents:
diff changeset
382 "$@"
551433a01cab initial coding
carl
parents:
diff changeset
383 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
384 wait "$proc"
551433a01cab initial coding
carl
parents:
diff changeset
385 if test "$stat" != 0; then exit $stat; fi
551433a01cab initial coding
carl
parents:
diff changeset
386 rm -f "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
387 echo "$object : \\" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
388 cat < "$tmpdepfile" >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
389 sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
390 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
391 ;;
551433a01cab initial coding
carl
parents:
diff changeset
392
551433a01cab initial coding
carl
parents:
diff changeset
393 msvisualcpp)
551433a01cab initial coding
carl
parents:
diff changeset
394 # Important note: in order to support this mode, a compiler *must*
551433a01cab initial coding
carl
parents:
diff changeset
395 # always write the proprocessed file to stdout, regardless of -o,
551433a01cab initial coding
carl
parents:
diff changeset
396 # because we must use -o when running libtool.
551433a01cab initial coding
carl
parents:
diff changeset
397 ( IFS=" "
551433a01cab initial coding
carl
parents:
diff changeset
398 case " $* " in
551433a01cab initial coding
carl
parents:
diff changeset
399 *" --mode=compile "*)
551433a01cab initial coding
carl
parents:
diff changeset
400 for arg
551433a01cab initial coding
carl
parents:
diff changeset
401 do # cycle over the arguments
551433a01cab initial coding
carl
parents:
diff changeset
402 case $arg in
551433a01cab initial coding
carl
parents:
diff changeset
403 "--mode=compile")
551433a01cab initial coding
carl
parents:
diff changeset
404 # insert --quiet before "--mode=compile"
551433a01cab initial coding
carl
parents:
diff changeset
405 set fnord "$@" --quiet
551433a01cab initial coding
carl
parents:
diff changeset
406 shift # fnord
551433a01cab initial coding
carl
parents:
diff changeset
407 ;;
551433a01cab initial coding
carl
parents:
diff changeset
408 esac
551433a01cab initial coding
carl
parents:
diff changeset
409 set fnord "$@" "$arg"
551433a01cab initial coding
carl
parents:
diff changeset
410 shift # fnord
551433a01cab initial coding
carl
parents:
diff changeset
411 shift # "$arg"
551433a01cab initial coding
carl
parents:
diff changeset
412 done
551433a01cab initial coding
carl
parents:
diff changeset
413 ;;
551433a01cab initial coding
carl
parents:
diff changeset
414 esac
551433a01cab initial coding
carl
parents:
diff changeset
415 "$@" -E |
551433a01cab initial coding
carl
parents:
diff changeset
416 sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
417 ) &
551433a01cab initial coding
carl
parents:
diff changeset
418 proc=$!
551433a01cab initial coding
carl
parents:
diff changeset
419 "$@"
551433a01cab initial coding
carl
parents:
diff changeset
420 stat=$?
551433a01cab initial coding
carl
parents:
diff changeset
421 wait "$proc"
551433a01cab initial coding
carl
parents:
diff changeset
422 if test "$stat" != 0; then exit $stat; fi
551433a01cab initial coding
carl
parents:
diff changeset
423 rm -f "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
424 echo "$object : \\" > "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
425 . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
426 echo " " >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
427 . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
551433a01cab initial coding
carl
parents:
diff changeset
428 rm -f "$tmpdepfile"
551433a01cab initial coding
carl
parents:
diff changeset
429 ;;
551433a01cab initial coding
carl
parents:
diff changeset
430
551433a01cab initial coding
carl
parents:
diff changeset
431 none)
551433a01cab initial coding
carl
parents:
diff changeset
432 exec "$@"
551433a01cab initial coding
carl
parents:
diff changeset
433 ;;
551433a01cab initial coding
carl
parents:
diff changeset
434
551433a01cab initial coding
carl
parents:
diff changeset
435 *)
551433a01cab initial coding
carl
parents:
diff changeset
436 echo "Unknown depmode $depmode" 1>&2
551433a01cab initial coding
carl
parents:
diff changeset
437 exit 1
551433a01cab initial coding
carl
parents:
diff changeset
438 ;;
551433a01cab initial coding
carl
parents:
diff changeset
439 esac
551433a01cab initial coding
carl
parents:
diff changeset
440
551433a01cab initial coding
carl
parents:
diff changeset
441 exit 0