depcomp revision 100ae103
1100ae103Smrg#! /bin/sh 2100ae103Smrg# depcomp - compile a program generating dependencies as side-effects 3100ae103Smrg 4100ae103Smrgscriptversion=2005-07-09.11 5100ae103Smrg 6100ae103Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7100ae103Smrg 8100ae103Smrg# This program is free software; you can redistribute it and/or modify 9100ae103Smrg# it under the terms of the GNU General Public License as published by 10100ae103Smrg# the Free Software Foundation; either version 2, or (at your option) 11100ae103Smrg# any later version. 12100ae103Smrg 13100ae103Smrg# This program is distributed in the hope that it will be useful, 14100ae103Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 15100ae103Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16100ae103Smrg# GNU General Public License for more details. 17100ae103Smrg 18100ae103Smrg# You should have received a copy of the GNU General Public License 19100ae103Smrg# along with this program; if not, write to the Free Software 20100ae103Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21100ae103Smrg# 02110-1301, USA. 22100ae103Smrg 23100ae103Smrg# As a special exception to the GNU General Public License, if you 24100ae103Smrg# distribute this file as part of a program that contains a 25100ae103Smrg# configuration script generated by Autoconf, you may include it under 26100ae103Smrg# the same distribution terms that you use for the rest of that program. 27100ae103Smrg 28100ae103Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 29100ae103Smrg 30100ae103Smrgcase $1 in 31100ae103Smrg '') 32100ae103Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 33100ae103Smrg exit 1; 34100ae103Smrg ;; 35100ae103Smrg -h | --h*) 36100ae103Smrg cat <<\EOF 37100ae103SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 38100ae103Smrg 39100ae103SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 40100ae103Smrgas side-effects. 41100ae103Smrg 42100ae103SmrgEnvironment variables: 43100ae103Smrg depmode Dependency tracking mode. 44100ae103Smrg source Source file read by `PROGRAMS ARGS'. 45100ae103Smrg object Object file output by `PROGRAMS ARGS'. 46100ae103Smrg DEPDIR directory where to store dependencies. 47100ae103Smrg depfile Dependency file to output. 48100ae103Smrg tmpdepfile Temporary file to use when outputing dependencies. 49100ae103Smrg libtool Whether libtool is used (yes/no). 50100ae103Smrg 51100ae103SmrgReport bugs to <bug-automake@gnu.org>. 52100ae103SmrgEOF 53100ae103Smrg exit $? 54100ae103Smrg ;; 55100ae103Smrg -v | --v*) 56100ae103Smrg echo "depcomp $scriptversion" 57100ae103Smrg exit $? 58100ae103Smrg ;; 59100ae103Smrgesac 60100ae103Smrg 61100ae103Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 62100ae103Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 63100ae103Smrg exit 1 64100ae103Smrgfi 65100ae103Smrg 66100ae103Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 67100ae103Smrgdepfile=${depfile-`echo "$object" | 68100ae103Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 69100ae103Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 70100ae103Smrg 71100ae103Smrgrm -f "$tmpdepfile" 72100ae103Smrg 73100ae103Smrg# Some modes work just like other modes, but use different flags. We 74100ae103Smrg# parameterize here, but still list the modes in the big case below, 75100ae103Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 76100ae103Smrg# here, because this file can only contain one case statement. 77100ae103Smrgif test "$depmode" = hp; then 78100ae103Smrg # HP compiler uses -M and no extra arg. 79100ae103Smrg gccflag=-M 80100ae103Smrg depmode=gcc 81100ae103Smrgfi 82100ae103Smrg 83100ae103Smrgif test "$depmode" = dashXmstdout; then 84100ae103Smrg # This is just like dashmstdout with a different argument. 85100ae103Smrg dashmflag=-xM 86100ae103Smrg depmode=dashmstdout 87100ae103Smrgfi 88100ae103Smrg 89100ae103Smrgcase "$depmode" in 90100ae103Smrggcc3) 91100ae103Smrg## gcc 3 implements dependency tracking that does exactly what 92100ae103Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 93100ae103Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 94100ae103Smrg "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 95100ae103Smrg stat=$? 96100ae103Smrg if test $stat -eq 0; then : 97100ae103Smrg else 98100ae103Smrg rm -f "$tmpdepfile" 99100ae103Smrg exit $stat 100100ae103Smrg fi 101100ae103Smrg mv "$tmpdepfile" "$depfile" 102100ae103Smrg ;; 103100ae103Smrg 104100ae103Smrggcc) 105100ae103Smrg## There are various ways to get dependency output from gcc. Here's 106100ae103Smrg## why we pick this rather obscure method: 107100ae103Smrg## - Don't want to use -MD because we'd like the dependencies to end 108100ae103Smrg## up in a subdir. Having to rename by hand is ugly. 109100ae103Smrg## (We might end up doing this anyway to support other compilers.) 110100ae103Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 111100ae103Smrg## -MM, not -M (despite what the docs say). 112100ae103Smrg## - Using -M directly means running the compiler twice (even worse 113100ae103Smrg## than renaming). 114100ae103Smrg if test -z "$gccflag"; then 115100ae103Smrg gccflag=-MD, 116100ae103Smrg fi 117100ae103Smrg "$@" -Wp,"$gccflag$tmpdepfile" 118100ae103Smrg stat=$? 119100ae103Smrg if test $stat -eq 0; then : 120100ae103Smrg else 121100ae103Smrg rm -f "$tmpdepfile" 122100ae103Smrg exit $stat 123100ae103Smrg fi 124100ae103Smrg rm -f "$depfile" 125100ae103Smrg echo "$object : \\" > "$depfile" 126100ae103Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 127100ae103Smrg## The second -e expression handles DOS-style file names with drive letters. 128100ae103Smrg sed -e 's/^[^:]*: / /' \ 129100ae103Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 130100ae103Smrg## This next piece of magic avoids the `deleted header file' problem. 131100ae103Smrg## The problem is that when a header file which appears in a .P file 132100ae103Smrg## is deleted, the dependency causes make to die (because there is 133100ae103Smrg## typically no way to rebuild the header). We avoid this by adding 134100ae103Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 135100ae103Smrg## this for us directly. 136100ae103Smrg tr ' ' ' 137100ae103Smrg' < "$tmpdepfile" | 138100ae103Smrg## Some versions of gcc put a space before the `:'. On the theory 139100ae103Smrg## that the space means something, we add a space to the output as 140100ae103Smrg## well. 141100ae103Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 142100ae103Smrg## correctly. Breaking it into two sed invocations is a workaround. 143100ae103Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 144100ae103Smrg rm -f "$tmpdepfile" 145100ae103Smrg ;; 146100ae103Smrg 147100ae103Smrghp) 148100ae103Smrg # This case exists only to let depend.m4 do its work. It works by 149100ae103Smrg # looking at the text of this script. This case will never be run, 150100ae103Smrg # since it is checked for above. 151100ae103Smrg exit 1 152100ae103Smrg ;; 153100ae103Smrg 154100ae103Smrgsgi) 155100ae103Smrg if test "$libtool" = yes; then 156100ae103Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 157100ae103Smrg else 158100ae103Smrg "$@" -MDupdate "$tmpdepfile" 159100ae103Smrg fi 160100ae103Smrg stat=$? 161100ae103Smrg if test $stat -eq 0; then : 162100ae103Smrg else 163100ae103Smrg rm -f "$tmpdepfile" 164100ae103Smrg exit $stat 165100ae103Smrg fi 166100ae103Smrg rm -f "$depfile" 167100ae103Smrg 168100ae103Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 169100ae103Smrg echo "$object : \\" > "$depfile" 170100ae103Smrg 171100ae103Smrg # Clip off the initial element (the dependent). Don't try to be 172100ae103Smrg # clever and replace this with sed code, as IRIX sed won't handle 173100ae103Smrg # lines with more than a fixed number of characters (4096 in 174100ae103Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 175100ae103Smrg # the IRIX cc adds comments like `#:fec' to the end of the 176100ae103Smrg # dependency line. 177100ae103Smrg tr ' ' ' 178100ae103Smrg' < "$tmpdepfile" \ 179100ae103Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 180100ae103Smrg tr ' 181100ae103Smrg' ' ' >> $depfile 182100ae103Smrg echo >> $depfile 183100ae103Smrg 184100ae103Smrg # The second pass generates a dummy entry for each header file. 185100ae103Smrg tr ' ' ' 186100ae103Smrg' < "$tmpdepfile" \ 187100ae103Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 188100ae103Smrg >> $depfile 189100ae103Smrg else 190100ae103Smrg # The sourcefile does not contain any dependencies, so just 191100ae103Smrg # store a dummy comment line, to avoid errors with the Makefile 192100ae103Smrg # "include basename.Plo" scheme. 193100ae103Smrg echo "#dummy" > "$depfile" 194100ae103Smrg fi 195100ae103Smrg rm -f "$tmpdepfile" 196100ae103Smrg ;; 197100ae103Smrg 198100ae103Smrgaix) 199100ae103Smrg # The C for AIX Compiler uses -M and outputs the dependencies 200100ae103Smrg # in a .u file. In older versions, this file always lives in the 201100ae103Smrg # current directory. Also, the AIX compiler puts `$object:' at the 202100ae103Smrg # start of each line; $object doesn't have directory information. 203100ae103Smrg # Version 6 uses the directory in both cases. 204100ae103Smrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 205100ae103Smrg tmpdepfile="$stripped.u" 206100ae103Smrg if test "$libtool" = yes; then 207100ae103Smrg "$@" -Wc,-M 208100ae103Smrg else 209100ae103Smrg "$@" -M 210100ae103Smrg fi 211100ae103Smrg stat=$? 212100ae103Smrg 213100ae103Smrg if test -f "$tmpdepfile"; then : 214100ae103Smrg else 215100ae103Smrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 216100ae103Smrg tmpdepfile="$stripped.u" 217100ae103Smrg fi 218100ae103Smrg 219100ae103Smrg if test $stat -eq 0; then : 220100ae103Smrg else 221100ae103Smrg rm -f "$tmpdepfile" 222100ae103Smrg exit $stat 223100ae103Smrg fi 224100ae103Smrg 225100ae103Smrg if test -f "$tmpdepfile"; then 226100ae103Smrg outname="$stripped.o" 227100ae103Smrg # Each line is of the form `foo.o: dependent.h'. 228100ae103Smrg # Do two passes, one to just change these to 229100ae103Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 230100ae103Smrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 231100ae103Smrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 232100ae103Smrg else 233100ae103Smrg # The sourcefile does not contain any dependencies, so just 234100ae103Smrg # store a dummy comment line, to avoid errors with the Makefile 235100ae103Smrg # "include basename.Plo" scheme. 236100ae103Smrg echo "#dummy" > "$depfile" 237100ae103Smrg fi 238100ae103Smrg rm -f "$tmpdepfile" 239100ae103Smrg ;; 240100ae103Smrg 241100ae103Smrgicc) 242100ae103Smrg # Intel's C compiler understands `-MD -MF file'. However on 243100ae103Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 244100ae103Smrg # ICC 7.0 will fill foo.d with something like 245100ae103Smrg # foo.o: sub/foo.c 246100ae103Smrg # foo.o: sub/foo.h 247100ae103Smrg # which is wrong. We want: 248100ae103Smrg # sub/foo.o: sub/foo.c 249100ae103Smrg # sub/foo.o: sub/foo.h 250100ae103Smrg # sub/foo.c: 251100ae103Smrg # sub/foo.h: 252100ae103Smrg # ICC 7.1 will output 253100ae103Smrg # foo.o: sub/foo.c sub/foo.h 254100ae103Smrg # and will wrap long lines using \ : 255100ae103Smrg # foo.o: sub/foo.c ... \ 256100ae103Smrg # sub/foo.h ... \ 257100ae103Smrg # ... 258100ae103Smrg 259100ae103Smrg "$@" -MD -MF "$tmpdepfile" 260100ae103Smrg stat=$? 261100ae103Smrg if test $stat -eq 0; then : 262100ae103Smrg else 263100ae103Smrg rm -f "$tmpdepfile" 264100ae103Smrg exit $stat 265100ae103Smrg fi 266100ae103Smrg rm -f "$depfile" 267100ae103Smrg # Each line is of the form `foo.o: dependent.h', 268100ae103Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 269100ae103Smrg # Do two passes, one to just change these to 270100ae103Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 271100ae103Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 272100ae103Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 273100ae103Smrg # correctly. Breaking it into two sed invocations is a workaround. 274100ae103Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 275100ae103Smrg sed -e 's/$/ :/' >> "$depfile" 276100ae103Smrg rm -f "$tmpdepfile" 277100ae103Smrg ;; 278100ae103Smrg 279100ae103Smrgtru64) 280100ae103Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 281100ae103Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 282100ae103Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 283100ae103Smrg # dependencies in `foo.d' instead, so we check for that too. 284100ae103Smrg # Subdirectories are respected. 285100ae103Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 286100ae103Smrg test "x$dir" = "x$object" && dir= 287100ae103Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 288100ae103Smrg 289100ae103Smrg if test "$libtool" = yes; then 290100ae103Smrg # With Tru64 cc, shared objects can also be used to make a 291100ae103Smrg # static library. This mecanism is used in libtool 1.4 series to 292100ae103Smrg # handle both shared and static libraries in a single compilation. 293100ae103Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 294100ae103Smrg # 295100ae103Smrg # With libtool 1.5 this exception was removed, and libtool now 296100ae103Smrg # generates 2 separate objects for the 2 libraries. These two 297100ae103Smrg # compilations output dependencies in in $dir.libs/$base.o.d and 298100ae103Smrg # in $dir$base.o.d. We have to check for both files, because 299100ae103Smrg # one of the two compilations can be disabled. We should prefer 300100ae103Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 301100ae103Smrg # automatically cleaned when .libs/ is deleted, while ignoring 302100ae103Smrg # the former would cause a distcleancheck panic. 303100ae103Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 304100ae103Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 305100ae103Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 306100ae103Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 307100ae103Smrg "$@" -Wc,-MD 308100ae103Smrg else 309100ae103Smrg tmpdepfile1=$dir$base.o.d 310100ae103Smrg tmpdepfile2=$dir$base.d 311100ae103Smrg tmpdepfile3=$dir$base.d 312100ae103Smrg tmpdepfile4=$dir$base.d 313100ae103Smrg "$@" -MD 314100ae103Smrg fi 315100ae103Smrg 316100ae103Smrg stat=$? 317100ae103Smrg if test $stat -eq 0; then : 318100ae103Smrg else 319100ae103Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 320100ae103Smrg exit $stat 321100ae103Smrg fi 322100ae103Smrg 323100ae103Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 324100ae103Smrg do 325100ae103Smrg test -f "$tmpdepfile" && break 326100ae103Smrg done 327100ae103Smrg if test -f "$tmpdepfile"; then 328100ae103Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 329100ae103Smrg # That's a tab and a space in the []. 330100ae103Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 331100ae103Smrg else 332100ae103Smrg echo "#dummy" > "$depfile" 333100ae103Smrg fi 334100ae103Smrg rm -f "$tmpdepfile" 335100ae103Smrg ;; 336100ae103Smrg 337100ae103Smrg#nosideeffect) 338100ae103Smrg # This comment above is used by automake to tell side-effect 339100ae103Smrg # dependency tracking mechanisms from slower ones. 340100ae103Smrg 341100ae103Smrgdashmstdout) 342100ae103Smrg # Important note: in order to support this mode, a compiler *must* 343100ae103Smrg # always write the preprocessed file to stdout, regardless of -o. 344100ae103Smrg "$@" || exit $? 345100ae103Smrg 346100ae103Smrg # Remove the call to Libtool. 347100ae103Smrg if test "$libtool" = yes; then 348100ae103Smrg while test $1 != '--mode=compile'; do 349100ae103Smrg shift 350100ae103Smrg done 351100ae103Smrg shift 352100ae103Smrg fi 353100ae103Smrg 354100ae103Smrg # Remove `-o $object'. 355100ae103Smrg IFS=" " 356100ae103Smrg for arg 357100ae103Smrg do 358100ae103Smrg case $arg in 359100ae103Smrg -o) 360100ae103Smrg shift 361100ae103Smrg ;; 362100ae103Smrg $object) 363100ae103Smrg shift 364100ae103Smrg ;; 365100ae103Smrg *) 366100ae103Smrg set fnord "$@" "$arg" 367100ae103Smrg shift # fnord 368100ae103Smrg shift # $arg 369100ae103Smrg ;; 370100ae103Smrg esac 371100ae103Smrg done 372100ae103Smrg 373100ae103Smrg test -z "$dashmflag" && dashmflag=-M 374100ae103Smrg # Require at least two characters before searching for `:' 375100ae103Smrg # in the target name. This is to cope with DOS-style filenames: 376100ae103Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 377100ae103Smrg "$@" $dashmflag | 378100ae103Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 379100ae103Smrg rm -f "$depfile" 380100ae103Smrg cat < "$tmpdepfile" > "$depfile" 381100ae103Smrg tr ' ' ' 382100ae103Smrg' < "$tmpdepfile" | \ 383100ae103Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 384100ae103Smrg## correctly. Breaking it into two sed invocations is a workaround. 385100ae103Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 386100ae103Smrg rm -f "$tmpdepfile" 387100ae103Smrg ;; 388100ae103Smrg 389100ae103SmrgdashXmstdout) 390100ae103Smrg # This case only exists to satisfy depend.m4. It is never actually 391100ae103Smrg # run, as this mode is specially recognized in the preamble. 392100ae103Smrg exit 1 393100ae103Smrg ;; 394100ae103Smrg 395100ae103Smrgmakedepend) 396100ae103Smrg "$@" || exit $? 397100ae103Smrg # Remove any Libtool call 398100ae103Smrg if test "$libtool" = yes; then 399100ae103Smrg while test $1 != '--mode=compile'; do 400100ae103Smrg shift 401100ae103Smrg done 402100ae103Smrg shift 403100ae103Smrg fi 404100ae103Smrg # X makedepend 405100ae103Smrg shift 406100ae103Smrg cleared=no 407100ae103Smrg for arg in "$@"; do 408100ae103Smrg case $cleared in 409100ae103Smrg no) 410100ae103Smrg set ""; shift 411100ae103Smrg cleared=yes ;; 412100ae103Smrg esac 413100ae103Smrg case "$arg" in 414100ae103Smrg -D*|-I*) 415100ae103Smrg set fnord "$@" "$arg"; shift ;; 416100ae103Smrg # Strip any option that makedepend may not understand. Remove 417100ae103Smrg # the object too, otherwise makedepend will parse it as a source file. 418100ae103Smrg -*|$object) 419100ae103Smrg ;; 420100ae103Smrg *) 421100ae103Smrg set fnord "$@" "$arg"; shift ;; 422100ae103Smrg esac 423100ae103Smrg done 424100ae103Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 425100ae103Smrg touch "$tmpdepfile" 426100ae103Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 427100ae103Smrg rm -f "$depfile" 428100ae103Smrg cat < "$tmpdepfile" > "$depfile" 429100ae103Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 430100ae103Smrg' | \ 431100ae103Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 432100ae103Smrg## correctly. Breaking it into two sed invocations is a workaround. 433100ae103Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 434100ae103Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 435100ae103Smrg ;; 436100ae103Smrg 437100ae103Smrgcpp) 438100ae103Smrg # Important note: in order to support this mode, a compiler *must* 439100ae103Smrg # always write the preprocessed file to stdout. 440100ae103Smrg "$@" || exit $? 441100ae103Smrg 442100ae103Smrg # Remove the call to Libtool. 443100ae103Smrg if test "$libtool" = yes; then 444100ae103Smrg while test $1 != '--mode=compile'; do 445100ae103Smrg shift 446100ae103Smrg done 447100ae103Smrg shift 448100ae103Smrg fi 449100ae103Smrg 450100ae103Smrg # Remove `-o $object'. 451100ae103Smrg IFS=" " 452100ae103Smrg for arg 453100ae103Smrg do 454100ae103Smrg case $arg in 455100ae103Smrg -o) 456100ae103Smrg shift 457100ae103Smrg ;; 458100ae103Smrg $object) 459100ae103Smrg shift 460100ae103Smrg ;; 461100ae103Smrg *) 462100ae103Smrg set fnord "$@" "$arg" 463100ae103Smrg shift # fnord 464100ae103Smrg shift # $arg 465100ae103Smrg ;; 466100ae103Smrg esac 467100ae103Smrg done 468100ae103Smrg 469100ae103Smrg "$@" -E | 470100ae103Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 471100ae103Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 472100ae103Smrg sed '$ s: \\$::' > "$tmpdepfile" 473100ae103Smrg rm -f "$depfile" 474100ae103Smrg echo "$object : \\" > "$depfile" 475100ae103Smrg cat < "$tmpdepfile" >> "$depfile" 476100ae103Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 477100ae103Smrg rm -f "$tmpdepfile" 478100ae103Smrg ;; 479100ae103Smrg 480100ae103Smrgmsvisualcpp) 481100ae103Smrg # Important note: in order to support this mode, a compiler *must* 482100ae103Smrg # always write the preprocessed file to stdout, regardless of -o, 483100ae103Smrg # because we must use -o when running libtool. 484100ae103Smrg "$@" || exit $? 485100ae103Smrg IFS=" " 486100ae103Smrg for arg 487100ae103Smrg do 488100ae103Smrg case "$arg" in 489100ae103Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 490100ae103Smrg set fnord "$@" 491100ae103Smrg shift 492100ae103Smrg shift 493100ae103Smrg ;; 494100ae103Smrg *) 495100ae103Smrg set fnord "$@" "$arg" 496100ae103Smrg shift 497100ae103Smrg shift 498100ae103Smrg ;; 499100ae103Smrg esac 500100ae103Smrg done 501100ae103Smrg "$@" -E | 502100ae103Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 503100ae103Smrg rm -f "$depfile" 504100ae103Smrg echo "$object : \\" > "$depfile" 505100ae103Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 506100ae103Smrg echo " " >> "$depfile" 507100ae103Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 508100ae103Smrg rm -f "$tmpdepfile" 509100ae103Smrg ;; 510100ae103Smrg 511100ae103Smrgnone) 512100ae103Smrg exec "$@" 513100ae103Smrg ;; 514100ae103Smrg 515100ae103Smrg*) 516100ae103Smrg echo "Unknown depmode $depmode" 1>&2 517100ae103Smrg exit 1 518100ae103Smrg ;; 519100ae103Smrgesac 520100ae103Smrg 521100ae103Smrgexit 0 522100ae103Smrg 523100ae103Smrg# Local Variables: 524100ae103Smrg# mode: shell-script 525100ae103Smrg# sh-indentation: 2 526100ae103Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 527100ae103Smrg# time-stamp-start: "scriptversion=" 528100ae103Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 529100ae103Smrg# time-stamp-end: "$" 530100ae103Smrg# End: 531