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