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