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