1156283Srwatson#! /bin/sh 2156283Srwatson# depcomp - compile a program generating dependencies as side-effects 3156283Srwatson 4156283Srwatsonscriptversion=2005-07-09.11 5156283Srwatson 6156283Srwatson# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7156283Srwatson 8156283Srwatson# This program is free software; you can redistribute it and/or modify 9156283Srwatson# it under the terms of the GNU General Public License as published by 10156283Srwatson# the Free Software Foundation; either version 2, or (at your option) 11156283Srwatson# any later version. 12156283Srwatson 13156283Srwatson# This program is distributed in the hope that it will be useful, 14156283Srwatson# but WITHOUT ANY WARRANTY; without even the implied warranty of 15156283Srwatson# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16156283Srwatson# GNU General Public License for more details. 17156283Srwatson 18156283Srwatson# You should have received a copy of the GNU General Public License 19156283Srwatson# along with this program; if not, write to the Free Software 20156283Srwatson# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21156283Srwatson# 02110-1301, USA. 22156283Srwatson 23156283Srwatson# As a special exception to the GNU General Public License, if you 24156283Srwatson# distribute this file as part of a program that contains a 25156283Srwatson# configuration script generated by Autoconf, you may include it under 26156283Srwatson# the same distribution terms that you use for the rest of that program. 27156283Srwatson 28156283Srwatson# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 29156283Srwatson 30156283Srwatsoncase $1 in 31156283Srwatson '') 32156283Srwatson echo "$0: No command. Try \`$0 --help' for more information." 1>&2 33156283Srwatson exit 1; 34156283Srwatson ;; 35156283Srwatson -h | --h*) 36156283Srwatson cat <<\EOF 37156283SrwatsonUsage: depcomp [--help] [--version] PROGRAM [ARGS] 38156283Srwatson 39156283SrwatsonRun PROGRAMS ARGS to compile a file, generating dependencies 40156283Srwatsonas side-effects. 41156283Srwatson 42156283SrwatsonEnvironment variables: 43156283Srwatson depmode Dependency tracking mode. 44156283Srwatson source Source file read by `PROGRAMS ARGS'. 45156283Srwatson object Object file output by `PROGRAMS ARGS'. 46156283Srwatson DEPDIR directory where to store dependencies. 47156283Srwatson depfile Dependency file to output. 48156283Srwatson tmpdepfile Temporary file to use when outputing dependencies. 49156283Srwatson libtool Whether libtool is used (yes/no). 50156283Srwatson 51156283SrwatsonReport bugs to <bug-automake@gnu.org>. 52156283SrwatsonEOF 53156283Srwatson exit $? 54156283Srwatson ;; 55156283Srwatson -v | --v*) 56156283Srwatson echo "depcomp $scriptversion" 57156283Srwatson exit $? 58156283Srwatson ;; 59156283Srwatsonesac 60156283Srwatson 61156283Srwatsonif test -z "$depmode" || test -z "$source" || test -z "$object"; then 62156283Srwatson echo "depcomp: Variables source, object and depmode must be set" 1>&2 63156283Srwatson exit 1 64156283Srwatsonfi 65156283Srwatson 66156283Srwatson# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 67156283Srwatsondepfile=${depfile-`echo "$object" | 68156283Srwatson sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 69156283Srwatsontmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 70156283Srwatson 71156283Srwatsonrm -f "$tmpdepfile" 72156283Srwatson 73156283Srwatson# Some modes work just like other modes, but use different flags. We 74156283Srwatson# parameterize here, but still list the modes in the big case below, 75156283Srwatson# to make depend.m4 easier to write. Note that we *cannot* use a case 76156283Srwatson# here, because this file can only contain one case statement. 77156283Srwatsonif test "$depmode" = hp; then 78156283Srwatson # HP compiler uses -M and no extra arg. 79156283Srwatson gccflag=-M 80156283Srwatson depmode=gcc 81156283Srwatsonfi 82156283Srwatson 83156283Srwatsonif test "$depmode" = dashXmstdout; then 84156283Srwatson # This is just like dashmstdout with a different argument. 85156283Srwatson dashmflag=-xM 86156283Srwatson depmode=dashmstdout 87156283Srwatsonfi 88156283Srwatson 89156283Srwatsoncase "$depmode" in 90156283Srwatsongcc3) 91156283Srwatson## gcc 3 implements dependency tracking that does exactly what 92156283Srwatson## we want. Yay! Note: for some reason libtool 1.4 doesn't like 93156283Srwatson## it if -MD -MP comes after the -MF stuff. Hmm. 94156283Srwatson "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 95156283Srwatson stat=$? 96156283Srwatson if test $stat -eq 0; then : 97156283Srwatson else 98156283Srwatson rm -f "$tmpdepfile" 99156283Srwatson exit $stat 100156283Srwatson fi 101156283Srwatson mv "$tmpdepfile" "$depfile" 102156283Srwatson ;; 103156283Srwatson 104156283Srwatsongcc) 105156283Srwatson## There are various ways to get dependency output from gcc. Here's 106156283Srwatson## why we pick this rather obscure method: 107156283Srwatson## - Don't want to use -MD because we'd like the dependencies to end 108156283Srwatson## up in a subdir. Having to rename by hand is ugly. 109156283Srwatson## (We might end up doing this anyway to support other compilers.) 110156283Srwatson## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 111156283Srwatson## -MM, not -M (despite what the docs say). 112156283Srwatson## - Using -M directly means running the compiler twice (even worse 113156283Srwatson## than renaming). 114156283Srwatson if test -z "$gccflag"; then 115156283Srwatson gccflag=-MD, 116156283Srwatson fi 117156283Srwatson "$@" -Wp,"$gccflag$tmpdepfile" 118156283Srwatson stat=$? 119156283Srwatson if test $stat -eq 0; then : 120156283Srwatson else 121156283Srwatson rm -f "$tmpdepfile" 122156283Srwatson exit $stat 123156283Srwatson fi 124156283Srwatson rm -f "$depfile" 125156283Srwatson echo "$object : \\" > "$depfile" 126156283Srwatson alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 127156283Srwatson## The second -e expression handles DOS-style file names with drive letters. 128156283Srwatson sed -e 's/^[^:]*: / /' \ 129156283Srwatson -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 130156283Srwatson## This next piece of magic avoids the `deleted header file' problem. 131156283Srwatson## The problem is that when a header file which appears in a .P file 132156283Srwatson## is deleted, the dependency causes make to die (because there is 133156283Srwatson## typically no way to rebuild the header). We avoid this by adding 134156283Srwatson## dummy dependencies for each header file. Too bad gcc doesn't do 135156283Srwatson## this for us directly. 136156283Srwatson tr ' ' ' 137156283Srwatson' < "$tmpdepfile" | 138156283Srwatson## Some versions of gcc put a space before the `:'. On the theory 139156283Srwatson## that the space means something, we add a space to the output as 140156283Srwatson## well. 141156283Srwatson## Some versions of the HPUX 10.20 sed can't process this invocation 142156283Srwatson## correctly. Breaking it into two sed invocations is a workaround. 143156283Srwatson sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 144156283Srwatson rm -f "$tmpdepfile" 145156283Srwatson ;; 146156283Srwatson 147156283Srwatsonhp) 148156283Srwatson # This case exists only to let depend.m4 do its work. It works by 149156283Srwatson # looking at the text of this script. This case will never be run, 150156283Srwatson # since it is checked for above. 151156283Srwatson exit 1 152156283Srwatson ;; 153156283Srwatson 154156283Srwatsonsgi) 155156283Srwatson if test "$libtool" = yes; then 156156283Srwatson "$@" "-Wp,-MDupdate,$tmpdepfile" 157156283Srwatson else 158156283Srwatson "$@" -MDupdate "$tmpdepfile" 159156283Srwatson fi 160156283Srwatson stat=$? 161156283Srwatson if test $stat -eq 0; then : 162156283Srwatson else 163156283Srwatson rm -f "$tmpdepfile" 164156283Srwatson exit $stat 165156283Srwatson fi 166156283Srwatson rm -f "$depfile" 167156283Srwatson 168156283Srwatson if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 169156283Srwatson echo "$object : \\" > "$depfile" 170156283Srwatson 171156283Srwatson # Clip off the initial element (the dependent). Don't try to be 172156283Srwatson # clever and replace this with sed code, as IRIX sed won't handle 173156283Srwatson # lines with more than a fixed number of characters (4096 in 174156283Srwatson # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 175156283Srwatson # the IRIX cc adds comments like `#:fec' to the end of the 176156283Srwatson # dependency line. 177156283Srwatson tr ' ' ' 178156283Srwatson' < "$tmpdepfile" \ 179156283Srwatson | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 180156283Srwatson tr ' 181156283Srwatson' ' ' >> $depfile 182156283Srwatson echo >> $depfile 183156283Srwatson 184156283Srwatson # The second pass generates a dummy entry for each header file. 185156283Srwatson tr ' ' ' 186156283Srwatson' < "$tmpdepfile" \ 187156283Srwatson | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 188156283Srwatson >> $depfile 189156283Srwatson else 190156283Srwatson # The sourcefile does not contain any dependencies, so just 191156283Srwatson # store a dummy comment line, to avoid errors with the Makefile 192156283Srwatson # "include basename.Plo" scheme. 193156283Srwatson echo "#dummy" > "$depfile" 194156283Srwatson fi 195156283Srwatson rm -f "$tmpdepfile" 196156283Srwatson ;; 197156283Srwatson 198156283Srwatsonaix) 199156283Srwatson # The C for AIX Compiler uses -M and outputs the dependencies 200156283Srwatson # in a .u file. In older versions, this file always lives in the 201156283Srwatson # current directory. Also, the AIX compiler puts `$object:' at the 202156283Srwatson # start of each line; $object doesn't have directory information. 203156283Srwatson # Version 6 uses the directory in both cases. 204156283Srwatson stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 205156283Srwatson tmpdepfile="$stripped.u" 206156283Srwatson if test "$libtool" = yes; then 207156283Srwatson "$@" -Wc,-M 208156283Srwatson else 209156283Srwatson "$@" -M 210156283Srwatson fi 211156283Srwatson stat=$? 212156283Srwatson 213156283Srwatson if test -f "$tmpdepfile"; then : 214156283Srwatson else 215156283Srwatson stripped=`echo "$stripped" | sed 's,^.*/,,'` 216156283Srwatson tmpdepfile="$stripped.u" 217156283Srwatson fi 218156283Srwatson 219156283Srwatson if test $stat -eq 0; then : 220156283Srwatson else 221156283Srwatson rm -f "$tmpdepfile" 222156283Srwatson exit $stat 223156283Srwatson fi 224156283Srwatson 225156283Srwatson if test -f "$tmpdepfile"; then 226156283Srwatson outname="$stripped.o" 227156283Srwatson # Each line is of the form `foo.o: dependent.h'. 228156283Srwatson # Do two passes, one to just change these to 229156283Srwatson # `$object: dependent.h' and one to simply `dependent.h:'. 230156283Srwatson sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 231156283Srwatson sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 232156283Srwatson else 233156283Srwatson # The sourcefile does not contain any dependencies, so just 234156283Srwatson # store a dummy comment line, to avoid errors with the Makefile 235156283Srwatson # "include basename.Plo" scheme. 236156283Srwatson echo "#dummy" > "$depfile" 237156283Srwatson fi 238156283Srwatson rm -f "$tmpdepfile" 239156283Srwatson ;; 240156283Srwatson 241156283Srwatsonicc) 242156283Srwatson # Intel's C compiler understands `-MD -MF file'. However on 243156283Srwatson # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 244156283Srwatson # ICC 7.0 will fill foo.d with something like 245156283Srwatson # foo.o: sub/foo.c 246156283Srwatson # foo.o: sub/foo.h 247156283Srwatson # which is wrong. We want: 248156283Srwatson # sub/foo.o: sub/foo.c 249156283Srwatson # sub/foo.o: sub/foo.h 250156283Srwatson # sub/foo.c: 251156283Srwatson # sub/foo.h: 252156283Srwatson # ICC 7.1 will output 253156283Srwatson # foo.o: sub/foo.c sub/foo.h 254156283Srwatson # and will wrap long lines using \ : 255156283Srwatson # foo.o: sub/foo.c ... \ 256156283Srwatson # sub/foo.h ... \ 257156283Srwatson # ... 258156283Srwatson 259156283Srwatson "$@" -MD -MF "$tmpdepfile" 260156283Srwatson stat=$? 261156283Srwatson if test $stat -eq 0; then : 262156283Srwatson else 263156283Srwatson rm -f "$tmpdepfile" 264156283Srwatson exit $stat 265156283Srwatson fi 266156283Srwatson rm -f "$depfile" 267156283Srwatson # Each line is of the form `foo.o: dependent.h', 268156283Srwatson # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 269156283Srwatson # Do two passes, one to just change these to 270156283Srwatson # `$object: dependent.h' and one to simply `dependent.h:'. 271156283Srwatson sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 272156283Srwatson # Some versions of the HPUX 10.20 sed can't process this invocation 273156283Srwatson # correctly. Breaking it into two sed invocations is a workaround. 274156283Srwatson sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 275156283Srwatson sed -e 's/$/ :/' >> "$depfile" 276156283Srwatson rm -f "$tmpdepfile" 277156283Srwatson ;; 278156283Srwatson 279156283Srwatsontru64) 280156283Srwatson # The Tru64 compiler uses -MD to generate dependencies as a side 281156283Srwatson # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 282156283Srwatson # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 283156283Srwatson # dependencies in `foo.d' instead, so we check for that too. 284156283Srwatson # Subdirectories are respected. 285156283Srwatson dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 286156283Srwatson test "x$dir" = "x$object" && dir= 287156283Srwatson base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 288156283Srwatson 289156283Srwatson if test "$libtool" = yes; then 290156283Srwatson # With Tru64 cc, shared objects can also be used to make a 291156283Srwatson # static library. This mecanism is used in libtool 1.4 series to 292156283Srwatson # handle both shared and static libraries in a single compilation. 293156283Srwatson # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 294156283Srwatson # 295156283Srwatson # With libtool 1.5 this exception was removed, and libtool now 296156283Srwatson # generates 2 separate objects for the 2 libraries. These two 297156283Srwatson # compilations output dependencies in in $dir.libs/$base.o.d and 298156283Srwatson # in $dir$base.o.d. We have to check for both files, because 299156283Srwatson # one of the two compilations can be disabled. We should prefer 300156283Srwatson # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 301156283Srwatson # automatically cleaned when .libs/ is deleted, while ignoring 302156283Srwatson # the former would cause a distcleancheck panic. 303156283Srwatson tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 304156283Srwatson tmpdepfile2=$dir$base.o.d # libtool 1.5 305156283Srwatson tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 306156283Srwatson tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 307156283Srwatson "$@" -Wc,-MD 308156283Srwatson else 309156283Srwatson tmpdepfile1=$dir$base.o.d 310156283Srwatson tmpdepfile2=$dir$base.d 311156283Srwatson tmpdepfile3=$dir$base.d 312156283Srwatson tmpdepfile4=$dir$base.d 313156283Srwatson "$@" -MD 314156283Srwatson fi 315156283Srwatson 316156283Srwatson stat=$? 317156283Srwatson if test $stat -eq 0; then : 318156283Srwatson else 319156283Srwatson rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 320156283Srwatson exit $stat 321156283Srwatson fi 322156283Srwatson 323156283Srwatson for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 324156283Srwatson do 325156283Srwatson test -f "$tmpdepfile" && break 326156283Srwatson done 327156283Srwatson if test -f "$tmpdepfile"; then 328156283Srwatson sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 329156283Srwatson # That's a tab and a space in the []. 330156283Srwatson sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 331156283Srwatson else 332156283Srwatson echo "#dummy" > "$depfile" 333156283Srwatson fi 334156283Srwatson rm -f "$tmpdepfile" 335156283Srwatson ;; 336156283Srwatson 337156283Srwatson#nosideeffect) 338156283Srwatson # This comment above is used by automake to tell side-effect 339156283Srwatson # dependency tracking mechanisms from slower ones. 340156283Srwatson 341156283Srwatsondashmstdout) 342156283Srwatson # Important note: in order to support this mode, a compiler *must* 343156283Srwatson # always write the preprocessed file to stdout, regardless of -o. 344156283Srwatson "$@" || exit $? 345156283Srwatson 346156283Srwatson # Remove the call to Libtool. 347156283Srwatson if test "$libtool" = yes; then 348156283Srwatson while test $1 != '--mode=compile'; do 349156283Srwatson shift 350156283Srwatson done 351156283Srwatson shift 352156283Srwatson fi 353156283Srwatson 354156283Srwatson # Remove `-o $object'. 355156283Srwatson IFS=" " 356156283Srwatson for arg 357156283Srwatson do 358156283Srwatson case $arg in 359156283Srwatson -o) 360156283Srwatson shift 361156283Srwatson ;; 362156283Srwatson $object) 363156283Srwatson shift 364156283Srwatson ;; 365156283Srwatson *) 366156283Srwatson set fnord "$@" "$arg" 367156283Srwatson shift # fnord 368156283Srwatson shift # $arg 369156283Srwatson ;; 370156283Srwatson esac 371156283Srwatson done 372156283Srwatson 373156283Srwatson test -z "$dashmflag" && dashmflag=-M 374156283Srwatson # Require at least two characters before searching for `:' 375156283Srwatson # in the target name. This is to cope with DOS-style filenames: 376156283Srwatson # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 377156283Srwatson "$@" $dashmflag | 378156283Srwatson sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 379156283Srwatson rm -f "$depfile" 380156283Srwatson cat < "$tmpdepfile" > "$depfile" 381156283Srwatson tr ' ' ' 382156283Srwatson' < "$tmpdepfile" | \ 383156283Srwatson## Some versions of the HPUX 10.20 sed can't process this invocation 384156283Srwatson## correctly. Breaking it into two sed invocations is a workaround. 385156283Srwatson sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 386156283Srwatson rm -f "$tmpdepfile" 387156283Srwatson ;; 388156283Srwatson 389156283SrwatsondashXmstdout) 390156283Srwatson # This case only exists to satisfy depend.m4. It is never actually 391156283Srwatson # run, as this mode is specially recognized in the preamble. 392156283Srwatson exit 1 393156283Srwatson ;; 394156283Srwatson 395156283Srwatsonmakedepend) 396156283Srwatson "$@" || exit $? 397156283Srwatson # Remove any Libtool call 398156283Srwatson if test "$libtool" = yes; then 399156283Srwatson while test $1 != '--mode=compile'; do 400156283Srwatson shift 401156283Srwatson done 402156283Srwatson shift 403156283Srwatson fi 404156283Srwatson # X makedepend 405156283Srwatson shift 406156283Srwatson cleared=no 407156283Srwatson for arg in "$@"; do 408156283Srwatson case $cleared in 409156283Srwatson no) 410156283Srwatson set ""; shift 411156283Srwatson cleared=yes ;; 412156283Srwatson esac 413156283Srwatson case "$arg" in 414156283Srwatson -D*|-I*) 415156283Srwatson set fnord "$@" "$arg"; shift ;; 416156283Srwatson # Strip any option that makedepend may not understand. Remove 417156283Srwatson # the object too, otherwise makedepend will parse it as a source file. 418156283Srwatson -*|$object) 419156283Srwatson ;; 420156283Srwatson *) 421156283Srwatson set fnord "$@" "$arg"; shift ;; 422156283Srwatson esac 423156283Srwatson done 424156283Srwatson obj_suffix="`echo $object | sed 's/^.*\././'`" 425156283Srwatson touch "$tmpdepfile" 426156283Srwatson ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 427156283Srwatson rm -f "$depfile" 428156283Srwatson cat < "$tmpdepfile" > "$depfile" 429156283Srwatson sed '1,2d' "$tmpdepfile" | tr ' ' ' 430156283Srwatson' | \ 431156283Srwatson## Some versions of the HPUX 10.20 sed can't process this invocation 432156283Srwatson## correctly. Breaking it into two sed invocations is a workaround. 433156283Srwatson sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 434156283Srwatson rm -f "$tmpdepfile" "$tmpdepfile".bak 435156283Srwatson ;; 436156283Srwatson 437156283Srwatsoncpp) 438156283Srwatson # Important note: in order to support this mode, a compiler *must* 439156283Srwatson # always write the preprocessed file to stdout. 440156283Srwatson "$@" || exit $? 441156283Srwatson 442156283Srwatson # Remove the call to Libtool. 443156283Srwatson if test "$libtool" = yes; then 444156283Srwatson while test $1 != '--mode=compile'; do 445156283Srwatson shift 446156283Srwatson done 447156283Srwatson shift 448156283Srwatson fi 449156283Srwatson 450156283Srwatson # Remove `-o $object'. 451156283Srwatson IFS=" " 452156283Srwatson for arg 453156283Srwatson do 454156283Srwatson case $arg in 455156283Srwatson -o) 456156283Srwatson shift 457156283Srwatson ;; 458156283Srwatson $object) 459156283Srwatson shift 460156283Srwatson ;; 461156283Srwatson *) 462156283Srwatson set fnord "$@" "$arg" 463156283Srwatson shift # fnord 464156283Srwatson shift # $arg 465156283Srwatson ;; 466156283Srwatson esac 467156283Srwatson done 468156283Srwatson 469156283Srwatson "$@" -E | 470156283Srwatson sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 471156283Srwatson -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 472156283Srwatson sed '$ s: \\$::' > "$tmpdepfile" 473156283Srwatson rm -f "$depfile" 474156283Srwatson echo "$object : \\" > "$depfile" 475156283Srwatson cat < "$tmpdepfile" >> "$depfile" 476156283Srwatson sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 477156283Srwatson rm -f "$tmpdepfile" 478156283Srwatson ;; 479156283Srwatson 480156283Srwatsonmsvisualcpp) 481156283Srwatson # Important note: in order to support this mode, a compiler *must* 482156283Srwatson # always write the preprocessed file to stdout, regardless of -o, 483156283Srwatson # because we must use -o when running libtool. 484156283Srwatson "$@" || exit $? 485156283Srwatson IFS=" " 486156283Srwatson for arg 487156283Srwatson do 488156283Srwatson case "$arg" in 489156283Srwatson "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 490156283Srwatson set fnord "$@" 491156283Srwatson shift 492156283Srwatson shift 493156283Srwatson ;; 494156283Srwatson *) 495156283Srwatson set fnord "$@" "$arg" 496156283Srwatson shift 497156283Srwatson shift 498156283Srwatson ;; 499156283Srwatson esac 500156283Srwatson done 501156283Srwatson "$@" -E | 502156283Srwatson sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 503156283Srwatson rm -f "$depfile" 504156283Srwatson echo "$object : \\" > "$depfile" 505156283Srwatson . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 506156283Srwatson echo " " >> "$depfile" 507156283Srwatson . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 508156283Srwatson rm -f "$tmpdepfile" 509156283Srwatson ;; 510156283Srwatson 511156283Srwatsonnone) 512156283Srwatson exec "$@" 513156283Srwatson ;; 514156283Srwatson 515156283Srwatson*) 516156283Srwatson echo "Unknown depmode $depmode" 1>&2 517156283Srwatson exit 1 518156283Srwatson ;; 519156283Srwatsonesac 520156283Srwatson 521156283Srwatsonexit 0 522156283Srwatson 523156283Srwatson# Local Variables: 524156283Srwatson# mode: shell-script 525156283Srwatson# sh-indentation: 2 526156283Srwatson# eval: (add-hook 'write-file-hooks 'time-stamp) 527156283Srwatson# time-stamp-start: "scriptversion=" 528156283Srwatson# time-stamp-format: "%:y-%02m-%02d.%02H" 529156283Srwatson# time-stamp-end: "$" 530156283Srwatson# End: 531