source: FTPfs/sshfs-fuse-1.9/depcomp @ 104

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