depcomp revision 209ff23f
1209ff23fSmrg#! /bin/sh 2209ff23fSmrg# depcomp - compile a program generating dependencies as side-effects 3209ff23fSmrg 4209ff23fSmrgscriptversion=2006-10-15.18 5209ff23fSmrg 6209ff23fSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software 7209ff23fSmrg# Foundation, Inc. 8209ff23fSmrg 9209ff23fSmrg# This program is free software; you can redistribute it and/or modify 10209ff23fSmrg# it under the terms of the GNU General Public License as published by 11209ff23fSmrg# the Free Software Foundation; either version 2, or (at your option) 12209ff23fSmrg# any later version. 13209ff23fSmrg 14209ff23fSmrg# This program is distributed in the hope that it will be useful, 15209ff23fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16209ff23fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17209ff23fSmrg# GNU General Public License for more details. 18209ff23fSmrg 19209ff23fSmrg# You should have received a copy of the GNU General Public License 20209ff23fSmrg# along with this program; if not, write to the Free Software 21209ff23fSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22209ff23fSmrg# 02110-1301, USA. 23209ff23fSmrg 24209ff23fSmrg# As a special exception to the GNU General Public License, if you 25209ff23fSmrg# distribute this file as part of a program that contains a 26209ff23fSmrg# configuration script generated by Autoconf, you may include it under 27209ff23fSmrg# the same distribution terms that you use for the rest of that program. 28209ff23fSmrg 29209ff23fSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 30209ff23fSmrg 31209ff23fSmrgcase $1 in 32209ff23fSmrg '') 33209ff23fSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 34209ff23fSmrg exit 1; 35209ff23fSmrg ;; 36209ff23fSmrg -h | --h*) 37209ff23fSmrg cat <<\EOF 38209ff23fSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 39209ff23fSmrg 40209ff23fSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 41209ff23fSmrgas side-effects. 42209ff23fSmrg 43209ff23fSmrgEnvironment variables: 44209ff23fSmrg depmode Dependency tracking mode. 45209ff23fSmrg source Source file read by `PROGRAMS ARGS'. 46209ff23fSmrg object Object file output by `PROGRAMS ARGS'. 47209ff23fSmrg DEPDIR directory where to store dependencies. 48209ff23fSmrg depfile Dependency file to output. 49209ff23fSmrg tmpdepfile Temporary file to use when outputing dependencies. 50209ff23fSmrg libtool Whether libtool is used (yes/no). 51209ff23fSmrg 52209ff23fSmrgReport bugs to <bug-automake@gnu.org>. 53209ff23fSmrgEOF 54209ff23fSmrg exit $? 55209ff23fSmrg ;; 56209ff23fSmrg -v | --v*) 57209ff23fSmrg echo "depcomp $scriptversion" 58209ff23fSmrg exit $? 59209ff23fSmrg ;; 60209ff23fSmrgesac 61209ff23fSmrg 62209ff23fSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 63209ff23fSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 64209ff23fSmrg exit 1 65209ff23fSmrgfi 66209ff23fSmrg 67209ff23fSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 68209ff23fSmrgdepfile=${depfile-`echo "$object" | 69209ff23fSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 70209ff23fSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 71209ff23fSmrg 72209ff23fSmrgrm -f "$tmpdepfile" 73209ff23fSmrg 74209ff23fSmrg# Some modes work just like other modes, but use different flags. We 75209ff23fSmrg# parameterize here, but still list the modes in the big case below, 76209ff23fSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 77209ff23fSmrg# here, because this file can only contain one case statement. 78209ff23fSmrgif test "$depmode" = hp; then 79209ff23fSmrg # HP compiler uses -M and no extra arg. 80209ff23fSmrg gccflag=-M 81209ff23fSmrg depmode=gcc 82209ff23fSmrgfi 83209ff23fSmrg 84209ff23fSmrgif test "$depmode" = dashXmstdout; then 85209ff23fSmrg # This is just like dashmstdout with a different argument. 86209ff23fSmrg dashmflag=-xM 87209ff23fSmrg depmode=dashmstdout 88209ff23fSmrgfi 89209ff23fSmrg 90209ff23fSmrgcase "$depmode" in 91209ff23fSmrggcc3) 92209ff23fSmrg## gcc 3 implements dependency tracking that does exactly what 93209ff23fSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 94209ff23fSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 95209ff23fSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 96209ff23fSmrg## the command line argument order; so add the flags where they 97209ff23fSmrg## appear in depend2.am. Note that the slowdown incurred here 98209ff23fSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 99209ff23fSmrg for arg 100209ff23fSmrg do 101209ff23fSmrg case $arg in 102209ff23fSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 103209ff23fSmrg *) set fnord "$@" "$arg" ;; 104209ff23fSmrg esac 105209ff23fSmrg shift # fnord 106209ff23fSmrg shift # $arg 107209ff23fSmrg done 108209ff23fSmrg "$@" 109209ff23fSmrg stat=$? 110209ff23fSmrg if test $stat -eq 0; then : 111209ff23fSmrg else 112209ff23fSmrg rm -f "$tmpdepfile" 113209ff23fSmrg exit $stat 114209ff23fSmrg fi 115209ff23fSmrg mv "$tmpdepfile" "$depfile" 116209ff23fSmrg ;; 117209ff23fSmrg 118209ff23fSmrggcc) 119209ff23fSmrg## There are various ways to get dependency output from gcc. Here's 120209ff23fSmrg## why we pick this rather obscure method: 121209ff23fSmrg## - Don't want to use -MD because we'd like the dependencies to end 122209ff23fSmrg## up in a subdir. Having to rename by hand is ugly. 123209ff23fSmrg## (We might end up doing this anyway to support other compilers.) 124209ff23fSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 125209ff23fSmrg## -MM, not -M (despite what the docs say). 126209ff23fSmrg## - Using -M directly means running the compiler twice (even worse 127209ff23fSmrg## than renaming). 128209ff23fSmrg if test -z "$gccflag"; then 129209ff23fSmrg gccflag=-MD, 130209ff23fSmrg fi 131209ff23fSmrg "$@" -Wp,"$gccflag$tmpdepfile" 132209ff23fSmrg stat=$? 133209ff23fSmrg if test $stat -eq 0; then : 134209ff23fSmrg else 135209ff23fSmrg rm -f "$tmpdepfile" 136209ff23fSmrg exit $stat 137209ff23fSmrg fi 138209ff23fSmrg rm -f "$depfile" 139209ff23fSmrg echo "$object : \\" > "$depfile" 140209ff23fSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 141209ff23fSmrg## The second -e expression handles DOS-style file names with drive letters. 142209ff23fSmrg sed -e 's/^[^:]*: / /' \ 143209ff23fSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 144209ff23fSmrg## This next piece of magic avoids the `deleted header file' problem. 145209ff23fSmrg## The problem is that when a header file which appears in a .P file 146209ff23fSmrg## is deleted, the dependency causes make to die (because there is 147209ff23fSmrg## typically no way to rebuild the header). We avoid this by adding 148209ff23fSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 149209ff23fSmrg## this for us directly. 150209ff23fSmrg tr ' ' ' 151209ff23fSmrg' < "$tmpdepfile" | 152209ff23fSmrg## Some versions of gcc put a space before the `:'. On the theory 153209ff23fSmrg## that the space means something, we add a space to the output as 154209ff23fSmrg## well. 155209ff23fSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 156209ff23fSmrg## correctly. Breaking it into two sed invocations is a workaround. 157209ff23fSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 158209ff23fSmrg rm -f "$tmpdepfile" 159209ff23fSmrg ;; 160209ff23fSmrg 161209ff23fSmrghp) 162209ff23fSmrg # This case exists only to let depend.m4 do its work. It works by 163209ff23fSmrg # looking at the text of this script. This case will never be run, 164209ff23fSmrg # since it is checked for above. 165209ff23fSmrg exit 1 166209ff23fSmrg ;; 167209ff23fSmrg 168209ff23fSmrgsgi) 169209ff23fSmrg if test "$libtool" = yes; then 170209ff23fSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 171209ff23fSmrg else 172209ff23fSmrg "$@" -MDupdate "$tmpdepfile" 173209ff23fSmrg fi 174209ff23fSmrg stat=$? 175209ff23fSmrg if test $stat -eq 0; then : 176209ff23fSmrg else 177209ff23fSmrg rm -f "$tmpdepfile" 178209ff23fSmrg exit $stat 179209ff23fSmrg fi 180209ff23fSmrg rm -f "$depfile" 181209ff23fSmrg 182209ff23fSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 183209ff23fSmrg echo "$object : \\" > "$depfile" 184209ff23fSmrg 185209ff23fSmrg # Clip off the initial element (the dependent). Don't try to be 186209ff23fSmrg # clever and replace this with sed code, as IRIX sed won't handle 187209ff23fSmrg # lines with more than a fixed number of characters (4096 in 188209ff23fSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 189209ff23fSmrg # the IRIX cc adds comments like `#:fec' to the end of the 190209ff23fSmrg # dependency line. 191209ff23fSmrg tr ' ' ' 192209ff23fSmrg' < "$tmpdepfile" \ 193209ff23fSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 194209ff23fSmrg tr ' 195209ff23fSmrg' ' ' >> $depfile 196209ff23fSmrg echo >> $depfile 197209ff23fSmrg 198209ff23fSmrg # The second pass generates a dummy entry for each header file. 199209ff23fSmrg tr ' ' ' 200209ff23fSmrg' < "$tmpdepfile" \ 201209ff23fSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 202209ff23fSmrg >> $depfile 203209ff23fSmrg else 204209ff23fSmrg # The sourcefile does not contain any dependencies, so just 205209ff23fSmrg # store a dummy comment line, to avoid errors with the Makefile 206209ff23fSmrg # "include basename.Plo" scheme. 207209ff23fSmrg echo "#dummy" > "$depfile" 208209ff23fSmrg fi 209209ff23fSmrg rm -f "$tmpdepfile" 210209ff23fSmrg ;; 211209ff23fSmrg 212209ff23fSmrgaix) 213209ff23fSmrg # The C for AIX Compiler uses -M and outputs the dependencies 214209ff23fSmrg # in a .u file. In older versions, this file always lives in the 215209ff23fSmrg # current directory. Also, the AIX compiler puts `$object:' at the 216209ff23fSmrg # start of each line; $object doesn't have directory information. 217209ff23fSmrg # Version 6 uses the directory in both cases. 218209ff23fSmrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 219209ff23fSmrg tmpdepfile="$stripped.u" 220209ff23fSmrg if test "$libtool" = yes; then 221209ff23fSmrg "$@" -Wc,-M 222209ff23fSmrg else 223209ff23fSmrg "$@" -M 224209ff23fSmrg fi 225209ff23fSmrg stat=$? 226209ff23fSmrg 227209ff23fSmrg if test -f "$tmpdepfile"; then : 228209ff23fSmrg else 229209ff23fSmrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 230209ff23fSmrg tmpdepfile="$stripped.u" 231209ff23fSmrg fi 232209ff23fSmrg 233209ff23fSmrg if test $stat -eq 0; then : 234209ff23fSmrg else 235209ff23fSmrg rm -f "$tmpdepfile" 236209ff23fSmrg exit $stat 237209ff23fSmrg fi 238209ff23fSmrg 239209ff23fSmrg if test -f "$tmpdepfile"; then 240209ff23fSmrg outname="$stripped.o" 241209ff23fSmrg # Each line is of the form `foo.o: dependent.h'. 242209ff23fSmrg # Do two passes, one to just change these to 243209ff23fSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 244209ff23fSmrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 245209ff23fSmrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 246209ff23fSmrg else 247209ff23fSmrg # The sourcefile does not contain any dependencies, so just 248209ff23fSmrg # store a dummy comment line, to avoid errors with the Makefile 249209ff23fSmrg # "include basename.Plo" scheme. 250209ff23fSmrg echo "#dummy" > "$depfile" 251209ff23fSmrg fi 252209ff23fSmrg rm -f "$tmpdepfile" 253209ff23fSmrg ;; 254209ff23fSmrg 255209ff23fSmrgicc) 256209ff23fSmrg # Intel's C compiler understands `-MD -MF file'. However on 257209ff23fSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 258209ff23fSmrg # ICC 7.0 will fill foo.d with something like 259209ff23fSmrg # foo.o: sub/foo.c 260209ff23fSmrg # foo.o: sub/foo.h 261209ff23fSmrg # which is wrong. We want: 262209ff23fSmrg # sub/foo.o: sub/foo.c 263209ff23fSmrg # sub/foo.o: sub/foo.h 264209ff23fSmrg # sub/foo.c: 265209ff23fSmrg # sub/foo.h: 266209ff23fSmrg # ICC 7.1 will output 267209ff23fSmrg # foo.o: sub/foo.c sub/foo.h 268209ff23fSmrg # and will wrap long lines using \ : 269209ff23fSmrg # foo.o: sub/foo.c ... \ 270209ff23fSmrg # sub/foo.h ... \ 271209ff23fSmrg # ... 272209ff23fSmrg 273209ff23fSmrg "$@" -MD -MF "$tmpdepfile" 274209ff23fSmrg stat=$? 275209ff23fSmrg if test $stat -eq 0; then : 276209ff23fSmrg else 277209ff23fSmrg rm -f "$tmpdepfile" 278209ff23fSmrg exit $stat 279209ff23fSmrg fi 280209ff23fSmrg rm -f "$depfile" 281209ff23fSmrg # Each line is of the form `foo.o: dependent.h', 282209ff23fSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 283209ff23fSmrg # Do two passes, one to just change these to 284209ff23fSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 285209ff23fSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 286209ff23fSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 287209ff23fSmrg # correctly. Breaking it into two sed invocations is a workaround. 288209ff23fSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 289209ff23fSmrg sed -e 's/$/ :/' >> "$depfile" 290209ff23fSmrg rm -f "$tmpdepfile" 291209ff23fSmrg ;; 292209ff23fSmrg 293209ff23fSmrghp2) 294209ff23fSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 295209ff23fSmrg # compilers, which have integrated preprocessors. The correct option 296209ff23fSmrg # to use with these is +Maked; it writes dependencies to a file named 297209ff23fSmrg # 'foo.d', which lands next to the object file, wherever that 298209ff23fSmrg # happens to be. 299209ff23fSmrg # Much of this is similar to the tru64 case; see comments there. 300209ff23fSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 301209ff23fSmrg test "x$dir" = "x$object" && dir= 302209ff23fSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 303209ff23fSmrg if test "$libtool" = yes; then 304209ff23fSmrg tmpdepfile1=$dir$base.d 305209ff23fSmrg tmpdepfile2=$dir.libs/$base.d 306209ff23fSmrg "$@" -Wc,+Maked 307209ff23fSmrg else 308209ff23fSmrg tmpdepfile1=$dir$base.d 309209ff23fSmrg tmpdepfile2=$dir$base.d 310209ff23fSmrg "$@" +Maked 311209ff23fSmrg fi 312209ff23fSmrg stat=$? 313209ff23fSmrg if test $stat -eq 0; then : 314209ff23fSmrg else 315209ff23fSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 316209ff23fSmrg exit $stat 317209ff23fSmrg fi 318209ff23fSmrg 319209ff23fSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 320209ff23fSmrg do 321209ff23fSmrg test -f "$tmpdepfile" && break 322209ff23fSmrg done 323209ff23fSmrg if test -f "$tmpdepfile"; then 324209ff23fSmrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 325209ff23fSmrg # Add `dependent.h:' lines. 326209ff23fSmrg sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 327209ff23fSmrg else 328209ff23fSmrg echo "#dummy" > "$depfile" 329209ff23fSmrg fi 330209ff23fSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 331209ff23fSmrg ;; 332209ff23fSmrg 333209ff23fSmrgtru64) 334209ff23fSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 335209ff23fSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 336209ff23fSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 337209ff23fSmrg # dependencies in `foo.d' instead, so we check for that too. 338209ff23fSmrg # Subdirectories are respected. 339209ff23fSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 340209ff23fSmrg test "x$dir" = "x$object" && dir= 341209ff23fSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 342209ff23fSmrg 343209ff23fSmrg if test "$libtool" = yes; then 344209ff23fSmrg # With Tru64 cc, shared objects can also be used to make a 345209ff23fSmrg # static library. This mechanism is used in libtool 1.4 series to 346209ff23fSmrg # handle both shared and static libraries in a single compilation. 347209ff23fSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 348209ff23fSmrg # 349209ff23fSmrg # With libtool 1.5 this exception was removed, and libtool now 350209ff23fSmrg # generates 2 separate objects for the 2 libraries. These two 351209ff23fSmrg # compilations output dependencies in $dir.libs/$base.o.d and 352209ff23fSmrg # in $dir$base.o.d. We have to check for both files, because 353209ff23fSmrg # one of the two compilations can be disabled. We should prefer 354209ff23fSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 355209ff23fSmrg # automatically cleaned when .libs/ is deleted, while ignoring 356209ff23fSmrg # the former would cause a distcleancheck panic. 357209ff23fSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 358209ff23fSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 359209ff23fSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 360209ff23fSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 361209ff23fSmrg "$@" -Wc,-MD 362209ff23fSmrg else 363209ff23fSmrg tmpdepfile1=$dir$base.o.d 364209ff23fSmrg tmpdepfile2=$dir$base.d 365209ff23fSmrg tmpdepfile3=$dir$base.d 366209ff23fSmrg tmpdepfile4=$dir$base.d 367209ff23fSmrg "$@" -MD 368209ff23fSmrg fi 369209ff23fSmrg 370209ff23fSmrg stat=$? 371209ff23fSmrg if test $stat -eq 0; then : 372209ff23fSmrg else 373209ff23fSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 374209ff23fSmrg exit $stat 375209ff23fSmrg fi 376209ff23fSmrg 377209ff23fSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 378209ff23fSmrg do 379209ff23fSmrg test -f "$tmpdepfile" && break 380209ff23fSmrg done 381209ff23fSmrg if test -f "$tmpdepfile"; then 382209ff23fSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 383209ff23fSmrg # That's a tab and a space in the []. 384209ff23fSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 385209ff23fSmrg else 386209ff23fSmrg echo "#dummy" > "$depfile" 387209ff23fSmrg fi 388209ff23fSmrg rm -f "$tmpdepfile" 389209ff23fSmrg ;; 390209ff23fSmrg 391209ff23fSmrg#nosideeffect) 392209ff23fSmrg # This comment above is used by automake to tell side-effect 393209ff23fSmrg # dependency tracking mechanisms from slower ones. 394209ff23fSmrg 395209ff23fSmrgdashmstdout) 396209ff23fSmrg # Important note: in order to support this mode, a compiler *must* 397209ff23fSmrg # always write the preprocessed file to stdout, regardless of -o. 398209ff23fSmrg "$@" || exit $? 399209ff23fSmrg 400209ff23fSmrg # Remove the call to Libtool. 401209ff23fSmrg if test "$libtool" = yes; then 402209ff23fSmrg while test $1 != '--mode=compile'; do 403209ff23fSmrg shift 404209ff23fSmrg done 405209ff23fSmrg shift 406209ff23fSmrg fi 407209ff23fSmrg 408209ff23fSmrg # Remove `-o $object'. 409209ff23fSmrg IFS=" " 410209ff23fSmrg for arg 411209ff23fSmrg do 412209ff23fSmrg case $arg in 413209ff23fSmrg -o) 414209ff23fSmrg shift 415209ff23fSmrg ;; 416209ff23fSmrg $object) 417209ff23fSmrg shift 418209ff23fSmrg ;; 419209ff23fSmrg *) 420209ff23fSmrg set fnord "$@" "$arg" 421209ff23fSmrg shift # fnord 422209ff23fSmrg shift # $arg 423209ff23fSmrg ;; 424209ff23fSmrg esac 425209ff23fSmrg done 426209ff23fSmrg 427209ff23fSmrg test -z "$dashmflag" && dashmflag=-M 428209ff23fSmrg # Require at least two characters before searching for `:' 429209ff23fSmrg # in the target name. This is to cope with DOS-style filenames: 430209ff23fSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 431209ff23fSmrg "$@" $dashmflag | 432209ff23fSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 433209ff23fSmrg rm -f "$depfile" 434209ff23fSmrg cat < "$tmpdepfile" > "$depfile" 435209ff23fSmrg tr ' ' ' 436209ff23fSmrg' < "$tmpdepfile" | \ 437209ff23fSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 438209ff23fSmrg## correctly. Breaking it into two sed invocations is a workaround. 439209ff23fSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 440209ff23fSmrg rm -f "$tmpdepfile" 441209ff23fSmrg ;; 442209ff23fSmrg 443209ff23fSmrgdashXmstdout) 444209ff23fSmrg # This case only exists to satisfy depend.m4. It is never actually 445209ff23fSmrg # run, as this mode is specially recognized in the preamble. 446209ff23fSmrg exit 1 447209ff23fSmrg ;; 448209ff23fSmrg 449209ff23fSmrgmakedepend) 450209ff23fSmrg "$@" || exit $? 451209ff23fSmrg # Remove any Libtool call 452209ff23fSmrg if test "$libtool" = yes; then 453209ff23fSmrg while test $1 != '--mode=compile'; do 454209ff23fSmrg shift 455209ff23fSmrg done 456209ff23fSmrg shift 457209ff23fSmrg fi 458209ff23fSmrg # X makedepend 459209ff23fSmrg shift 460209ff23fSmrg cleared=no 461209ff23fSmrg for arg in "$@"; do 462209ff23fSmrg case $cleared in 463209ff23fSmrg no) 464209ff23fSmrg set ""; shift 465209ff23fSmrg cleared=yes ;; 466209ff23fSmrg esac 467209ff23fSmrg case "$arg" in 468209ff23fSmrg -D*|-I*) 469209ff23fSmrg set fnord "$@" "$arg"; shift ;; 470209ff23fSmrg # Strip any option that makedepend may not understand. Remove 471209ff23fSmrg # the object too, otherwise makedepend will parse it as a source file. 472209ff23fSmrg -*|$object) 473209ff23fSmrg ;; 474209ff23fSmrg *) 475209ff23fSmrg set fnord "$@" "$arg"; shift ;; 476209ff23fSmrg esac 477209ff23fSmrg done 478209ff23fSmrg obj_suffix="`echo $object | sed 's/^.*\././'`" 479209ff23fSmrg touch "$tmpdepfile" 480209ff23fSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 481209ff23fSmrg rm -f "$depfile" 482209ff23fSmrg cat < "$tmpdepfile" > "$depfile" 483209ff23fSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 484209ff23fSmrg' | \ 485209ff23fSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 486209ff23fSmrg## correctly. Breaking it into two sed invocations is a workaround. 487209ff23fSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 488209ff23fSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 489209ff23fSmrg ;; 490209ff23fSmrg 491209ff23fSmrgcpp) 492209ff23fSmrg # Important note: in order to support this mode, a compiler *must* 493209ff23fSmrg # always write the preprocessed file to stdout. 494209ff23fSmrg "$@" || exit $? 495209ff23fSmrg 496209ff23fSmrg # Remove the call to Libtool. 497209ff23fSmrg if test "$libtool" = yes; then 498209ff23fSmrg while test $1 != '--mode=compile'; do 499209ff23fSmrg shift 500209ff23fSmrg done 501209ff23fSmrg shift 502209ff23fSmrg fi 503209ff23fSmrg 504209ff23fSmrg # Remove `-o $object'. 505209ff23fSmrg IFS=" " 506209ff23fSmrg for arg 507209ff23fSmrg do 508209ff23fSmrg case $arg in 509209ff23fSmrg -o) 510209ff23fSmrg shift 511209ff23fSmrg ;; 512209ff23fSmrg $object) 513209ff23fSmrg shift 514209ff23fSmrg ;; 515209ff23fSmrg *) 516209ff23fSmrg set fnord "$@" "$arg" 517209ff23fSmrg shift # fnord 518209ff23fSmrg shift # $arg 519209ff23fSmrg ;; 520209ff23fSmrg esac 521209ff23fSmrg done 522209ff23fSmrg 523209ff23fSmrg "$@" -E | 524209ff23fSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 525209ff23fSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 526209ff23fSmrg sed '$ s: \\$::' > "$tmpdepfile" 527209ff23fSmrg rm -f "$depfile" 528209ff23fSmrg echo "$object : \\" > "$depfile" 529209ff23fSmrg cat < "$tmpdepfile" >> "$depfile" 530209ff23fSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 531209ff23fSmrg rm -f "$tmpdepfile" 532209ff23fSmrg ;; 533209ff23fSmrg 534209ff23fSmrgmsvisualcpp) 535209ff23fSmrg # Important note: in order to support this mode, a compiler *must* 536209ff23fSmrg # always write the preprocessed file to stdout, regardless of -o, 537209ff23fSmrg # because we must use -o when running libtool. 538209ff23fSmrg "$@" || exit $? 539209ff23fSmrg IFS=" " 540209ff23fSmrg for arg 541209ff23fSmrg do 542209ff23fSmrg case "$arg" in 543209ff23fSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 544209ff23fSmrg set fnord "$@" 545209ff23fSmrg shift 546209ff23fSmrg shift 547209ff23fSmrg ;; 548209ff23fSmrg *) 549209ff23fSmrg set fnord "$@" "$arg" 550209ff23fSmrg shift 551209ff23fSmrg shift 552209ff23fSmrg ;; 553209ff23fSmrg esac 554209ff23fSmrg done 555209ff23fSmrg "$@" -E | 556209ff23fSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 557209ff23fSmrg rm -f "$depfile" 558209ff23fSmrg echo "$object : \\" > "$depfile" 559209ff23fSmrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 560209ff23fSmrg echo " " >> "$depfile" 561209ff23fSmrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 562209ff23fSmrg rm -f "$tmpdepfile" 563209ff23fSmrg ;; 564209ff23fSmrg 565209ff23fSmrgnone) 566209ff23fSmrg exec "$@" 567209ff23fSmrg ;; 568209ff23fSmrg 569209ff23fSmrg*) 570209ff23fSmrg echo "Unknown depmode $depmode" 1>&2 571209ff23fSmrg exit 1 572209ff23fSmrg ;; 573209ff23fSmrgesac 574209ff23fSmrg 575209ff23fSmrgexit 0 576209ff23fSmrg 577209ff23fSmrg# Local Variables: 578209ff23fSmrg# mode: shell-script 579209ff23fSmrg# sh-indentation: 2 580209ff23fSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 581209ff23fSmrg# time-stamp-start: "scriptversion=" 582209ff23fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 583209ff23fSmrg# time-stamp-end: "$" 584209ff23fSmrg# End: 585