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