depcomp revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer #! /bin/sh
2 1.1.1.2.2.2 bouyer # depcomp - compile a program generating dependencies as side-effects
3 1.1.1.2.2.2 bouyer
4 1.1.1.2.2.2 bouyer scriptversion=2009-04-28.21; # UTC
5 1.1.1.2.2.2 bouyer
6 1.1.1.2.2.2 bouyer # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
7 1.1.1.2.2.2 bouyer # Software Foundation, Inc.
8 1.1.1.2.2.2 bouyer
9 1.1.1.2.2.2 bouyer # This program is free software; you can redistribute it and/or modify
10 1.1.1.2.2.2 bouyer # it under the terms of the GNU General Public License as published by
11 1.1.1.2.2.2 bouyer # the Free Software Foundation; either version 2, or (at your option)
12 1.1.1.2.2.2 bouyer # any later version.
13 1.1.1.2.2.2 bouyer
14 1.1.1.2.2.2 bouyer # This program is distributed in the hope that it will be useful,
15 1.1.1.2.2.2 bouyer # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 1.1.1.2.2.2 bouyer # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 1.1.1.2.2.2 bouyer # GNU General Public License for more details.
18 1.1.1.2.2.2 bouyer
19 1.1.1.2.2.2 bouyer # You should have received a copy of the GNU General Public License
20 1.1.1.2.2.2 bouyer # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 1.1.1.2.2.2 bouyer
22 1.1.1.2.2.2 bouyer # As a special exception to the GNU General Public License, if you
23 1.1.1.2.2.2 bouyer # distribute this file as part of a program that contains a
24 1.1.1.2.2.2 bouyer # configuration script generated by Autoconf, you may include it under
25 1.1.1.2.2.2 bouyer # the same distribution terms that you use for the rest of that program.
26 1.1.1.2.2.2 bouyer
27 1.1.1.2.2.2 bouyer # Originally written by Alexandre Oliva <oliva (at] dcc.unicamp.br>.
28 1.1.1.2.2.2 bouyer
29 1.1.1.2.2.2 bouyer case $1 in
30 1.1.1.2.2.2 bouyer '')
31 1.1.1.2.2.2 bouyer echo "$0: No command. Try \`$0 --help' for more information." 1>&2
32 1.1.1.2.2.2 bouyer exit 1;
33 1.1.1.2.2.2 bouyer ;;
34 1.1.1.2.2.2 bouyer -h | --h*)
35 1.1.1.2.2.2 bouyer cat <<\EOF
36 1.1.1.2.2.2 bouyer Usage: depcomp [--help] [--version] PROGRAM [ARGS]
37 1.1.1.2.2.2 bouyer
38 1.1.1.2.2.2 bouyer Run PROGRAMS ARGS to compile a file, generating dependencies
39 1.1.1.2.2.2 bouyer as side-effects.
40 1.1.1.2.2.2 bouyer
41 1.1.1.2.2.2 bouyer Environment variables:
42 1.1.1.2.2.2 bouyer depmode Dependency tracking mode.
43 1.1.1.2.2.2 bouyer source Source file read by `PROGRAMS ARGS'.
44 1.1.1.2.2.2 bouyer object Object file output by `PROGRAMS ARGS'.
45 1.1.1.2.2.2 bouyer DEPDIR directory where to store dependencies.
46 1.1.1.2.2.2 bouyer depfile Dependency file to output.
47 1.1.1.2.2.2 bouyer tmpdepfile Temporary file to use when outputing dependencies.
48 1.1.1.2.2.2 bouyer libtool Whether libtool is used (yes/no).
49 1.1.1.2.2.2 bouyer
50 1.1.1.2.2.2 bouyer Report bugs to <bug-automake (at] gnu.org>.
51 1.1.1.2.2.2 bouyer EOF
52 1.1.1.2.2.2 bouyer exit $?
53 1.1.1.2.2.2 bouyer ;;
54 1.1.1.2.2.2 bouyer -v | --v*)
55 1.1.1.2.2.2 bouyer echo "depcomp $scriptversion"
56 1.1.1.2.2.2 bouyer exit $?
57 1.1.1.2.2.2 bouyer ;;
58 1.1.1.2.2.2 bouyer esac
59 1.1.1.2.2.2 bouyer
60 1.1.1.2.2.2 bouyer if test -z "$depmode" || test -z "$source" || test -z "$object"; then
61 1.1.1.2.2.2 bouyer echo "depcomp: Variables source, object and depmode must be set" 1>&2
62 1.1.1.2.2.2 bouyer exit 1
63 1.1.1.2.2.2 bouyer fi
64 1.1.1.2.2.2 bouyer
65 1.1.1.2.2.2 bouyer # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66 1.1.1.2.2.2 bouyer depfile=${depfile-`echo "$object" |
67 1.1.1.2.2.2 bouyer sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68 1.1.1.2.2.2 bouyer tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69 1.1.1.2.2.2 bouyer
70 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
71 1.1.1.2.2.2 bouyer
72 1.1.1.2.2.2 bouyer # Some modes work just like other modes, but use different flags. We
73 1.1.1.2.2.2 bouyer # parameterize here, but still list the modes in the big case below,
74 1.1.1.2.2.2 bouyer # to make depend.m4 easier to write. Note that we *cannot* use a case
75 1.1.1.2.2.2 bouyer # here, because this file can only contain one case statement.
76 1.1.1.2.2.2 bouyer if test "$depmode" = hp; then
77 1.1.1.2.2.2 bouyer # HP compiler uses -M and no extra arg.
78 1.1.1.2.2.2 bouyer gccflag=-M
79 1.1.1.2.2.2 bouyer depmode=gcc
80 1.1.1.2.2.2 bouyer fi
81 1.1.1.2.2.2 bouyer
82 1.1.1.2.2.2 bouyer if test "$depmode" = dashXmstdout; then
83 1.1.1.2.2.2 bouyer # This is just like dashmstdout with a different argument.
84 1.1.1.2.2.2 bouyer dashmflag=-xM
85 1.1.1.2.2.2 bouyer depmode=dashmstdout
86 1.1.1.2.2.2 bouyer fi
87 1.1.1.2.2.2 bouyer
88 1.1.1.2.2.2 bouyer cygpath_u="cygpath -u -f -"
89 1.1.1.2.2.2 bouyer if test "$depmode" = msvcmsys; then
90 1.1.1.2.2.2 bouyer # This is just like msvisualcpp but w/o cygpath translation.
91 1.1.1.2.2.2 bouyer # Just convert the backslash-escaped backslashes to single forward
92 1.1.1.2.2.2 bouyer # slashes to satisfy depend.m4
93 1.1.1.2.2.2 bouyer cygpath_u="sed s,\\\\\\\\,/,g"
94 1.1.1.2.2.2 bouyer depmode=msvisualcpp
95 1.1.1.2.2.2 bouyer fi
96 1.1.1.2.2.2 bouyer
97 1.1.1.2.2.2 bouyer case "$depmode" in
98 1.1.1.2.2.2 bouyer gcc3)
99 1.1.1.2.2.2 bouyer ## gcc 3 implements dependency tracking that does exactly what
100 1.1.1.2.2.2 bouyer ## we want. Yay! Note: for some reason libtool 1.4 doesn't like
101 1.1.1.2.2.2 bouyer ## it if -MD -MP comes after the -MF stuff. Hmm.
102 1.1.1.2.2.2 bouyer ## Unfortunately, FreeBSD c89 acceptance of flags depends upon
103 1.1.1.2.2.2 bouyer ## the command line argument order; so add the flags where they
104 1.1.1.2.2.2 bouyer ## appear in depend2.am. Note that the slowdown incurred here
105 1.1.1.2.2.2 bouyer ## affects only configure: in makefiles, %FASTDEP% shortcuts this.
106 1.1.1.2.2.2 bouyer for arg
107 1.1.1.2.2.2 bouyer do
108 1.1.1.2.2.2 bouyer case $arg in
109 1.1.1.2.2.2 bouyer -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
110 1.1.1.2.2.2 bouyer *) set fnord "$@" "$arg" ;;
111 1.1.1.2.2.2 bouyer esac
112 1.1.1.2.2.2 bouyer shift # fnord
113 1.1.1.2.2.2 bouyer shift # $arg
114 1.1.1.2.2.2 bouyer done
115 1.1.1.2.2.2 bouyer "$@"
116 1.1.1.2.2.2 bouyer stat=$?
117 1.1.1.2.2.2 bouyer if test $stat -eq 0; then :
118 1.1.1.2.2.2 bouyer else
119 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
120 1.1.1.2.2.2 bouyer exit $stat
121 1.1.1.2.2.2 bouyer fi
122 1.1.1.2.2.2 bouyer mv "$tmpdepfile" "$depfile"
123 1.1.1.2.2.2 bouyer ;;
124 1.1.1.2.2.2 bouyer
125 1.1.1.2.2.2 bouyer gcc)
126 1.1.1.2.2.2 bouyer ## There are various ways to get dependency output from gcc. Here's
127 1.1.1.2.2.2 bouyer ## why we pick this rather obscure method:
128 1.1.1.2.2.2 bouyer ## - Don't want to use -MD because we'd like the dependencies to end
129 1.1.1.2.2.2 bouyer ## up in a subdir. Having to rename by hand is ugly.
130 1.1.1.2.2.2 bouyer ## (We might end up doing this anyway to support other compilers.)
131 1.1.1.2.2.2 bouyer ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
132 1.1.1.2.2.2 bouyer ## -MM, not -M (despite what the docs say).
133 1.1.1.2.2.2 bouyer ## - Using -M directly means running the compiler twice (even worse
134 1.1.1.2.2.2 bouyer ## than renaming).
135 1.1.1.2.2.2 bouyer if test -z "$gccflag"; then
136 1.1.1.2.2.2 bouyer gccflag=-MD,
137 1.1.1.2.2.2 bouyer fi
138 1.1.1.2.2.2 bouyer "$@" -Wp,"$gccflag$tmpdepfile"
139 1.1.1.2.2.2 bouyer stat=$?
140 1.1.1.2.2.2 bouyer if test $stat -eq 0; then :
141 1.1.1.2.2.2 bouyer else
142 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
143 1.1.1.2.2.2 bouyer exit $stat
144 1.1.1.2.2.2 bouyer fi
145 1.1.1.2.2.2 bouyer rm -f "$depfile"
146 1.1.1.2.2.2 bouyer echo "$object : \\" > "$depfile"
147 1.1.1.2.2.2 bouyer alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
148 1.1.1.2.2.2 bouyer ## The second -e expression handles DOS-style file names with drive letters.
149 1.1.1.2.2.2 bouyer sed -e 's/^[^:]*: / /' \
150 1.1.1.2.2.2 bouyer -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
151 1.1.1.2.2.2 bouyer ## This next piece of magic avoids the `deleted header file' problem.
152 1.1.1.2.2.2 bouyer ## The problem is that when a header file which appears in a .P file
153 1.1.1.2.2.2 bouyer ## is deleted, the dependency causes make to die (because there is
154 1.1.1.2.2.2 bouyer ## typically no way to rebuild the header). We avoid this by adding
155 1.1.1.2.2.2 bouyer ## dummy dependencies for each header file. Too bad gcc doesn't do
156 1.1.1.2.2.2 bouyer ## this for us directly.
157 1.1.1.2.2.2 bouyer tr ' ' '
158 1.1.1.2.2.2 bouyer ' < "$tmpdepfile" |
159 1.1.1.2.2.2 bouyer ## Some versions of gcc put a space before the `:'. On the theory
160 1.1.1.2.2.2 bouyer ## that the space means something, we add a space to the output as
161 1.1.1.2.2.2 bouyer ## well.
162 1.1.1.2.2.2 bouyer ## Some versions of the HPUX 10.20 sed can't process this invocation
163 1.1.1.2.2.2 bouyer ## correctly. Breaking it into two sed invocations is a workaround.
164 1.1.1.2.2.2 bouyer sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
165 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
166 1.1.1.2.2.2 bouyer ;;
167 1.1.1.2.2.2 bouyer
168 1.1.1.2.2.2 bouyer hp)
169 1.1.1.2.2.2 bouyer # This case exists only to let depend.m4 do its work. It works by
170 1.1.1.2.2.2 bouyer # looking at the text of this script. This case will never be run,
171 1.1.1.2.2.2 bouyer # since it is checked for above.
172 1.1.1.2.2.2 bouyer exit 1
173 1.1.1.2.2.2 bouyer ;;
174 1.1.1.2.2.2 bouyer
175 1.1.1.2.2.2 bouyer sgi)
176 1.1.1.2.2.2 bouyer if test "$libtool" = yes; then
177 1.1.1.2.2.2 bouyer "$@" "-Wp,-MDupdate,$tmpdepfile"
178 1.1.1.2.2.2 bouyer else
179 1.1.1.2.2.2 bouyer "$@" -MDupdate "$tmpdepfile"
180 1.1.1.2.2.2 bouyer fi
181 1.1.1.2.2.2 bouyer stat=$?
182 1.1.1.2.2.2 bouyer if test $stat -eq 0; then :
183 1.1.1.2.2.2 bouyer else
184 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
185 1.1.1.2.2.2 bouyer exit $stat
186 1.1.1.2.2.2 bouyer fi
187 1.1.1.2.2.2 bouyer rm -f "$depfile"
188 1.1.1.2.2.2 bouyer
189 1.1.1.2.2.2 bouyer if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
190 1.1.1.2.2.2 bouyer echo "$object : \\" > "$depfile"
191 1.1.1.2.2.2 bouyer
192 1.1.1.2.2.2 bouyer # Clip off the initial element (the dependent). Don't try to be
193 1.1.1.2.2.2 bouyer # clever and replace this with sed code, as IRIX sed won't handle
194 1.1.1.2.2.2 bouyer # lines with more than a fixed number of characters (4096 in
195 1.1.1.2.2.2 bouyer # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
196 1.1.1.2.2.2 bouyer # the IRIX cc adds comments like `#:fec' to the end of the
197 1.1.1.2.2.2 bouyer # dependency line.
198 1.1.1.2.2.2 bouyer tr ' ' '
199 1.1.1.2.2.2 bouyer ' < "$tmpdepfile" \
200 1.1.1.2.2.2 bouyer | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
201 1.1.1.2.2.2 bouyer tr '
202 1.1.1.2.2.2 bouyer ' ' ' >> "$depfile"
203 1.1.1.2.2.2 bouyer echo >> "$depfile"
204 1.1.1.2.2.2 bouyer
205 1.1.1.2.2.2 bouyer # The second pass generates a dummy entry for each header file.
206 1.1.1.2.2.2 bouyer tr ' ' '
207 1.1.1.2.2.2 bouyer ' < "$tmpdepfile" \
208 1.1.1.2.2.2 bouyer | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
209 1.1.1.2.2.2 bouyer >> "$depfile"
210 1.1.1.2.2.2 bouyer else
211 1.1.1.2.2.2 bouyer # The sourcefile does not contain any dependencies, so just
212 1.1.1.2.2.2 bouyer # store a dummy comment line, to avoid errors with the Makefile
213 1.1.1.2.2.2 bouyer # "include basename.Plo" scheme.
214 1.1.1.2.2.2 bouyer echo "#dummy" > "$depfile"
215 1.1.1.2.2.2 bouyer fi
216 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
217 1.1.1.2.2.2 bouyer ;;
218 1.1.1.2.2.2 bouyer
219 1.1.1.2.2.2 bouyer aix)
220 1.1.1.2.2.2 bouyer # The C for AIX Compiler uses -M and outputs the dependencies
221 1.1.1.2.2.2 bouyer # in a .u file. In older versions, this file always lives in the
222 1.1.1.2.2.2 bouyer # current directory. Also, the AIX compiler puts `$object:' at the
223 1.1.1.2.2.2 bouyer # start of each line; $object doesn't have directory information.
224 1.1.1.2.2.2 bouyer # Version 6 uses the directory in both cases.
225 1.1.1.2.2.2 bouyer dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
226 1.1.1.2.2.2 bouyer test "x$dir" = "x$object" && dir=
227 1.1.1.2.2.2 bouyer base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
228 1.1.1.2.2.2 bouyer if test "$libtool" = yes; then
229 1.1.1.2.2.2 bouyer tmpdepfile1=$dir$base.u
230 1.1.1.2.2.2 bouyer tmpdepfile2=$base.u
231 1.1.1.2.2.2 bouyer tmpdepfile3=$dir.libs/$base.u
232 1.1.1.2.2.2 bouyer "$@" -Wc,-M
233 1.1.1.2.2.2 bouyer else
234 1.1.1.2.2.2 bouyer tmpdepfile1=$dir$base.u
235 1.1.1.2.2.2 bouyer tmpdepfile2=$dir$base.u
236 1.1.1.2.2.2 bouyer tmpdepfile3=$dir$base.u
237 1.1.1.2.2.2 bouyer "$@" -M
238 1.1.1.2.2.2 bouyer fi
239 1.1.1.2.2.2 bouyer stat=$?
240 1.1.1.2.2.2 bouyer
241 1.1.1.2.2.2 bouyer if test $stat -eq 0; then :
242 1.1.1.2.2.2 bouyer else
243 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
244 1.1.1.2.2.2 bouyer exit $stat
245 1.1.1.2.2.2 bouyer fi
246 1.1.1.2.2.2 bouyer
247 1.1.1.2.2.2 bouyer for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
248 1.1.1.2.2.2 bouyer do
249 1.1.1.2.2.2 bouyer test -f "$tmpdepfile" && break
250 1.1.1.2.2.2 bouyer done
251 1.1.1.2.2.2 bouyer if test -f "$tmpdepfile"; then
252 1.1.1.2.2.2 bouyer # Each line is of the form `foo.o: dependent.h'.
253 1.1.1.2.2.2 bouyer # Do two passes, one to just change these to
254 1.1.1.2.2.2 bouyer # `$object: dependent.h' and one to simply `dependent.h:'.
255 1.1.1.2.2.2 bouyer sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
256 1.1.1.2.2.2 bouyer # That's a tab and a space in the [].
257 1.1.1.2.2.2 bouyer sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
258 1.1.1.2.2.2 bouyer else
259 1.1.1.2.2.2 bouyer # The sourcefile does not contain any dependencies, so just
260 1.1.1.2.2.2 bouyer # store a dummy comment line, to avoid errors with the Makefile
261 1.1.1.2.2.2 bouyer # "include basename.Plo" scheme.
262 1.1.1.2.2.2 bouyer echo "#dummy" > "$depfile"
263 1.1.1.2.2.2 bouyer fi
264 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
265 1.1.1.2.2.2 bouyer ;;
266 1.1.1.2.2.2 bouyer
267 1.1.1.2.2.2 bouyer icc)
268 1.1.1.2.2.2 bouyer # Intel's C compiler understands `-MD -MF file'. However on
269 1.1.1.2.2.2 bouyer # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
270 1.1.1.2.2.2 bouyer # ICC 7.0 will fill foo.d with something like
271 1.1.1.2.2.2 bouyer # foo.o: sub/foo.c
272 1.1.1.2.2.2 bouyer # foo.o: sub/foo.h
273 1.1.1.2.2.2 bouyer # which is wrong. We want:
274 1.1.1.2.2.2 bouyer # sub/foo.o: sub/foo.c
275 1.1.1.2.2.2 bouyer # sub/foo.o: sub/foo.h
276 1.1.1.2.2.2 bouyer # sub/foo.c:
277 1.1.1.2.2.2 bouyer # sub/foo.h:
278 1.1.1.2.2.2 bouyer # ICC 7.1 will output
279 1.1.1.2.2.2 bouyer # foo.o: sub/foo.c sub/foo.h
280 1.1.1.2.2.2 bouyer # and will wrap long lines using \ :
281 1.1.1.2.2.2 bouyer # foo.o: sub/foo.c ... \
282 1.1.1.2.2.2 bouyer # sub/foo.h ... \
283 1.1.1.2.2.2 bouyer # ...
284 1.1.1.2.2.2 bouyer
285 1.1.1.2.2.2 bouyer "$@" -MD -MF "$tmpdepfile"
286 1.1.1.2.2.2 bouyer stat=$?
287 1.1.1.2.2.2 bouyer if test $stat -eq 0; then :
288 1.1.1.2.2.2 bouyer else
289 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
290 1.1.1.2.2.2 bouyer exit $stat
291 1.1.1.2.2.2 bouyer fi
292 1.1.1.2.2.2 bouyer rm -f "$depfile"
293 1.1.1.2.2.2 bouyer # Each line is of the form `foo.o: dependent.h',
294 1.1.1.2.2.2 bouyer # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
295 1.1.1.2.2.2 bouyer # Do two passes, one to just change these to
296 1.1.1.2.2.2 bouyer # `$object: dependent.h' and one to simply `dependent.h:'.
297 1.1.1.2.2.2 bouyer sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
298 1.1.1.2.2.2 bouyer # Some versions of the HPUX 10.20 sed can't process this invocation
299 1.1.1.2.2.2 bouyer # correctly. Breaking it into two sed invocations is a workaround.
300 1.1.1.2.2.2 bouyer sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
301 1.1.1.2.2.2 bouyer sed -e 's/$/ :/' >> "$depfile"
302 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
303 1.1.1.2.2.2 bouyer ;;
304 1.1.1.2.2.2 bouyer
305 1.1.1.2.2.2 bouyer hp2)
306 1.1.1.2.2.2 bouyer # The "hp" stanza above does not work with aCC (C++) and HP's ia64
307 1.1.1.2.2.2 bouyer # compilers, which have integrated preprocessors. The correct option
308 1.1.1.2.2.2 bouyer # to use with these is +Maked; it writes dependencies to a file named
309 1.1.1.2.2.2 bouyer # 'foo.d', which lands next to the object file, wherever that
310 1.1.1.2.2.2 bouyer # happens to be.
311 1.1.1.2.2.2 bouyer # Much of this is similar to the tru64 case; see comments there.
312 1.1.1.2.2.2 bouyer dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
313 1.1.1.2.2.2 bouyer test "x$dir" = "x$object" && dir=
314 1.1.1.2.2.2 bouyer base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
315 1.1.1.2.2.2 bouyer if test "$libtool" = yes; then
316 1.1.1.2.2.2 bouyer tmpdepfile1=$dir$base.d
317 1.1.1.2.2.2 bouyer tmpdepfile2=$dir.libs/$base.d
318 1.1.1.2.2.2 bouyer "$@" -Wc,+Maked
319 1.1.1.2.2.2 bouyer else
320 1.1.1.2.2.2 bouyer tmpdepfile1=$dir$base.d
321 1.1.1.2.2.2 bouyer tmpdepfile2=$dir$base.d
322 1.1.1.2.2.2 bouyer "$@" +Maked
323 1.1.1.2.2.2 bouyer fi
324 1.1.1.2.2.2 bouyer stat=$?
325 1.1.1.2.2.2 bouyer if test $stat -eq 0; then :
326 1.1.1.2.2.2 bouyer else
327 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile1" "$tmpdepfile2"
328 1.1.1.2.2.2 bouyer exit $stat
329 1.1.1.2.2.2 bouyer fi
330 1.1.1.2.2.2 bouyer
331 1.1.1.2.2.2 bouyer for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
332 1.1.1.2.2.2 bouyer do
333 1.1.1.2.2.2 bouyer test -f "$tmpdepfile" && break
334 1.1.1.2.2.2 bouyer done
335 1.1.1.2.2.2 bouyer if test -f "$tmpdepfile"; then
336 1.1.1.2.2.2 bouyer sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
337 1.1.1.2.2.2 bouyer # Add `dependent.h:' lines.
338 1.1.1.2.2.2 bouyer sed -ne '2,${
339 1.1.1.2.2.2 bouyer s/^ *//
340 1.1.1.2.2.2 bouyer s/ \\*$//
341 1.1.1.2.2.2 bouyer s/$/:/
342 1.1.1.2.2.2 bouyer p
343 1.1.1.2.2.2 bouyer }' "$tmpdepfile" >> "$depfile"
344 1.1.1.2.2.2 bouyer else
345 1.1.1.2.2.2 bouyer echo "#dummy" > "$depfile"
346 1.1.1.2.2.2 bouyer fi
347 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile" "$tmpdepfile2"
348 1.1.1.2.2.2 bouyer ;;
349 1.1.1.2.2.2 bouyer
350 1.1.1.2.2.2 bouyer tru64)
351 1.1.1.2.2.2 bouyer # The Tru64 compiler uses -MD to generate dependencies as a side
352 1.1.1.2.2.2 bouyer # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
353 1.1.1.2.2.2 bouyer # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
354 1.1.1.2.2.2 bouyer # dependencies in `foo.d' instead, so we check for that too.
355 1.1.1.2.2.2 bouyer # Subdirectories are respected.
356 1.1.1.2.2.2 bouyer dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
357 1.1.1.2.2.2 bouyer test "x$dir" = "x$object" && dir=
358 1.1.1.2.2.2 bouyer base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
359 1.1.1.2.2.2 bouyer
360 1.1.1.2.2.2 bouyer if test "$libtool" = yes; then
361 1.1.1.2.2.2 bouyer # With Tru64 cc, shared objects can also be used to make a
362 1.1.1.2.2.2 bouyer # static library. This mechanism is used in libtool 1.4 series to
363 1.1.1.2.2.2 bouyer # handle both shared and static libraries in a single compilation.
364 1.1.1.2.2.2 bouyer # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
365 1.1.1.2.2.2 bouyer #
366 1.1.1.2.2.2 bouyer # With libtool 1.5 this exception was removed, and libtool now
367 1.1.1.2.2.2 bouyer # generates 2 separate objects for the 2 libraries. These two
368 1.1.1.2.2.2 bouyer # compilations output dependencies in $dir.libs/$base.o.d and
369 1.1.1.2.2.2 bouyer # in $dir$base.o.d. We have to check for both files, because
370 1.1.1.2.2.2 bouyer # one of the two compilations can be disabled. We should prefer
371 1.1.1.2.2.2 bouyer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
372 1.1.1.2.2.2 bouyer # automatically cleaned when .libs/ is deleted, while ignoring
373 1.1.1.2.2.2 bouyer # the former would cause a distcleancheck panic.
374 1.1.1.2.2.2 bouyer tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
375 1.1.1.2.2.2 bouyer tmpdepfile2=$dir$base.o.d # libtool 1.5
376 1.1.1.2.2.2 bouyer tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
377 1.1.1.2.2.2 bouyer tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
378 1.1.1.2.2.2 bouyer "$@" -Wc,-MD
379 1.1.1.2.2.2 bouyer else
380 1.1.1.2.2.2 bouyer tmpdepfile1=$dir$base.o.d
381 1.1.1.2.2.2 bouyer tmpdepfile2=$dir$base.d
382 1.1.1.2.2.2 bouyer tmpdepfile3=$dir$base.d
383 1.1.1.2.2.2 bouyer tmpdepfile4=$dir$base.d
384 1.1.1.2.2.2 bouyer "$@" -MD
385 1.1.1.2.2.2 bouyer fi
386 1.1.1.2.2.2 bouyer
387 1.1.1.2.2.2 bouyer stat=$?
388 1.1.1.2.2.2 bouyer if test $stat -eq 0; then :
389 1.1.1.2.2.2 bouyer else
390 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
391 1.1.1.2.2.2 bouyer exit $stat
392 1.1.1.2.2.2 bouyer fi
393 1.1.1.2.2.2 bouyer
394 1.1.1.2.2.2 bouyer for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
395 1.1.1.2.2.2 bouyer do
396 1.1.1.2.2.2 bouyer test -f "$tmpdepfile" && break
397 1.1.1.2.2.2 bouyer done
398 1.1.1.2.2.2 bouyer if test -f "$tmpdepfile"; then
399 1.1.1.2.2.2 bouyer sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
400 1.1.1.2.2.2 bouyer # That's a tab and a space in the [].
401 1.1.1.2.2.2 bouyer sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
402 1.1.1.2.2.2 bouyer else
403 1.1.1.2.2.2 bouyer echo "#dummy" > "$depfile"
404 1.1.1.2.2.2 bouyer fi
405 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
406 1.1.1.2.2.2 bouyer ;;
407 1.1.1.2.2.2 bouyer
408 1.1.1.2.2.2 bouyer #nosideeffect)
409 1.1.1.2.2.2 bouyer # This comment above is used by automake to tell side-effect
410 1.1.1.2.2.2 bouyer # dependency tracking mechanisms from slower ones.
411 1.1.1.2.2.2 bouyer
412 1.1.1.2.2.2 bouyer dashmstdout)
413 1.1.1.2.2.2 bouyer # Important note: in order to support this mode, a compiler *must*
414 1.1.1.2.2.2 bouyer # always write the preprocessed file to stdout, regardless of -o.
415 1.1.1.2.2.2 bouyer "$@" || exit $?
416 1.1.1.2.2.2 bouyer
417 1.1.1.2.2.2 bouyer # Remove the call to Libtool.
418 1.1.1.2.2.2 bouyer if test "$libtool" = yes; then
419 1.1.1.2.2.2 bouyer while test "X$1" != 'X--mode=compile'; do
420 1.1.1.2.2.2 bouyer shift
421 1.1.1.2.2.2 bouyer done
422 1.1.1.2.2.2 bouyer shift
423 1.1.1.2.2.2 bouyer fi
424 1.1.1.2.2.2 bouyer
425 1.1.1.2.2.2 bouyer # Remove `-o $object'.
426 1.1.1.2.2.2 bouyer IFS=" "
427 1.1.1.2.2.2 bouyer for arg
428 1.1.1.2.2.2 bouyer do
429 1.1.1.2.2.2 bouyer case $arg in
430 1.1.1.2.2.2 bouyer -o)
431 1.1.1.2.2.2 bouyer shift
432 1.1.1.2.2.2 bouyer ;;
433 1.1.1.2.2.2 bouyer $object)
434 1.1.1.2.2.2 bouyer shift
435 1.1.1.2.2.2 bouyer ;;
436 1.1.1.2.2.2 bouyer *)
437 1.1.1.2.2.2 bouyer set fnord "$@" "$arg"
438 1.1.1.2.2.2 bouyer shift # fnord
439 1.1.1.2.2.2 bouyer shift # $arg
440 1.1.1.2.2.2 bouyer ;;
441 1.1.1.2.2.2 bouyer esac
442 1.1.1.2.2.2 bouyer done
443 1.1.1.2.2.2 bouyer
444 1.1.1.2.2.2 bouyer test -z "$dashmflag" && dashmflag=-M
445 1.1.1.2.2.2 bouyer # Require at least two characters before searching for `:'
446 1.1.1.2.2.2 bouyer # in the target name. This is to cope with DOS-style filenames:
447 1.1.1.2.2.2 bouyer # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
448 1.1.1.2.2.2 bouyer "$@" $dashmflag |
449 1.1.1.2.2.2 bouyer sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
450 1.1.1.2.2.2 bouyer rm -f "$depfile"
451 1.1.1.2.2.2 bouyer cat < "$tmpdepfile" > "$depfile"
452 1.1.1.2.2.2 bouyer tr ' ' '
453 1.1.1.2.2.2 bouyer ' < "$tmpdepfile" | \
454 1.1.1.2.2.2 bouyer ## Some versions of the HPUX 10.20 sed can't process this invocation
455 1.1.1.2.2.2 bouyer ## correctly. Breaking it into two sed invocations is a workaround.
456 1.1.1.2.2.2 bouyer sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
457 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
458 1.1.1.2.2.2 bouyer ;;
459 1.1.1.2.2.2 bouyer
460 1.1.1.2.2.2 bouyer dashXmstdout)
461 1.1.1.2.2.2 bouyer # This case only exists to satisfy depend.m4. It is never actually
462 1.1.1.2.2.2 bouyer # run, as this mode is specially recognized in the preamble.
463 1.1.1.2.2.2 bouyer exit 1
464 1.1.1.2.2.2 bouyer ;;
465 1.1.1.2.2.2 bouyer
466 1.1.1.2.2.2 bouyer makedepend)
467 1.1.1.2.2.2 bouyer "$@" || exit $?
468 1.1.1.2.2.2 bouyer # Remove any Libtool call
469 1.1.1.2.2.2 bouyer if test "$libtool" = yes; then
470 1.1.1.2.2.2 bouyer while test "X$1" != 'X--mode=compile'; do
471 1.1.1.2.2.2 bouyer shift
472 1.1.1.2.2.2 bouyer done
473 1.1.1.2.2.2 bouyer shift
474 1.1.1.2.2.2 bouyer fi
475 1.1.1.2.2.2 bouyer # X makedepend
476 1.1.1.2.2.2 bouyer shift
477 1.1.1.2.2.2 bouyer cleared=no eat=no
478 1.1.1.2.2.2 bouyer for arg
479 1.1.1.2.2.2 bouyer do
480 1.1.1.2.2.2 bouyer case $cleared in
481 1.1.1.2.2.2 bouyer no)
482 1.1.1.2.2.2 bouyer set ""; shift
483 1.1.1.2.2.2 bouyer cleared=yes ;;
484 1.1.1.2.2.2 bouyer esac
485 1.1.1.2.2.2 bouyer if test $eat = yes; then
486 1.1.1.2.2.2 bouyer eat=no
487 1.1.1.2.2.2 bouyer continue
488 1.1.1.2.2.2 bouyer fi
489 1.1.1.2.2.2 bouyer case "$arg" in
490 1.1.1.2.2.2 bouyer -D*|-I*)
491 1.1.1.2.2.2 bouyer set fnord "$@" "$arg"; shift ;;
492 1.1.1.2.2.2 bouyer # Strip any option that makedepend may not understand. Remove
493 1.1.1.2.2.2 bouyer # the object too, otherwise makedepend will parse it as a source file.
494 1.1.1.2.2.2 bouyer -arch)
495 1.1.1.2.2.2 bouyer eat=yes ;;
496 1.1.1.2.2.2 bouyer -*|$object)
497 1.1.1.2.2.2 bouyer ;;
498 1.1.1.2.2.2 bouyer *)
499 1.1.1.2.2.2 bouyer set fnord "$@" "$arg"; shift ;;
500 1.1.1.2.2.2 bouyer esac
501 1.1.1.2.2.2 bouyer done
502 1.1.1.2.2.2 bouyer obj_suffix=`echo "$object" | sed 's/^.*\././'`
503 1.1.1.2.2.2 bouyer touch "$tmpdepfile"
504 1.1.1.2.2.2 bouyer ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
505 1.1.1.2.2.2 bouyer rm -f "$depfile"
506 1.1.1.2.2.2 bouyer cat < "$tmpdepfile" > "$depfile"
507 1.1.1.2.2.2 bouyer sed '1,2d' "$tmpdepfile" | tr ' ' '
508 1.1.1.2.2.2 bouyer ' | \
509 1.1.1.2.2.2 bouyer ## Some versions of the HPUX 10.20 sed can't process this invocation
510 1.1.1.2.2.2 bouyer ## correctly. Breaking it into two sed invocations is a workaround.
511 1.1.1.2.2.2 bouyer sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
512 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile" "$tmpdepfile".bak
513 1.1.1.2.2.2 bouyer ;;
514 1.1.1.2.2.2 bouyer
515 1.1.1.2.2.2 bouyer cpp)
516 1.1.1.2.2.2 bouyer # Important note: in order to support this mode, a compiler *must*
517 1.1.1.2.2.2 bouyer # always write the preprocessed file to stdout.
518 1.1.1.2.2.2 bouyer "$@" || exit $?
519 1.1.1.2.2.2 bouyer
520 1.1.1.2.2.2 bouyer # Remove the call to Libtool.
521 1.1.1.2.2.2 bouyer if test "$libtool" = yes; then
522 1.1.1.2.2.2 bouyer while test "X$1" != 'X--mode=compile'; do
523 1.1.1.2.2.2 bouyer shift
524 1.1.1.2.2.2 bouyer done
525 1.1.1.2.2.2 bouyer shift
526 1.1.1.2.2.2 bouyer fi
527 1.1.1.2.2.2 bouyer
528 1.1.1.2.2.2 bouyer # Remove `-o $object'.
529 1.1.1.2.2.2 bouyer IFS=" "
530 1.1.1.2.2.2 bouyer for arg
531 1.1.1.2.2.2 bouyer do
532 1.1.1.2.2.2 bouyer case $arg in
533 1.1.1.2.2.2 bouyer -o)
534 1.1.1.2.2.2 bouyer shift
535 1.1.1.2.2.2 bouyer ;;
536 1.1.1.2.2.2 bouyer $object)
537 1.1.1.2.2.2 bouyer shift
538 1.1.1.2.2.2 bouyer ;;
539 1.1.1.2.2.2 bouyer *)
540 1.1.1.2.2.2 bouyer set fnord "$@" "$arg"
541 1.1.1.2.2.2 bouyer shift # fnord
542 1.1.1.2.2.2 bouyer shift # $arg
543 1.1.1.2.2.2 bouyer ;;
544 1.1.1.2.2.2 bouyer esac
545 1.1.1.2.2.2 bouyer done
546 1.1.1.2.2.2 bouyer
547 1.1.1.2.2.2 bouyer "$@" -E |
548 1.1.1.2.2.2 bouyer sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
549 1.1.1.2.2.2 bouyer -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
550 1.1.1.2.2.2 bouyer sed '$ s: \\$::' > "$tmpdepfile"
551 1.1.1.2.2.2 bouyer rm -f "$depfile"
552 1.1.1.2.2.2 bouyer echo "$object : \\" > "$depfile"
553 1.1.1.2.2.2 bouyer cat < "$tmpdepfile" >> "$depfile"
554 1.1.1.2.2.2 bouyer sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
555 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
556 1.1.1.2.2.2 bouyer ;;
557 1.1.1.2.2.2 bouyer
558 1.1.1.2.2.2 bouyer msvisualcpp)
559 1.1.1.2.2.2 bouyer # Important note: in order to support this mode, a compiler *must*
560 1.1.1.2.2.2 bouyer # always write the preprocessed file to stdout.
561 1.1.1.2.2.2 bouyer "$@" || exit $?
562 1.1.1.2.2.2 bouyer
563 1.1.1.2.2.2 bouyer # Remove the call to Libtool.
564 1.1.1.2.2.2 bouyer if test "$libtool" = yes; then
565 1.1.1.2.2.2 bouyer while test "X$1" != 'X--mode=compile'; do
566 1.1.1.2.2.2 bouyer shift
567 1.1.1.2.2.2 bouyer done
568 1.1.1.2.2.2 bouyer shift
569 1.1.1.2.2.2 bouyer fi
570 1.1.1.2.2.2 bouyer
571 1.1.1.2.2.2 bouyer IFS=" "
572 1.1.1.2.2.2 bouyer for arg
573 1.1.1.2.2.2 bouyer do
574 1.1.1.2.2.2 bouyer case "$arg" in
575 1.1.1.2.2.2 bouyer -o)
576 1.1.1.2.2.2 bouyer shift
577 1.1.1.2.2.2 bouyer ;;
578 1.1.1.2.2.2 bouyer $object)
579 1.1.1.2.2.2 bouyer shift
580 1.1.1.2.2.2 bouyer ;;
581 1.1.1.2.2.2 bouyer "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
582 1.1.1.2.2.2 bouyer set fnord "$@"
583 1.1.1.2.2.2 bouyer shift
584 1.1.1.2.2.2 bouyer shift
585 1.1.1.2.2.2 bouyer ;;
586 1.1.1.2.2.2 bouyer *)
587 1.1.1.2.2.2 bouyer set fnord "$@" "$arg"
588 1.1.1.2.2.2 bouyer shift
589 1.1.1.2.2.2 bouyer shift
590 1.1.1.2.2.2 bouyer ;;
591 1.1.1.2.2.2 bouyer esac
592 1.1.1.2.2.2 bouyer done
593 1.1.1.2.2.2 bouyer "$@" -E 2>/dev/null |
594 1.1.1.2.2.2 bouyer sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
595 1.1.1.2.2.2 bouyer rm -f "$depfile"
596 1.1.1.2.2.2 bouyer echo "$object : \\" > "$depfile"
597 1.1.1.2.2.2 bouyer sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
598 1.1.1.2.2.2 bouyer echo " " >> "$depfile"
599 1.1.1.2.2.2 bouyer sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
600 1.1.1.2.2.2 bouyer rm -f "$tmpdepfile"
601 1.1.1.2.2.2 bouyer ;;
602 1.1.1.2.2.2 bouyer
603 1.1.1.2.2.2 bouyer msvcmsys)
604 1.1.1.2.2.2 bouyer # This case exists only to let depend.m4 do its work. It works by
605 1.1.1.2.2.2 bouyer # looking at the text of this script. This case will never be run,
606 1.1.1.2.2.2 bouyer # since it is checked for above.
607 1.1.1.2.2.2 bouyer exit 1
608 1.1.1.2.2.2 bouyer ;;
609 1.1.1.2.2.2 bouyer
610 1.1.1.2.2.2 bouyer none)
611 1.1.1.2.2.2 bouyer exec "$@"
612 1.1.1.2.2.2 bouyer ;;
613 1.1.1.2.2.2 bouyer
614 1.1.1.2.2.2 bouyer *)
615 1.1.1.2.2.2 bouyer echo "Unknown depmode $depmode" 1>&2
616 1.1.1.2.2.2 bouyer exit 1
617 1.1.1.2.2.2 bouyer ;;
618 1.1.1.2.2.2 bouyer esac
619 1.1.1.2.2.2 bouyer
620 1.1.1.2.2.2 bouyer exit 0
621 1.1.1.2.2.2 bouyer
622 1.1.1.2.2.2 bouyer # Local Variables:
623 1.1.1.2.2.2 bouyer # mode: shell-script
624 1.1.1.2.2.2 bouyer # sh-indentation: 2
625 1.1.1.2.2.2 bouyer # eval: (add-hook 'write-file-hooks 'time-stamp)
626 1.1.1.2.2.2 bouyer # time-stamp-start: "scriptversion="
627 1.1.1.2.2.2 bouyer # time-stamp-format: "%:y-%02m-%02d.%02H"
628 1.1.1.2.2.2 bouyer # time-stamp-time-zone: "UTC"
629 1.1.1.2.2.2 bouyer # time-stamp-end: "; # UTC"
630 1.1.1.2.2.2 bouyer # End:
631