depcomp revision 692f60a7
1692f60a7Smrg#! /bin/sh 2692f60a7Smrg# depcomp - compile a program generating dependencies as side-effects 3692f60a7Smrg 4692f60a7Smrgscriptversion=2005-07-09.11 5692f60a7Smrg 6692f60a7Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7692f60a7Smrg 8692f60a7Smrg# This program is free software; you can redistribute it and/or modify 9692f60a7Smrg# it under the terms of the GNU General Public License as published by 10692f60a7Smrg# the Free Software Foundation; either version 2, or (at your option) 11692f60a7Smrg# any later version. 12692f60a7Smrg 13692f60a7Smrg# This program is distributed in the hope that it will be useful, 14692f60a7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 15692f60a7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16692f60a7Smrg# GNU General Public License for more details. 17692f60a7Smrg 18692f60a7Smrg# You should have received a copy of the GNU General Public License 19692f60a7Smrg# along with this program; if not, write to the Free Software 20692f60a7Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21692f60a7Smrg# 02110-1301, USA. 22692f60a7Smrg 23692f60a7Smrg# As a special exception to the GNU General Public License, if you 24692f60a7Smrg# distribute this file as part of a program that contains a 25692f60a7Smrg# configuration script generated by Autoconf, you may include it under 26692f60a7Smrg# the same distribution terms that you use for the rest of that program. 27692f60a7Smrg 28692f60a7Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 29692f60a7Smrg 30692f60a7Smrgcase $1 in 31692f60a7Smrg '') 32692f60a7Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 33692f60a7Smrg exit 1; 34692f60a7Smrg ;; 35692f60a7Smrg -h | --h*) 36692f60a7Smrg cat <<\EOF 37692f60a7SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 38692f60a7Smrg 39692f60a7SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 40692f60a7Smrgas side-effects. 41692f60a7Smrg 42692f60a7SmrgEnvironment variables: 43692f60a7Smrg depmode Dependency tracking mode. 44692f60a7Smrg source Source file read by `PROGRAMS ARGS'. 45692f60a7Smrg object Object file output by `PROGRAMS ARGS'. 46692f60a7Smrg DEPDIR directory where to store dependencies. 47692f60a7Smrg depfile Dependency file to output. 48692f60a7Smrg tmpdepfile Temporary file to use when outputing dependencies. 49692f60a7Smrg libtool Whether libtool is used (yes/no). 50692f60a7Smrg 51692f60a7SmrgReport bugs to <bug-automake@gnu.org>. 52692f60a7SmrgEOF 53692f60a7Smrg exit $? 54692f60a7Smrg ;; 55692f60a7Smrg -v | --v*) 56692f60a7Smrg echo "depcomp $scriptversion" 57692f60a7Smrg exit $? 58692f60a7Smrg ;; 59692f60a7Smrgesac 60692f60a7Smrg 61692f60a7Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 62692f60a7Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 63692f60a7Smrg exit 1 64692f60a7Smrgfi 65692f60a7Smrg 66692f60a7Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 67692f60a7Smrgdepfile=${depfile-`echo "$object" | 68692f60a7Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 69692f60a7Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 70692f60a7Smrg 71692f60a7Smrgrm -f "$tmpdepfile" 72692f60a7Smrg 73692f60a7Smrg# Some modes work just like other modes, but use different flags. We 74692f60a7Smrg# parameterize here, but still list the modes in the big case below, 75692f60a7Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 76692f60a7Smrg# here, because this file can only contain one case statement. 77692f60a7Smrgif test "$depmode" = hp; then 78692f60a7Smrg # HP compiler uses -M and no extra arg. 79692f60a7Smrg gccflag=-M 80692f60a7Smrg depmode=gcc 81692f60a7Smrgfi 82692f60a7Smrg 83692f60a7Smrgif test "$depmode" = dashXmstdout; then 84692f60a7Smrg # This is just like dashmstdout with a different argument. 85692f60a7Smrg dashmflag=-xM 86692f60a7Smrg depmode=dashmstdout 87692f60a7Smrgfi 88692f60a7Smrg 89692f60a7Smrgcase "$depmode" in 90692f60a7Smrggcc3) 91692f60a7Smrg## gcc 3 implements dependency tracking that does exactly what 92692f60a7Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 93692f60a7Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 94692f60a7Smrg "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 95692f60a7Smrg stat=$? 96692f60a7Smrg if test $stat -eq 0; then : 97692f60a7Smrg else 98692f60a7Smrg rm -f "$tmpdepfile" 99692f60a7Smrg exit $stat 100692f60a7Smrg fi 101692f60a7Smrg mv "$tmpdepfile" "$depfile" 102692f60a7Smrg ;; 103692f60a7Smrg 104692f60a7Smrggcc) 105692f60a7Smrg## There are various ways to get dependency output from gcc. Here's 106692f60a7Smrg## why we pick this rather obscure method: 107692f60a7Smrg## - Don't want to use -MD because we'd like the dependencies to end 108692f60a7Smrg## up in a subdir. Having to rename by hand is ugly. 109692f60a7Smrg## (We might end up doing this anyway to support other compilers.) 110692f60a7Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 111692f60a7Smrg## -MM, not -M (despite what the docs say). 112692f60a7Smrg## - Using -M directly means running the compiler twice (even worse 113692f60a7Smrg## than renaming). 114692f60a7Smrg if test -z "$gccflag"; then 115692f60a7Smrg gccflag=-MD, 116692f60a7Smrg fi 117692f60a7Smrg "$@" -Wp,"$gccflag$tmpdepfile" 118692f60a7Smrg stat=$? 119692f60a7Smrg if test $stat -eq 0; then : 120692f60a7Smrg else 121692f60a7Smrg rm -f "$tmpdepfile" 122692f60a7Smrg exit $stat 123692f60a7Smrg fi 124692f60a7Smrg rm -f "$depfile" 125692f60a7Smrg echo "$object : \\" > "$depfile" 126692f60a7Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 127692f60a7Smrg## The second -e expression handles DOS-style file names with drive letters. 128692f60a7Smrg sed -e 's/^[^:]*: / /' \ 129692f60a7Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 130692f60a7Smrg## This next piece of magic avoids the `deleted header file' problem. 131692f60a7Smrg## The problem is that when a header file which appears in a .P file 132692f60a7Smrg## is deleted, the dependency causes make to die (because there is 133692f60a7Smrg## typically no way to rebuild the header). We avoid this by adding 134692f60a7Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 135692f60a7Smrg## this for us directly. 136692f60a7Smrg tr ' ' ' 137692f60a7Smrg' < "$tmpdepfile" | 138692f60a7Smrg## Some versions of gcc put a space before the `:'. On the theory 139692f60a7Smrg## that the space means something, we add a space to the output as 140692f60a7Smrg## well. 141692f60a7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 142692f60a7Smrg## correctly. Breaking it into two sed invocations is a workaround. 143692f60a7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 144692f60a7Smrg rm -f "$tmpdepfile" 145692f60a7Smrg ;; 146692f60a7Smrg 147692f60a7Smrghp) 148692f60a7Smrg # This case exists only to let depend.m4 do its work. It works by 149692f60a7Smrg # looking at the text of this script. This case will never be run, 150692f60a7Smrg # since it is checked for above. 151692f60a7Smrg exit 1 152692f60a7Smrg ;; 153692f60a7Smrg 154692f60a7Smrgsgi) 155692f60a7Smrg if test "$libtool" = yes; then 156692f60a7Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 157692f60a7Smrg else 158692f60a7Smrg "$@" -MDupdate "$tmpdepfile" 159692f60a7Smrg fi 160692f60a7Smrg stat=$? 161692f60a7Smrg if test $stat -eq 0; then : 162692f60a7Smrg else 163692f60a7Smrg rm -f "$tmpdepfile" 164692f60a7Smrg exit $stat 165692f60a7Smrg fi 166692f60a7Smrg rm -f "$depfile" 167692f60a7Smrg 168692f60a7Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 169692f60a7Smrg echo "$object : \\" > "$depfile" 170692f60a7Smrg 171692f60a7Smrg # Clip off the initial element (the dependent). Don't try to be 172692f60a7Smrg # clever and replace this with sed code, as IRIX sed won't handle 173692f60a7Smrg # lines with more than a fixed number of characters (4096 in 174692f60a7Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 175692f60a7Smrg # the IRIX cc adds comments like `#:fec' to the end of the 176692f60a7Smrg # dependency line. 177692f60a7Smrg tr ' ' ' 178692f60a7Smrg' < "$tmpdepfile" \ 179692f60a7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 180692f60a7Smrg tr ' 181692f60a7Smrg' ' ' >> $depfile 182692f60a7Smrg echo >> $depfile 183692f60a7Smrg 184692f60a7Smrg # The second pass generates a dummy entry for each header file. 185692f60a7Smrg tr ' ' ' 186692f60a7Smrg' < "$tmpdepfile" \ 187692f60a7Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 188692f60a7Smrg >> $depfile 189692f60a7Smrg else 190692f60a7Smrg # The sourcefile does not contain any dependencies, so just 191692f60a7Smrg # store a dummy comment line, to avoid errors with the Makefile 192692f60a7Smrg # "include basename.Plo" scheme. 193692f60a7Smrg echo "#dummy" > "$depfile" 194692f60a7Smrg fi 195692f60a7Smrg rm -f "$tmpdepfile" 196692f60a7Smrg ;; 197692f60a7Smrg 198692f60a7Smrgaix) 199692f60a7Smrg # The C for AIX Compiler uses -M and outputs the dependencies 200692f60a7Smrg # in a .u file. In older versions, this file always lives in the 201692f60a7Smrg # current directory. Also, the AIX compiler puts `$object:' at the 202692f60a7Smrg # start of each line; $object doesn't have directory information. 203692f60a7Smrg # Version 6 uses the directory in both cases. 204692f60a7Smrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 205692f60a7Smrg tmpdepfile="$stripped.u" 206692f60a7Smrg if test "$libtool" = yes; then 207692f60a7Smrg "$@" -Wc,-M 208692f60a7Smrg else 209692f60a7Smrg "$@" -M 210692f60a7Smrg fi 211692f60a7Smrg stat=$? 212692f60a7Smrg 213692f60a7Smrg if test -f "$tmpdepfile"; then : 214692f60a7Smrg else 215692f60a7Smrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 216692f60a7Smrg tmpdepfile="$stripped.u" 217692f60a7Smrg fi 218692f60a7Smrg 219692f60a7Smrg if test $stat -eq 0; then : 220692f60a7Smrg else 221692f60a7Smrg rm -f "$tmpdepfile" 222692f60a7Smrg exit $stat 223692f60a7Smrg fi 224692f60a7Smrg 225692f60a7Smrg if test -f "$tmpdepfile"; then 226692f60a7Smrg outname="$stripped.o" 227692f60a7Smrg # Each line is of the form `foo.o: dependent.h'. 228692f60a7Smrg # Do two passes, one to just change these to 229692f60a7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 230692f60a7Smrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 231692f60a7Smrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 232692f60a7Smrg else 233692f60a7Smrg # The sourcefile does not contain any dependencies, so just 234692f60a7Smrg # store a dummy comment line, to avoid errors with the Makefile 235692f60a7Smrg # "include basename.Plo" scheme. 236692f60a7Smrg echo "#dummy" > "$depfile" 237692f60a7Smrg fi 238692f60a7Smrg rm -f "$tmpdepfile" 239692f60a7Smrg ;; 240692f60a7Smrg 241692f60a7Smrgicc) 242692f60a7Smrg # Intel's C compiler understands `-MD -MF file'. However on 243692f60a7Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 244692f60a7Smrg # ICC 7.0 will fill foo.d with something like 245692f60a7Smrg # foo.o: sub/foo.c 246692f60a7Smrg # foo.o: sub/foo.h 247692f60a7Smrg # which is wrong. We want: 248692f60a7Smrg # sub/foo.o: sub/foo.c 249692f60a7Smrg # sub/foo.o: sub/foo.h 250692f60a7Smrg # sub/foo.c: 251692f60a7Smrg # sub/foo.h: 252692f60a7Smrg # ICC 7.1 will output 253692f60a7Smrg # foo.o: sub/foo.c sub/foo.h 254692f60a7Smrg # and will wrap long lines using \ : 255692f60a7Smrg # foo.o: sub/foo.c ... \ 256692f60a7Smrg # sub/foo.h ... \ 257692f60a7Smrg # ... 258692f60a7Smrg 259692f60a7Smrg "$@" -MD -MF "$tmpdepfile" 260692f60a7Smrg stat=$? 261692f60a7Smrg if test $stat -eq 0; then : 262692f60a7Smrg else 263692f60a7Smrg rm -f "$tmpdepfile" 264692f60a7Smrg exit $stat 265692f60a7Smrg fi 266692f60a7Smrg rm -f "$depfile" 267692f60a7Smrg # Each line is of the form `foo.o: dependent.h', 268692f60a7Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 269692f60a7Smrg # Do two passes, one to just change these to 270692f60a7Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 271692f60a7Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 272692f60a7Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 273692f60a7Smrg # correctly. Breaking it into two sed invocations is a workaround. 274692f60a7Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 275692f60a7Smrg sed -e 's/$/ :/' >> "$depfile" 276692f60a7Smrg rm -f "$tmpdepfile" 277692f60a7Smrg ;; 278692f60a7Smrg 279692f60a7Smrgtru64) 280692f60a7Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 281692f60a7Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 282692f60a7Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 283692f60a7Smrg # dependencies in `foo.d' instead, so we check for that too. 284692f60a7Smrg # Subdirectories are respected. 285692f60a7Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 286692f60a7Smrg test "x$dir" = "x$object" && dir= 287692f60a7Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 288692f60a7Smrg 289692f60a7Smrg if test "$libtool" = yes; then 290692f60a7Smrg # With Tru64 cc, shared objects can also be used to make a 291692f60a7Smrg # static library. This mecanism is used in libtool 1.4 series to 292692f60a7Smrg # handle both shared and static libraries in a single compilation. 293692f60a7Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 294692f60a7Smrg # 295692f60a7Smrg # With libtool 1.5 this exception was removed, and libtool now 296692f60a7Smrg # generates 2 separate objects for the 2 libraries. These two 297692f60a7Smrg # compilations output dependencies in in $dir.libs/$base.o.d and 298692f60a7Smrg # in $dir$base.o.d. We have to check for both files, because 299692f60a7Smrg # one of the two compilations can be disabled. We should prefer 300692f60a7Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 301692f60a7Smrg # automatically cleaned when .libs/ is deleted, while ignoring 302692f60a7Smrg # the former would cause a distcleancheck panic. 303692f60a7Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 304692f60a7Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 305692f60a7Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 306692f60a7Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 307692f60a7Smrg "$@" -Wc,-MD 308692f60a7Smrg else 309692f60a7Smrg tmpdepfile1=$dir$base.o.d 310692f60a7Smrg tmpdepfile2=$dir$base.d 311692f60a7Smrg tmpdepfile3=$dir$base.d 312692f60a7Smrg tmpdepfile4=$dir$base.d 313692f60a7Smrg "$@" -MD 314692f60a7Smrg fi 315692f60a7Smrg 316692f60a7Smrg stat=$? 317692f60a7Smrg if test $stat -eq 0; then : 318692f60a7Smrg else 319692f60a7Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 320692f60a7Smrg exit $stat 321692f60a7Smrg fi 322692f60a7Smrg 323692f60a7Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 324692f60a7Smrg do 325692f60a7Smrg test -f "$tmpdepfile" && break 326692f60a7Smrg done 327692f60a7Smrg if test -f "$tmpdepfile"; then 328692f60a7Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 329692f60a7Smrg # That's a tab and a space in the []. 330692f60a7Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 331692f60a7Smrg else 332692f60a7Smrg echo "#dummy" > "$depfile" 333692f60a7Smrg fi 334692f60a7Smrg rm -f "$tmpdepfile" 335692f60a7Smrg ;; 336692f60a7Smrg 337692f60a7Smrg#nosideeffect) 338692f60a7Smrg # This comment above is used by automake to tell side-effect 339692f60a7Smrg # dependency tracking mechanisms from slower ones. 340692f60a7Smrg 341692f60a7Smrgdashmstdout) 342692f60a7Smrg # Important note: in order to support this mode, a compiler *must* 343692f60a7Smrg # always write the preprocessed file to stdout, regardless of -o. 344692f60a7Smrg "$@" || exit $? 345692f60a7Smrg 346692f60a7Smrg # Remove the call to Libtool. 347692f60a7Smrg if test "$libtool" = yes; then 348692f60a7Smrg while test $1 != '--mode=compile'; do 349692f60a7Smrg shift 350692f60a7Smrg done 351692f60a7Smrg shift 352692f60a7Smrg fi 353692f60a7Smrg 354692f60a7Smrg # Remove `-o $object'. 355692f60a7Smrg IFS=" " 356692f60a7Smrg for arg 357692f60a7Smrg do 358692f60a7Smrg case $arg in 359692f60a7Smrg -o) 360692f60a7Smrg shift 361692f60a7Smrg ;; 362692f60a7Smrg $object) 363692f60a7Smrg shift 364692f60a7Smrg ;; 365692f60a7Smrg *) 366692f60a7Smrg set fnord "$@" "$arg" 367692f60a7Smrg shift # fnord 368692f60a7Smrg shift # $arg 369692f60a7Smrg ;; 370692f60a7Smrg esac 371692f60a7Smrg done 372692f60a7Smrg 373692f60a7Smrg test -z "$dashmflag" && dashmflag=-M 374692f60a7Smrg # Require at least two characters before searching for `:' 375692f60a7Smrg # in the target name. This is to cope with DOS-style filenames: 376692f60a7Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 377692f60a7Smrg "$@" $dashmflag | 378692f60a7Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 379692f60a7Smrg rm -f "$depfile" 380692f60a7Smrg cat < "$tmpdepfile" > "$depfile" 381692f60a7Smrg tr ' ' ' 382692f60a7Smrg' < "$tmpdepfile" | \ 383692f60a7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 384692f60a7Smrg## correctly. Breaking it into two sed invocations is a workaround. 385692f60a7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 386692f60a7Smrg rm -f "$tmpdepfile" 387692f60a7Smrg ;; 388692f60a7Smrg 389692f60a7SmrgdashXmstdout) 390692f60a7Smrg # This case only exists to satisfy depend.m4. It is never actually 391692f60a7Smrg # run, as this mode is specially recognized in the preamble. 392692f60a7Smrg exit 1 393692f60a7Smrg ;; 394692f60a7Smrg 395692f60a7Smrgmakedepend) 396692f60a7Smrg "$@" || exit $? 397692f60a7Smrg # Remove any Libtool call 398692f60a7Smrg if test "$libtool" = yes; then 399692f60a7Smrg while test $1 != '--mode=compile'; do 400692f60a7Smrg shift 401692f60a7Smrg done 402692f60a7Smrg shift 403692f60a7Smrg fi 404692f60a7Smrg # X makedepend 405692f60a7Smrg shift 406692f60a7Smrg cleared=no 407692f60a7Smrg for arg in "$@"; do 408692f60a7Smrg case $cleared in 409692f60a7Smrg no) 410692f60a7Smrg set ""; shift 411692f60a7Smrg cleared=yes ;; 412692f60a7Smrg esac 413692f60a7Smrg case "$arg" in 414692f60a7Smrg -D*|-I*) 415692f60a7Smrg set fnord "$@" "$arg"; shift ;; 416692f60a7Smrg # Strip any option that makedepend may not understand. Remove 417692f60a7Smrg # the object too, otherwise makedepend will parse it as a source file. 418692f60a7Smrg -*|$object) 419692f60a7Smrg ;; 420692f60a7Smrg *) 421692f60a7Smrg set fnord "$@" "$arg"; shift ;; 422692f60a7Smrg esac 423692f60a7Smrg done 424692f60a7Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 425692f60a7Smrg touch "$tmpdepfile" 426692f60a7Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 427692f60a7Smrg rm -f "$depfile" 428692f60a7Smrg cat < "$tmpdepfile" > "$depfile" 429692f60a7Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 430692f60a7Smrg' | \ 431692f60a7Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 432692f60a7Smrg## correctly. Breaking it into two sed invocations is a workaround. 433692f60a7Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 434692f60a7Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 435692f60a7Smrg ;; 436692f60a7Smrg 437692f60a7Smrgcpp) 438692f60a7Smrg # Important note: in order to support this mode, a compiler *must* 439692f60a7Smrg # always write the preprocessed file to stdout. 440692f60a7Smrg "$@" || exit $? 441692f60a7Smrg 442692f60a7Smrg # Remove the call to Libtool. 443692f60a7Smrg if test "$libtool" = yes; then 444692f60a7Smrg while test $1 != '--mode=compile'; do 445692f60a7Smrg shift 446692f60a7Smrg done 447692f60a7Smrg shift 448692f60a7Smrg fi 449692f60a7Smrg 450692f60a7Smrg # Remove `-o $object'. 451692f60a7Smrg IFS=" " 452692f60a7Smrg for arg 453692f60a7Smrg do 454692f60a7Smrg case $arg in 455692f60a7Smrg -o) 456692f60a7Smrg shift 457692f60a7Smrg ;; 458692f60a7Smrg $object) 459692f60a7Smrg shift 460692f60a7Smrg ;; 461692f60a7Smrg *) 462692f60a7Smrg set fnord "$@" "$arg" 463692f60a7Smrg shift # fnord 464692f60a7Smrg shift # $arg 465692f60a7Smrg ;; 466692f60a7Smrg esac 467692f60a7Smrg done 468692f60a7Smrg 469692f60a7Smrg "$@" -E | 470692f60a7Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 471692f60a7Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 472692f60a7Smrg sed '$ s: \\$::' > "$tmpdepfile" 473692f60a7Smrg rm -f "$depfile" 474692f60a7Smrg echo "$object : \\" > "$depfile" 475692f60a7Smrg cat < "$tmpdepfile" >> "$depfile" 476692f60a7Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 477692f60a7Smrg rm -f "$tmpdepfile" 478692f60a7Smrg ;; 479692f60a7Smrg 480692f60a7Smrgmsvisualcpp) 481692f60a7Smrg # Important note: in order to support this mode, a compiler *must* 482692f60a7Smrg # always write the preprocessed file to stdout, regardless of -o, 483692f60a7Smrg # because we must use -o when running libtool. 484692f60a7Smrg "$@" || exit $? 485692f60a7Smrg IFS=" " 486692f60a7Smrg for arg 487692f60a7Smrg do 488692f60a7Smrg case "$arg" in 489692f60a7Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 490692f60a7Smrg set fnord "$@" 491692f60a7Smrg shift 492692f60a7Smrg shift 493692f60a7Smrg ;; 494692f60a7Smrg *) 495692f60a7Smrg set fnord "$@" "$arg" 496692f60a7Smrg shift 497692f60a7Smrg shift 498692f60a7Smrg ;; 499692f60a7Smrg esac 500692f60a7Smrg done 501692f60a7Smrg "$@" -E | 502692f60a7Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 503692f60a7Smrg rm -f "$depfile" 504692f60a7Smrg echo "$object : \\" > "$depfile" 505692f60a7Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 506692f60a7Smrg echo " " >> "$depfile" 507692f60a7Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 508692f60a7Smrg rm -f "$tmpdepfile" 509692f60a7Smrg ;; 510692f60a7Smrg 511692f60a7Smrgnone) 512692f60a7Smrg exec "$@" 513692f60a7Smrg ;; 514692f60a7Smrg 515692f60a7Smrg*) 516692f60a7Smrg echo "Unknown depmode $depmode" 1>&2 517692f60a7Smrg exit 1 518692f60a7Smrg ;; 519692f60a7Smrgesac 520692f60a7Smrg 521692f60a7Smrgexit 0 522692f60a7Smrg 523692f60a7Smrg# Local Variables: 524692f60a7Smrg# mode: shell-script 525692f60a7Smrg# sh-indentation: 2 526692f60a7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 527692f60a7Smrg# time-stamp-start: "scriptversion=" 528692f60a7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 529692f60a7Smrg# time-stamp-end: "$" 530692f60a7Smrg# End: 531