ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.0.x/depcomp
(Generate patch)

Comparing:
ircd-hybrid-7.2/depcomp (file contents), Revision 945 by michael, Mon Jul 20 15:48:27 2009 UTC vs.
ircd-hybrid/branches/8.0.x/depcomp (file contents), Revision 1673 by michael, Wed Nov 21 20:29:18 2012 UTC

# Line 1 | Line 1
1   #! /bin/sh
2   # depcomp - compile a program generating dependencies as side-effects
3  
4 < scriptversion=2009-04-28.21; # UTC
4 > scriptversion=2012-07-12.20; # UTC
5  
6 < # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
7 < # Software Foundation, Inc.
6 > # Copyright (C) 1999-2012 Free Software Foundation, Inc.
7  
8   # This program is free software; you can redistribute it and/or modify
9   # it under the terms of the GNU General Public License as published by
# Line 28 | Line 27 | scriptversion=2009-04-28.21; # UTC
27  
28   case $1 in
29    '')
30 <     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
31       exit 1;
32       ;;
33    -h | --h*)
# Line 40 | Line 39 | as side-effects.
39  
40   Environment variables:
41    depmode     Dependency tracking mode.
42 <  source      Source file read by `PROGRAMS ARGS'.
43 <  object      Object file output by `PROGRAMS ARGS'.
42 >  source      Source file read by 'PROGRAMS ARGS'.
43 >  object      Object file output by 'PROGRAMS ARGS'.
44    DEPDIR      directory where to store dependencies.
45    depfile     Dependency file to output.
46 <  tmpdepfile  Temporary file to use when outputing dependencies.
46 >  tmpdepfile  Temporary file to use when outputting dependencies.
47    libtool     Whether libtool is used (yes/no).
48  
49   Report bugs to <bug-automake@gnu.org>.
# Line 57 | Line 56 | EOF
56      ;;
57   esac
58  
59 + # A tabulation character.
60 + tab='   '
61 + # A newline character.
62 + nl='
63 + '
64 +
65   if test -z "$depmode" || test -z "$source" || test -z "$object"; then
66    echo "depcomp: Variables source, object and depmode must be set" 1>&2
67    exit 1
# Line 69 | Line 74 | tmpdepfile=${tmpdepfile-`echo "$depfile"
74  
75   rm -f "$tmpdepfile"
76  
77 + # Avoid interferences from the environment.
78 + gccflag= dashmflag=
79 +
80   # Some modes work just like other modes, but use different flags.  We
81   # parameterize here, but still list the modes in the big case below,
82   # to make depend.m4 easier to write.  Note that we *cannot* use a case
# Line 90 | Line 98 | if test "$depmode" = msvcmsys; then
98     # This is just like msvisualcpp but w/o cygpath translation.
99     # Just convert the backslash-escaped backslashes to single forward
100     # slashes to satisfy depend.m4
101 <   cygpath_u="sed s,\\\\\\\\,/,g"
101 >   cygpath_u='sed s,\\\\,/,g'
102     depmode=msvisualcpp
103   fi
104  
105 + if test "$depmode" = msvc7msys; then
106 +   # This is just like msvc7 but w/o cygpath translation.
107 +   # Just convert the backslash-escaped backslashes to single forward
108 +   # slashes to satisfy depend.m4
109 +   cygpath_u='sed s,\\\\,/,g'
110 +   depmode=msvc7
111 + fi
112 +
113 + if test "$depmode" = xlc; then
114 +   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
115 +   gccflag=-qmakedep=gcc,-MF
116 +   depmode=gcc
117 + fi
118 +
119   case "$depmode" in
120   gcc3)
121   ## gcc 3 implements dependency tracking that does exactly what
# Line 123 | Line 145 | gcc3)
145    ;;
146  
147   gcc)
148 + ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
149 + ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
150 + ## (see the conditional assignment to $gccflag above).
151   ## There are various ways to get dependency output from gcc.  Here's
152   ## why we pick this rather obscure method:
153   ## - Don't want to use -MD because we'd like the dependencies to end
154   ##   up in a subdir.  Having to rename by hand is ugly.
155   ##   (We might end up doing this anyway to support other compilers.)
156   ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
157 < ##   -MM, not -M (despite what the docs say).
157 > ##   -MM, not -M (despite what the docs say).  Also, it might not be
158 > ##   supported by the other compilers which use the 'gcc' depmode.
159   ## - Using -M directly means running the compiler twice (even worse
160   ##   than renaming).
161    if test -z "$gccflag"; then
# Line 148 | Line 174 | gcc)
174   ## The second -e expression handles DOS-style file names with drive letters.
175    sed -e 's/^[^:]*: / /' \
176        -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
177 < ## This next piece of magic avoids the `deleted header file' problem.
177 > ## This next piece of magic avoids the "deleted header file" problem.
178   ## The problem is that when a header file which appears in a .P file
179   ## is deleted, the dependency causes make to die (because there is
180   ## typically no way to rebuild the header).  We avoid this by adding
181   ## dummy dependencies for each header file.  Too bad gcc doesn't do
182   ## this for us directly.
183 <  tr ' ' '
184 < ' < "$tmpdepfile" |
159 < ## Some versions of gcc put a space before the `:'.  On the theory
183 >  tr ' ' "$nl" < "$tmpdepfile" |
184 > ## Some versions of gcc put a space before the ':'.  On the theory
185   ## that the space means something, we add a space to the output as
186 < ## well.
186 > ## well.  hp depmode also adds that space, but also prefixes the VPATH
187 > ## to the object.  Take care to not repeat it in the output.
188   ## Some versions of the HPUX 10.20 sed can't process this invocation
189   ## correctly.  Breaking it into two sed invocations is a workaround.
190 <    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
190 >    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
191 >      | sed -e 's/$/ :/' >> "$depfile"
192    rm -f "$tmpdepfile"
193    ;;
194  
# Line 193 | Line 220 | sgi)
220      # clever and replace this with sed code, as IRIX sed won't handle
221      # lines with more than a fixed number of characters (4096 in
222      # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
223 <    # the IRIX cc adds comments like `#:fec' to the end of the
223 >    # the IRIX cc adds comments like '#:fec' to the end of the
224      # dependency line.
225 <    tr ' ' '
199 < ' < "$tmpdepfile" \
225 >    tr ' ' "$nl" < "$tmpdepfile" \
226      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
227 <    tr '
202 < ' ' ' >> "$depfile"
227 >    tr "$nl" ' ' >> "$depfile"
228      echo >> "$depfile"
229  
230      # The second pass generates a dummy entry for each header file.
231 <    tr ' ' '
207 < ' < "$tmpdepfile" \
231 >    tr ' ' "$nl" < "$tmpdepfile" \
232     | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
233     >> "$depfile"
234    else
# Line 216 | Line 240 | sgi)
240    rm -f "$tmpdepfile"
241    ;;
242  
243 + xlc)
244 +  # This case exists only to let depend.m4 do its work.  It works by
245 +  # looking at the text of this script.  This case will never be run,
246 +  # since it is checked for above.
247 +  exit 1
248 +  ;;
249 +
250   aix)
251    # The C for AIX Compiler uses -M and outputs the dependencies
252    # in a .u file.  In older versions, this file always lives in the
253 <  # current directory.  Also, the AIX compiler puts `$object:' at the
253 >  # current directory.  Also, the AIX compiler puts '$object:' at the
254    # start of each line; $object doesn't have directory information.
255    # Version 6 uses the directory in both cases.
256    dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
# Line 249 | Line 280 | aix)
280      test -f "$tmpdepfile" && break
281    done
282    if test -f "$tmpdepfile"; then
283 <    # Each line is of the form `foo.o: dependent.h'.
283 >    # Each line is of the form 'foo.o: dependent.h'.
284      # Do two passes, one to just change these to
285 <    # `$object: dependent.h' and one to simply `dependent.h:'.
285 >    # '$object: dependent.h' and one to simply 'dependent.h:'.
286      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
287 <    # That's a tab and a space in the [].
257 <    sed -e 's,^.*\.[a-z]*:[      ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
287 >    sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
288    else
289      # The sourcefile does not contain any dependencies, so just
290      # store a dummy comment line, to avoid errors with the Makefile
# Line 265 | Line 295 | aix)
295    ;;
296  
297   icc)
298 <  # Intel's C compiler understands `-MD -MF file'.  However on
299 <  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
298 >  # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
299 >  # However on
300 >  #    $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
301    # ICC 7.0 will fill foo.d with something like
302    #    foo.o: sub/foo.c
303    #    foo.o: sub/foo.h
304 <  # which is wrong.  We want:
304 >  # which is wrong.  We want
305    #    sub/foo.o: sub/foo.c
306    #    sub/foo.o: sub/foo.h
307    #    sub/foo.c:
308    #    sub/foo.h:
309    # ICC 7.1 will output
310    #    foo.o: sub/foo.c sub/foo.h
311 <  # and will wrap long lines using \ :
311 >  # and will wrap long lines using '\':
312    #    foo.o: sub/foo.c ... \
313    #     sub/foo.h ... \
314    #     ...
315 <
315 >  # tcc 0.9.26 (FIXME still under development at the moment of writing)
316 >  # will emit a similar output, but also prepend the continuation lines
317 >  # with horizontal tabulation characters.
318    "$@" -MD -MF "$tmpdepfile"
319    stat=$?
320    if test $stat -eq 0; then :
# Line 290 | Line 323 | icc)
323      exit $stat
324    fi
325    rm -f "$depfile"
326 +  # Each line is of the form 'foo.o: dependent.h',
327 +  # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
328 +  # Do two passes, one to just change these to
329 +  # '$object: dependent.h' and one to simply 'dependent.h:'.
330 +  sed -e "s/^[ $tab][ $tab]*/  /" -e "s,^[^:]*:,$object :," \
331 +    < "$tmpdepfile" > "$depfile"
332 +  sed '
333 +    s/[ '"$tab"'][ '"$tab"']*/ /g
334 +    s/^ *//
335 +    s/ *\\*$//
336 +    s/^[^:]*: *//
337 +    /^$/d
338 +    /:$/d
339 +    s/$/ :/
340 +  ' < "$tmpdepfile" >> "$depfile"
341 +  rm -f "$tmpdepfile"
342 +  ;;
343 +
344 + ## The order of this option in the case statement is important, since the
345 + ## shell code in configure will try each of these formats in the order
346 + ## listed in this file.  A plain '-MD' option would be understood by many
347 + ## compilers, so we must ensure this comes after the gcc and icc options.
348 + pgcc)
349 +  # Portland's C compiler understands '-MD'.
350 +  # Will always output deps to 'file.d' where file is the root name of the
351 +  # source file under compilation, even if file resides in a subdirectory.
352 +  # The object file name does not affect the name of the '.d' file.
353 +  # pgcc 10.2 will output
354 +  #    foo.o: sub/foo.c sub/foo.h
355 +  # and will wrap long lines using '\' :
356 +  #    foo.o: sub/foo.c ... \
357 +  #     sub/foo.h ... \
358 +  #     ...
359 +  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
360 +  test "x$dir" = "x$object" && dir=
361 +  # Use the source, not the object, to determine the base name, since
362 +  # that's sadly what pgcc will do too.
363 +  base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'`
364 +  tmpdepfile="$base.d"
365 +
366 +  # For projects that build the same source file twice into different object
367 +  # files, the pgcc approach of using the *source* file root name can cause
368 +  # problems in parallel builds.  Use a locking strategy to avoid stomping on
369 +  # the same $tmpdepfile.
370 +  lockdir="$base.d-lock"
371 +  trap "echo '$0: caught signal, cleaning up...' >&2; rm -rf $lockdir" 1 2 13 15
372 +  numtries=100
373 +  i=$numtries
374 +  while test $i -gt 0 ; do
375 +    # mkdir is a portable test-and-set.
376 +    if mkdir $lockdir 2>/dev/null; then
377 +      # This process acquired the lock.
378 +      "$@" -MD
379 +      stat=$?
380 +      # Release the lock.
381 +      rm -rf $lockdir
382 +      break
383 +    else
384 +      ## the lock is being held by a different process,
385 +      ## wait until the winning process is done or we timeout
386 +      while test -d $lockdir && test $i -gt 0; do
387 +        sleep 1
388 +        i=`expr $i - 1`
389 +      done
390 +    fi
391 +    i=`expr $i - 1`
392 +  done
393 +  trap - 1 2 13 15
394 +  if test $i -le 0; then
395 +    echo "$0: failed to acquire lock after $numtries attempts" >&2
396 +    echo "$0: check lockdir '$lockdir'" >&2
397 +    exit 1
398 +  fi
399 +
400 +  if test $stat -ne 0; then
401 +    rm -f "$tmpdepfile"
402 +    exit $stat
403 +  fi
404 +  rm -f "$depfile"
405    # Each line is of the form `foo.o: dependent.h',
406    # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
407    # Do two passes, one to just change these to
# Line 334 | Line 446 | hp2)
446    done
447    if test -f "$tmpdepfile"; then
448      sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
449 <    # Add `dependent.h:' lines.
449 >    # Add 'dependent.h:' lines.
450      sed -ne '2,${
451                 s/^ *//
452                 s/ \\*$//
# Line 349 | Line 461 | hp2)
461  
462   tru64)
463     # The Tru64 compiler uses -MD to generate dependencies as a side
464 <   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
464 >   # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
465     # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
466 <   # dependencies in `foo.d' instead, so we check for that too.
466 >   # dependencies in 'foo.d' instead, so we check for that too.
467     # Subdirectories are respected.
468     dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
469     test "x$dir" = "x$object" && dir=
# Line 397 | Line 509 | tru64)
509     done
510     if test -f "$tmpdepfile"; then
511        sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
512 <      # That's a tab and a space in the [].
401 <      sed -e 's,^.*\.[a-z]*:[    ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
512 >      sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
513     else
514        echo "#dummy" > "$depfile"
515     fi
516     rm -f "$tmpdepfile"
517     ;;
518  
519 + msvc7)
520 +  if test "$libtool" = yes; then
521 +    showIncludes=-Wc,-showIncludes
522 +  else
523 +    showIncludes=-showIncludes
524 +  fi
525 +  "$@" $showIncludes > "$tmpdepfile"
526 +  stat=$?
527 +  grep -v '^Note: including file: ' "$tmpdepfile"
528 +  if test "$stat" = 0; then :
529 +  else
530 +    rm -f "$tmpdepfile"
531 +    exit $stat
532 +  fi
533 +  rm -f "$depfile"
534 +  echo "$object : \\" > "$depfile"
535 +  # The first sed program below extracts the file names and escapes
536 +  # backslashes for cygpath.  The second sed program outputs the file
537 +  # name when reading, but also accumulates all include files in the
538 +  # hold buffer in order to output them again at the end.  This only
539 +  # works with sed implementations that can handle large buffers.
540 +  sed < "$tmpdepfile" -n '
541 + /^Note: including file:  *\(.*\)/ {
542 +  s//\1/
543 +  s/\\/\\\\/g
544 +  p
545 + }' | $cygpath_u | sort -u | sed -n '
546 + s/ /\\ /g
547 + s/\(.*\)/'"$tab"'\1 \\/p
548 + s/.\(.*\) \\/\1:/
549 + H
550 + $ {
551 +  s/.*/'"$tab"'/
552 +  G
553 +  p
554 + }' >> "$depfile"
555 +  rm -f "$tmpdepfile"
556 +  ;;
557 +
558 + msvc7msys)
559 +  # This case exists only to let depend.m4 do its work.  It works by
560 +  # looking at the text of this script.  This case will never be run,
561 +  # since it is checked for above.
562 +  exit 1
563 +  ;;
564 +
565   #nosideeffect)
566    # This comment above is used by automake to tell side-effect
567    # dependency tracking mechanisms from slower ones.
# Line 422 | Line 579 | dashmstdout)
579      shift
580    fi
581  
582 <  # Remove `-o $object'.
582 >  # Remove '-o $object'.
583    IFS=" "
584    for arg
585    do
# Line 442 | Line 599 | dashmstdout)
599    done
600  
601    test -z "$dashmflag" && dashmflag=-M
602 <  # Require at least two characters before searching for `:'
602 >  # Require at least two characters before searching for ':'
603    # in the target name.  This is to cope with DOS-style filenames:
604 <  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
604 >  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
605    "$@" $dashmflag |
606 <    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
606 >    sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
607    rm -f "$depfile"
608    cat < "$tmpdepfile" > "$depfile"
609 <  tr ' ' '
453 < ' < "$tmpdepfile" | \
609 >  tr ' ' "$nl" < "$tmpdepfile" | \
610   ## Some versions of the HPUX 10.20 sed can't process this invocation
611   ## correctly.  Breaking it into two sed invocations is a workaround.
612      sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
# Line 503 | Line 659 | makedepend)
659    touch "$tmpdepfile"
660    ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
661    rm -f "$depfile"
662 <  cat < "$tmpdepfile" > "$depfile"
663 <  sed '1,2d' "$tmpdepfile" | tr ' ' '
664 < ' | \
662 >  # makedepend may prepend the VPATH from the source file name to the object.
663 >  # No need to regex-escape $object, excess matching of '.' is harmless.
664 >  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
665 >  sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
666   ## Some versions of the HPUX 10.20 sed can't process this invocation
667   ## correctly.  Breaking it into two sed invocations is a workaround.
668      sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
# Line 525 | Line 682 | cpp)
682      shift
683    fi
684  
685 <  # Remove `-o $object'.
685 >  # Remove '-o $object'.
686    IFS=" "
687    for arg
688    do
# Line 594 | Line 751 | msvisualcpp)
751    sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
752    rm -f "$depfile"
753    echo "$object : \\" > "$depfile"
754 <  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::      \1 \\:p' >> "$depfile"
755 <  echo "        " >> "$depfile"
754 >  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
755 >  echo "$tab" >> "$depfile"
756    sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
757    rm -f "$tmpdepfile"
758    ;;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)