Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: bison/src/bison/2.4.1/bison-2.4.1-src/build-aux/depcomp

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

Powered by Google App Engine
This is Rietveld 408576698