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