comparison depcomp @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 77e2b8dfacca
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 #! /bin/sh 1 #! /bin/sh
2 # depcomp - compile a program generating dependencies as side-effects 2 # depcomp - compile a program generating dependencies as side-effects
3 3
4 scriptversion=2009-04-28.21; # UTC 4 scriptversion=2013-05-30.07; # UTC
5 5
6 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 6 # Copyright (C) 1999-2014 Free Software Foundation, Inc.
7 # Software Foundation, Inc.
8 7
9 # This program is free software; you can redistribute it and/or modify 8 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by 9 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option) 10 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version. 11 # any later version.
26 25
27 # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 26 # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28 27
29 case $1 in 28 case $1 in
30 '') 29 '')
31 echo "$0: No command. Try \`$0 --help' for more information." 1>&2 30 echo "$0: No command. Try '$0 --help' for more information." 1>&2
32 exit 1; 31 exit 1;
33 ;; 32 ;;
34 -h | --h*) 33 -h | --h*)
35 cat <<\EOF 34 cat <<\EOF
36 Usage: depcomp [--help] [--version] PROGRAM [ARGS] 35 Usage: depcomp [--help] [--version] PROGRAM [ARGS]
37 36
38 Run PROGRAMS ARGS to compile a file, generating dependencies 37 Run PROGRAMS ARGS to compile a file, generating dependencies
39 as side-effects. 38 as side-effects.
40 39
41 Environment variables: 40 Environment variables:
42 depmode Dependency tracking mode. 41 depmode Dependency tracking mode.
43 source Source file read by `PROGRAMS ARGS'. 42 source Source file read by 'PROGRAMS ARGS'.
44 object Object file output by `PROGRAMS ARGS'. 43 object Object file output by 'PROGRAMS ARGS'.
45 DEPDIR directory where to store dependencies. 44 DEPDIR directory where to store dependencies.
46 depfile Dependency file to output. 45 depfile Dependency file to output.
47 tmpdepfile Temporary file to use when outputing dependencies. 46 tmpdepfile Temporary file to use when outputting dependencies.
48 libtool Whether libtool is used (yes/no). 47 libtool Whether libtool is used (yes/no).
49 48
50 Report bugs to <bug-automake@gnu.org>. 49 Report bugs to <bug-automake@gnu.org>.
51 EOF 50 EOF
52 exit $? 51 exit $?
55 echo "depcomp $scriptversion" 54 echo "depcomp $scriptversion"
56 exit $? 55 exit $?
57 ;; 56 ;;
58 esac 57 esac
59 58
59 # Get the directory component of the given path, and save it in the
60 # global variables '$dir'. Note that this directory component will
61 # be either empty or ending with a '/' character. This is deliberate.
62 set_dir_from ()
63 {
64 case $1 in
65 */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
66 *) dir=;;
67 esac
68 }
69
70 # Get the suffix-stripped basename of the given path, and save it the
71 # global variable '$base'.
72 set_base_from ()
73 {
74 base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
75 }
76
77 # If no dependency file was actually created by the compiler invocation,
78 # we still have to create a dummy depfile, to avoid errors with the
79 # Makefile "include basename.Plo" scheme.
80 make_dummy_depfile ()
81 {
82 echo "#dummy" > "$depfile"
83 }
84
85 # Factor out some common post-processing of the generated depfile.
86 # Requires the auxiliary global variable '$tmpdepfile' to be set.
87 aix_post_process_depfile ()
88 {
89 # If the compiler actually managed to produce a dependency file,
90 # post-process it.
91 if test -f "$tmpdepfile"; then
92 # Each line is of the form 'foo.o: dependency.h'.
93 # Do two passes, one to just change these to
94 # $object: dependency.h
95 # and one to simply output
96 # dependency.h:
97 # which is needed to avoid the deleted-header problem.
98 { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
99 sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
100 } > "$depfile"
101 rm -f "$tmpdepfile"
102 else
103 make_dummy_depfile
104 fi
105 }
106
107 # A tabulation character.
108 tab=' '
109 # A newline character.
110 nl='
111 '
112 # Character ranges might be problematic outside the C locale.
113 # These definitions help.
114 upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
115 lower=abcdefghijklmnopqrstuvwxyz
116 digits=0123456789
117 alpha=${upper}${lower}
118
60 if test -z "$depmode" || test -z "$source" || test -z "$object"; then 119 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
61 echo "depcomp: Variables source, object and depmode must be set" 1>&2 120 echo "depcomp: Variables source, object and depmode must be set" 1>&2
62 exit 1 121 exit 1
63 fi 122 fi
64 123
66 depfile=${depfile-`echo "$object" | 125 depfile=${depfile-`echo "$object" |
67 sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 126 sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 127 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69 128
70 rm -f "$tmpdepfile" 129 rm -f "$tmpdepfile"
130
131 # Avoid interferences from the environment.
132 gccflag= dashmflag=
71 133
72 # Some modes work just like other modes, but use different flags. We 134 # Some modes work just like other modes, but use different flags. We
73 # parameterize here, but still list the modes in the big case below, 135 # parameterize here, but still list the modes in the big case below,
74 # to make depend.m4 easier to write. Note that we *cannot* use a case 136 # to make depend.m4 easier to write. Note that we *cannot* use a case
75 # here, because this file can only contain one case statement. 137 # here, because this file can only contain one case statement.
78 gccflag=-M 140 gccflag=-M
79 depmode=gcc 141 depmode=gcc
80 fi 142 fi
81 143
82 if test "$depmode" = dashXmstdout; then 144 if test "$depmode" = dashXmstdout; then
83 # This is just like dashmstdout with a different argument. 145 # This is just like dashmstdout with a different argument.
84 dashmflag=-xM 146 dashmflag=-xM
85 depmode=dashmstdout 147 depmode=dashmstdout
86 fi 148 fi
87 149
88 cygpath_u="cygpath -u -f -" 150 cygpath_u="cygpath -u -f -"
89 if test "$depmode" = msvcmsys; then 151 if test "$depmode" = msvcmsys; then
90 # This is just like msvisualcpp but w/o cygpath translation. 152 # This is just like msvisualcpp but w/o cygpath translation.
91 # Just convert the backslash-escaped backslashes to single forward 153 # Just convert the backslash-escaped backslashes to single forward
92 # slashes to satisfy depend.m4 154 # slashes to satisfy depend.m4
93 cygpath_u="sed s,\\\\\\\\,/,g" 155 cygpath_u='sed s,\\\\,/,g'
94 depmode=msvisualcpp 156 depmode=msvisualcpp
157 fi
158
159 if test "$depmode" = msvc7msys; then
160 # This is just like msvc7 but w/o cygpath translation.
161 # Just convert the backslash-escaped backslashes to single forward
162 # slashes to satisfy depend.m4
163 cygpath_u='sed s,\\\\,/,g'
164 depmode=msvc7
165 fi
166
167 if test "$depmode" = xlc; then
168 # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
169 gccflag=-qmakedep=gcc,-MF
170 depmode=gcc
95 fi 171 fi
96 172
97 case "$depmode" in 173 case "$depmode" in
98 gcc3) 174 gcc3)
99 ## gcc 3 implements dependency tracking that does exactly what 175 ## gcc 3 implements dependency tracking that does exactly what
112 shift # fnord 188 shift # fnord
113 shift # $arg 189 shift # $arg
114 done 190 done
115 "$@" 191 "$@"
116 stat=$? 192 stat=$?
117 if test $stat -eq 0; then : 193 if test $stat -ne 0; then
118 else
119 rm -f "$tmpdepfile" 194 rm -f "$tmpdepfile"
120 exit $stat 195 exit $stat
121 fi 196 fi
122 mv "$tmpdepfile" "$depfile" 197 mv "$tmpdepfile" "$depfile"
123 ;; 198 ;;
124 199
125 gcc) 200 gcc)
201 ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
202 ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
203 ## (see the conditional assignment to $gccflag above).
126 ## There are various ways to get dependency output from gcc. Here's 204 ## There are various ways to get dependency output from gcc. Here's
127 ## why we pick this rather obscure method: 205 ## why we pick this rather obscure method:
128 ## - Don't want to use -MD because we'd like the dependencies to end 206 ## - Don't want to use -MD because we'd like the dependencies to end
129 ## up in a subdir. Having to rename by hand is ugly. 207 ## up in a subdir. Having to rename by hand is ugly.
130 ## (We might end up doing this anyway to support other compilers.) 208 ## (We might end up doing this anyway to support other compilers.)
131 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 209 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
132 ## -MM, not -M (despite what the docs say). 210 ## -MM, not -M (despite what the docs say). Also, it might not be
211 ## supported by the other compilers which use the 'gcc' depmode.
133 ## - Using -M directly means running the compiler twice (even worse 212 ## - Using -M directly means running the compiler twice (even worse
134 ## than renaming). 213 ## than renaming).
135 if test -z "$gccflag"; then 214 if test -z "$gccflag"; then
136 gccflag=-MD, 215 gccflag=-MD,
137 fi 216 fi
138 "$@" -Wp,"$gccflag$tmpdepfile" 217 "$@" -Wp,"$gccflag$tmpdepfile"
139 stat=$? 218 stat=$?
140 if test $stat -eq 0; then : 219 if test $stat -ne 0; then
141 else
142 rm -f "$tmpdepfile" 220 rm -f "$tmpdepfile"
143 exit $stat 221 exit $stat
144 fi 222 fi
145 rm -f "$depfile" 223 rm -f "$depfile"
146 echo "$object : \\" > "$depfile" 224 echo "$object : \\" > "$depfile"
147 alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 225 # The second -e expression handles DOS-style file names with drive
148 ## The second -e expression handles DOS-style file names with drive letters. 226 # letters.
149 sed -e 's/^[^:]*: / /' \ 227 sed -e 's/^[^:]*: / /' \
150 -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 228 -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
151 ## This next piece of magic avoids the `deleted header file' problem. 229 ## This next piece of magic avoids the "deleted header file" problem.
152 ## The problem is that when a header file which appears in a .P file 230 ## The problem is that when a header file which appears in a .P file
153 ## is deleted, the dependency causes make to die (because there is 231 ## is deleted, the dependency causes make to die (because there is
154 ## typically no way to rebuild the header). We avoid this by adding 232 ## typically no way to rebuild the header). We avoid this by adding
155 ## dummy dependencies for each header file. Too bad gcc doesn't do 233 ## dummy dependencies for each header file. Too bad gcc doesn't do
156 ## this for us directly. 234 ## this for us directly.
157 tr ' ' ' 235 ## Some versions of gcc put a space before the ':'. On the theory
158 ' < "$tmpdepfile" |
159 ## Some versions of gcc put a space before the `:'. On the theory
160 ## that the space means something, we add a space to the output as 236 ## that the space means something, we add a space to the output as
161 ## well. 237 ## well. hp depmode also adds that space, but also prefixes the VPATH
238 ## to the object. Take care to not repeat it in the output.
162 ## Some versions of the HPUX 10.20 sed can't process this invocation 239 ## Some versions of the HPUX 10.20 sed can't process this invocation
163 ## correctly. Breaking it into two sed invocations is a workaround. 240 ## correctly. Breaking it into two sed invocations is a workaround.
164 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 241 tr ' ' "$nl" < "$tmpdepfile" \
242 | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
243 | sed -e 's/$/ :/' >> "$depfile"
165 rm -f "$tmpdepfile" 244 rm -f "$tmpdepfile"
166 ;; 245 ;;
167 246
168 hp) 247 hp)
169 # This case exists only to let depend.m4 do its work. It works by 248 # This case exists only to let depend.m4 do its work. It works by
170 # looking at the text of this script. This case will never be run, 249 # looking at the text of this script. This case will never be run,
171 # since it is checked for above. 250 # since it is checked for above.
172 exit 1 251 exit 1
173 ;; 252 ;;
174 253
175 sgi) 254 xlc)
176 if test "$libtool" = yes; then 255 # This case exists only to let depend.m4 do its work. It works by
177 "$@" "-Wp,-MDupdate,$tmpdepfile" 256 # looking at the text of this script. This case will never be run,
178 else 257 # since it is checked for above.
179 "$@" -MDupdate "$tmpdepfile" 258 exit 1
180 fi
181 stat=$?
182 if test $stat -eq 0; then :
183 else
184 rm -f "$tmpdepfile"
185 exit $stat
186 fi
187 rm -f "$depfile"
188
189 if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
190 echo "$object : \\" > "$depfile"
191
192 # Clip off the initial element (the dependent). Don't try to be
193 # clever and replace this with sed code, as IRIX sed won't handle
194 # lines with more than a fixed number of characters (4096 in
195 # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
196 # the IRIX cc adds comments like `#:fec' to the end of the
197 # dependency line.
198 tr ' ' '
199 ' < "$tmpdepfile" \
200 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
201 tr '
202 ' ' ' >> "$depfile"
203 echo >> "$depfile"
204
205 # The second pass generates a dummy entry for each header file.
206 tr ' ' '
207 ' < "$tmpdepfile" \
208 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
209 >> "$depfile"
210 else
211 # The sourcefile does not contain any dependencies, so just
212 # store a dummy comment line, to avoid errors with the Makefile
213 # "include basename.Plo" scheme.
214 echo "#dummy" > "$depfile"
215 fi
216 rm -f "$tmpdepfile"
217 ;; 259 ;;
218 260
219 aix) 261 aix)
220 # The C for AIX Compiler uses -M and outputs the dependencies 262 # The C for AIX Compiler uses -M and outputs the dependencies
221 # in a .u file. In older versions, this file always lives in the 263 # in a .u file. In older versions, this file always lives in the
222 # current directory. Also, the AIX compiler puts `$object:' at the 264 # current directory. Also, the AIX compiler puts '$object:' at the
223 # start of each line; $object doesn't have directory information. 265 # start of each line; $object doesn't have directory information.
224 # Version 6 uses the directory in both cases. 266 # Version 6 uses the directory in both cases.
225 dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 267 set_dir_from "$object"
226 test "x$dir" = "x$object" && dir= 268 set_base_from "$object"
227 base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
228 if test "$libtool" = yes; then 269 if test "$libtool" = yes; then
229 tmpdepfile1=$dir$base.u 270 tmpdepfile1=$dir$base.u
230 tmpdepfile2=$base.u 271 tmpdepfile2=$base.u
231 tmpdepfile3=$dir.libs/$base.u 272 tmpdepfile3=$dir.libs/$base.u
232 "$@" -Wc,-M 273 "$@" -Wc,-M
235 tmpdepfile2=$dir$base.u 276 tmpdepfile2=$dir$base.u
236 tmpdepfile3=$dir$base.u 277 tmpdepfile3=$dir$base.u
237 "$@" -M 278 "$@" -M
238 fi 279 fi
239 stat=$? 280 stat=$?
240 281 if test $stat -ne 0; then
241 if test $stat -eq 0; then :
242 else
243 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 282 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
244 exit $stat 283 exit $stat
245 fi 284 fi
246 285
247 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 286 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
248 do 287 do
249 test -f "$tmpdepfile" && break 288 test -f "$tmpdepfile" && break
250 done 289 done
251 if test -f "$tmpdepfile"; then 290 aix_post_process_depfile
252 # Each line is of the form `foo.o: dependent.h'. 291 ;;
253 # Do two passes, one to just change these to 292
254 # `$object: dependent.h' and one to simply `dependent.h:'. 293 tcc)
255 sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 294 # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
256 # That's a tab and a space in the []. 295 # FIXME: That version still under development at the moment of writing.
257 sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 296 # Make that this statement remains true also for stable, released
258 else 297 # versions.
259 # The sourcefile does not contain any dependencies, so just 298 # It will wrap lines (doesn't matter whether long or short) with a
260 # store a dummy comment line, to avoid errors with the Makefile 299 # trailing '\', as in:
261 # "include basename.Plo" scheme. 300 #
262 echo "#dummy" > "$depfile" 301 # foo.o : \
263 fi 302 # foo.c \
303 # foo.h \
304 #
305 # It will put a trailing '\' even on the last line, and will use leading
306 # spaces rather than leading tabs (at least since its commit 0394caf7
307 # "Emit spaces for -MD").
308 "$@" -MD -MF "$tmpdepfile"
309 stat=$?
310 if test $stat -ne 0; then
311 rm -f "$tmpdepfile"
312 exit $stat
313 fi
314 rm -f "$depfile"
315 # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
316 # We have to change lines of the first kind to '$object: \'.
317 sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
318 # And for each line of the second kind, we have to emit a 'dep.h:'
319 # dummy dependency, to avoid the deleted-header problem.
320 sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
264 rm -f "$tmpdepfile" 321 rm -f "$tmpdepfile"
265 ;; 322 ;;
266 323
267 icc) 324 ## The order of this option in the case statement is important, since the
268 # Intel's C compiler understands `-MD -MF file'. However on 325 ## shell code in configure will try each of these formats in the order
269 # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 326 ## listed in this file. A plain '-MD' option would be understood by many
270 # ICC 7.0 will fill foo.d with something like 327 ## compilers, so we must ensure this comes after the gcc and icc options.
271 # foo.o: sub/foo.c 328 pgcc)
272 # foo.o: sub/foo.h 329 # Portland's C compiler understands '-MD'.
273 # which is wrong. We want: 330 # Will always output deps to 'file.d' where file is the root name of the
274 # sub/foo.o: sub/foo.c 331 # source file under compilation, even if file resides in a subdirectory.
275 # sub/foo.o: sub/foo.h 332 # The object file name does not affect the name of the '.d' file.
276 # sub/foo.c: 333 # pgcc 10.2 will output
277 # sub/foo.h:
278 # ICC 7.1 will output
279 # foo.o: sub/foo.c sub/foo.h 334 # foo.o: sub/foo.c sub/foo.h
280 # and will wrap long lines using \ : 335 # and will wrap long lines using '\' :
281 # foo.o: sub/foo.c ... \ 336 # foo.o: sub/foo.c ... \
282 # sub/foo.h ... \ 337 # sub/foo.h ... \
283 # ... 338 # ...
284 339 set_dir_from "$object"
285 "$@" -MD -MF "$tmpdepfile" 340 # Use the source, not the object, to determine the base name, since
286 stat=$? 341 # that's sadly what pgcc will do too.
287 if test $stat -eq 0; then : 342 set_base_from "$source"
288 else 343 tmpdepfile=$base.d
344
345 # For projects that build the same source file twice into different object
346 # files, the pgcc approach of using the *source* file root name can cause
347 # problems in parallel builds. Use a locking strategy to avoid stomping on
348 # the same $tmpdepfile.
349 lockdir=$base.d-lock
350 trap "
351 echo '$0: caught signal, cleaning up...' >&2
352 rmdir '$lockdir'
353 exit 1
354 " 1 2 13 15
355 numtries=100
356 i=$numtries
357 while test $i -gt 0; do
358 # mkdir is a portable test-and-set.
359 if mkdir "$lockdir" 2>/dev/null; then
360 # This process acquired the lock.
361 "$@" -MD
362 stat=$?
363 # Release the lock.
364 rmdir "$lockdir"
365 break
366 else
367 # If the lock is being held by a different process, wait
368 # until the winning process is done or we timeout.
369 while test -d "$lockdir" && test $i -gt 0; do
370 sleep 1
371 i=`expr $i - 1`
372 done
373 fi
374 i=`expr $i - 1`
375 done
376 trap - 1 2 13 15
377 if test $i -le 0; then
378 echo "$0: failed to acquire lock after $numtries attempts" >&2
379 echo "$0: check lockdir '$lockdir'" >&2
380 exit 1
381 fi
382
383 if test $stat -ne 0; then
289 rm -f "$tmpdepfile" 384 rm -f "$tmpdepfile"
290 exit $stat 385 exit $stat
291 fi 386 fi
292 rm -f "$depfile" 387 rm -f "$depfile"
293 # Each line is of the form `foo.o: dependent.h', 388 # Each line is of the form `foo.o: dependent.h',
295 # Do two passes, one to just change these to 390 # Do two passes, one to just change these to
296 # `$object: dependent.h' and one to simply `dependent.h:'. 391 # `$object: dependent.h' and one to simply `dependent.h:'.
297 sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 392 sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
298 # Some versions of the HPUX 10.20 sed can't process this invocation 393 # Some versions of the HPUX 10.20 sed can't process this invocation
299 # correctly. Breaking it into two sed invocations is a workaround. 394 # correctly. Breaking it into two sed invocations is a workaround.
300 sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 395 sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
301 sed -e 's/$/ :/' >> "$depfile" 396 | sed -e 's/$/ :/' >> "$depfile"
302 rm -f "$tmpdepfile" 397 rm -f "$tmpdepfile"
303 ;; 398 ;;
304 399
305 hp2) 400 hp2)
306 # The "hp" stanza above does not work with aCC (C++) and HP's ia64 401 # The "hp" stanza above does not work with aCC (C++) and HP's ia64
307 # compilers, which have integrated preprocessors. The correct option 402 # compilers, which have integrated preprocessors. The correct option
308 # to use with these is +Maked; it writes dependencies to a file named 403 # to use with these is +Maked; it writes dependencies to a file named
309 # 'foo.d', which lands next to the object file, wherever that 404 # 'foo.d', which lands next to the object file, wherever that
310 # happens to be. 405 # happens to be.
311 # Much of this is similar to the tru64 case; see comments there. 406 # Much of this is similar to the tru64 case; see comments there.
312 dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 407 set_dir_from "$object"
313 test "x$dir" = "x$object" && dir= 408 set_base_from "$object"
314 base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
315 if test "$libtool" = yes; then 409 if test "$libtool" = yes; then
316 tmpdepfile1=$dir$base.d 410 tmpdepfile1=$dir$base.d
317 tmpdepfile2=$dir.libs/$base.d 411 tmpdepfile2=$dir.libs/$base.d
318 "$@" -Wc,+Maked 412 "$@" -Wc,+Maked
319 else 413 else
320 tmpdepfile1=$dir$base.d 414 tmpdepfile1=$dir$base.d
321 tmpdepfile2=$dir$base.d 415 tmpdepfile2=$dir$base.d
322 "$@" +Maked 416 "$@" +Maked
323 fi 417 fi
324 stat=$? 418 stat=$?
325 if test $stat -eq 0; then : 419 if test $stat -ne 0; then
326 else
327 rm -f "$tmpdepfile1" "$tmpdepfile2" 420 rm -f "$tmpdepfile1" "$tmpdepfile2"
328 exit $stat 421 exit $stat
329 fi 422 fi
330 423
331 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 424 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
332 do 425 do
333 test -f "$tmpdepfile" && break 426 test -f "$tmpdepfile" && break
334 done 427 done
335 if test -f "$tmpdepfile"; then 428 if test -f "$tmpdepfile"; then
336 sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 429 sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
337 # Add `dependent.h:' lines. 430 # Add 'dependent.h:' lines.
338 sed -ne '2,${ 431 sed -ne '2,${
339 s/^ *// 432 s/^ *//
340 s/ \\*$// 433 s/ \\*$//
341 s/$/:/ 434 s/$/:/
342 p 435 p
343 }' "$tmpdepfile" >> "$depfile" 436 }' "$tmpdepfile" >> "$depfile"
344 else 437 else
345 echo "#dummy" > "$depfile" 438 make_dummy_depfile
346 fi 439 fi
347 rm -f "$tmpdepfile" "$tmpdepfile2" 440 rm -f "$tmpdepfile" "$tmpdepfile2"
348 ;; 441 ;;
349 442
350 tru64) 443 tru64)
351 # The Tru64 compiler uses -MD to generate dependencies as a side 444 # The Tru64 compiler uses -MD to generate dependencies as a side
352 # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 445 # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
353 # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 446 # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
354 # dependencies in `foo.d' instead, so we check for that too. 447 # dependencies in 'foo.d' instead, so we check for that too.
355 # Subdirectories are respected. 448 # Subdirectories are respected.
356 dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 449 set_dir_from "$object"
357 test "x$dir" = "x$object" && dir= 450 set_base_from "$object"
358 base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 451
359 452 if test "$libtool" = yes; then
360 if test "$libtool" = yes; then 453 # Libtool generates 2 separate objects for the 2 libraries. These
361 # With Tru64 cc, shared objects can also be used to make a 454 # two compilations output dependencies in $dir.libs/$base.o.d and
362 # static library. This mechanism is used in libtool 1.4 series to 455 # in $dir$base.o.d. We have to check for both files, because
363 # handle both shared and static libraries in a single compilation. 456 # one of the two compilations can be disabled. We should prefer
364 # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 457 # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
365 # 458 # automatically cleaned when .libs/ is deleted, while ignoring
366 # With libtool 1.5 this exception was removed, and libtool now 459 # the former would cause a distcleancheck panic.
367 # generates 2 separate objects for the 2 libraries. These two 460 tmpdepfile1=$dir$base.o.d # libtool 1.5
368 # compilations output dependencies in $dir.libs/$base.o.d and 461 tmpdepfile2=$dir.libs/$base.o.d # Likewise.
369 # in $dir$base.o.d. We have to check for both files, because 462 tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
370 # one of the two compilations can be disabled. We should prefer 463 "$@" -Wc,-MD
371 # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 464 else
372 # automatically cleaned when .libs/ is deleted, while ignoring 465 tmpdepfile1=$dir$base.d
373 # the former would cause a distcleancheck panic. 466 tmpdepfile2=$dir$base.d
374 tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 467 tmpdepfile3=$dir$base.d
375 tmpdepfile2=$dir$base.o.d # libtool 1.5 468 "$@" -MD
376 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 469 fi
377 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 470
378 "$@" -Wc,-MD 471 stat=$?
379 else 472 if test $stat -ne 0; then
380 tmpdepfile1=$dir$base.o.d 473 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
381 tmpdepfile2=$dir$base.d 474 exit $stat
382 tmpdepfile3=$dir$base.d 475 fi
383 tmpdepfile4=$dir$base.d 476
384 "$@" -MD 477 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
385 fi 478 do
386 479 test -f "$tmpdepfile" && break
387 stat=$? 480 done
388 if test $stat -eq 0; then : 481 # Same post-processing that is required for AIX mode.
389 else 482 aix_post_process_depfile
390 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 483 ;;
391 exit $stat 484
392 fi 485 msvc7)
393 486 if test "$libtool" = yes; then
394 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 487 showIncludes=-Wc,-showIncludes
395 do 488 else
396 test -f "$tmpdepfile" && break 489 showIncludes=-showIncludes
397 done 490 fi
398 if test -f "$tmpdepfile"; then 491 "$@" $showIncludes > "$tmpdepfile"
399 sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 492 stat=$?
400 # That's a tab and a space in the []. 493 grep -v '^Note: including file: ' "$tmpdepfile"
401 sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 494 if test $stat -ne 0; then
402 else 495 rm -f "$tmpdepfile"
403 echo "#dummy" > "$depfile" 496 exit $stat
404 fi 497 fi
405 rm -f "$tmpdepfile" 498 rm -f "$depfile"
406 ;; 499 echo "$object : \\" > "$depfile"
500 # The first sed program below extracts the file names and escapes
501 # backslashes for cygpath. The second sed program outputs the file
502 # name when reading, but also accumulates all include files in the
503 # hold buffer in order to output them again at the end. This only
504 # works with sed implementations that can handle large buffers.
505 sed < "$tmpdepfile" -n '
506 /^Note: including file: *\(.*\)/ {
507 s//\1/
508 s/\\/\\\\/g
509 p
510 }' | $cygpath_u | sort -u | sed -n '
511 s/ /\\ /g
512 s/\(.*\)/'"$tab"'\1 \\/p
513 s/.\(.*\) \\/\1:/
514 H
515 $ {
516 s/.*/'"$tab"'/
517 G
518 p
519 }' >> "$depfile"
520 echo >> "$depfile" # make sure the fragment doesn't end with a backslash
521 rm -f "$tmpdepfile"
522 ;;
523
524 msvc7msys)
525 # This case exists only to let depend.m4 do its work. It works by
526 # looking at the text of this script. This case will never be run,
527 # since it is checked for above.
528 exit 1
529 ;;
407 530
408 #nosideeffect) 531 #nosideeffect)
409 # This comment above is used by automake to tell side-effect 532 # This comment above is used by automake to tell side-effect
410 # dependency tracking mechanisms from slower ones. 533 # dependency tracking mechanisms from slower ones.
411 534
420 shift 543 shift
421 done 544 done
422 shift 545 shift
423 fi 546 fi
424 547
425 # Remove `-o $object'. 548 # Remove '-o $object'.
426 IFS=" " 549 IFS=" "
427 for arg 550 for arg
428 do 551 do
429 case $arg in 552 case $arg in
430 -o) 553 -o)
440 ;; 563 ;;
441 esac 564 esac
442 done 565 done
443 566
444 test -z "$dashmflag" && dashmflag=-M 567 test -z "$dashmflag" && dashmflag=-M
445 # Require at least two characters before searching for `:' 568 # Require at least two characters before searching for ':'
446 # in the target name. This is to cope with DOS-style filenames: 569 # in the target name. This is to cope with DOS-style filenames:
447 # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 570 # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
448 "$@" $dashmflag | 571 "$@" $dashmflag |
449 sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 572 sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
450 rm -f "$depfile" 573 rm -f "$depfile"
451 cat < "$tmpdepfile" > "$depfile" 574 cat < "$tmpdepfile" > "$depfile"
452 tr ' ' ' 575 # Some versions of the HPUX 10.20 sed can't process this sed invocation
453 ' < "$tmpdepfile" | \ 576 # correctly. Breaking it into two sed invocations is a workaround.
454 ## Some versions of the HPUX 10.20 sed can't process this invocation 577 tr ' ' "$nl" < "$tmpdepfile" \
455 ## correctly. Breaking it into two sed invocations is a workaround. 578 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
456 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 579 | sed -e 's/$/ :/' >> "$depfile"
457 rm -f "$tmpdepfile" 580 rm -f "$tmpdepfile"
458 ;; 581 ;;
459 582
460 dashXmstdout) 583 dashXmstdout)
461 # This case only exists to satisfy depend.m4. It is never actually 584 # This case only exists to satisfy depend.m4. It is never actually
501 done 624 done
502 obj_suffix=`echo "$object" | sed 's/^.*\././'` 625 obj_suffix=`echo "$object" | sed 's/^.*\././'`
503 touch "$tmpdepfile" 626 touch "$tmpdepfile"
504 ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 627 ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
505 rm -f "$depfile" 628 rm -f "$depfile"
506 cat < "$tmpdepfile" > "$depfile" 629 # makedepend may prepend the VPATH from the source file name to the object.
507 sed '1,2d' "$tmpdepfile" | tr ' ' ' 630 # No need to regex-escape $object, excess matching of '.' is harmless.
508 ' | \ 631 sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
509 ## Some versions of the HPUX 10.20 sed can't process this invocation 632 # Some versions of the HPUX 10.20 sed can't process the last invocation
510 ## correctly. Breaking it into two sed invocations is a workaround. 633 # correctly. Breaking it into two sed invocations is a workaround.
511 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 634 sed '1,2d' "$tmpdepfile" \
635 | tr ' ' "$nl" \
636 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
637 | sed -e 's/$/ :/' >> "$depfile"
512 rm -f "$tmpdepfile" "$tmpdepfile".bak 638 rm -f "$tmpdepfile" "$tmpdepfile".bak
513 ;; 639 ;;
514 640
515 cpp) 641 cpp)
516 # Important note: in order to support this mode, a compiler *must* 642 # Important note: in order to support this mode, a compiler *must*
523 shift 649 shift
524 done 650 done
525 shift 651 shift
526 fi 652 fi
527 653
528 # Remove `-o $object'. 654 # Remove '-o $object'.
529 IFS=" " 655 IFS=" "
530 for arg 656 for arg
531 do 657 do
532 case $arg in 658 case $arg in
533 -o) 659 -o)
542 shift # $arg 668 shift # $arg
543 ;; 669 ;;
544 esac 670 esac
545 done 671 done
546 672
547 "$@" -E | 673 "$@" -E \
548 sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 674 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
549 -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 675 -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
550 sed '$ s: \\$::' > "$tmpdepfile" 676 | sed '$ s: \\$::' > "$tmpdepfile"
551 rm -f "$depfile" 677 rm -f "$depfile"
552 echo "$object : \\" > "$depfile" 678 echo "$object : \\" > "$depfile"
553 cat < "$tmpdepfile" >> "$depfile" 679 cat < "$tmpdepfile" >> "$depfile"
554 sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 680 sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
555 rm -f "$tmpdepfile" 681 rm -f "$tmpdepfile"
577 ;; 703 ;;
578 $object) 704 $object)
579 shift 705 shift
580 ;; 706 ;;
581 "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 707 "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
582 set fnord "$@" 708 set fnord "$@"
583 shift 709 shift
584 shift 710 shift
585 ;; 711 ;;
586 *) 712 *)
587 set fnord "$@" "$arg" 713 set fnord "$@" "$arg"
588 shift 714 shift
589 shift 715 shift
590 ;; 716 ;;
591 esac 717 esac
592 done 718 done
593 "$@" -E 2>/dev/null | 719 "$@" -E 2>/dev/null |
594 sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 720 sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
595 rm -f "$depfile" 721 rm -f "$depfile"
596 echo "$object : \\" > "$depfile" 722 echo "$object : \\" > "$depfile"
597 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 723 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
598 echo " " >> "$depfile" 724 echo "$tab" >> "$depfile"
599 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 725 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
600 rm -f "$tmpdepfile" 726 rm -f "$tmpdepfile"
601 ;; 727 ;;
602 728
603 msvcmsys) 729 msvcmsys)