depcomp revision 10998002
1ff7e0accSmrg#! /bin/sh 2ff7e0accSmrg# depcomp - compile a program generating dependencies as side-effects 3ff7e0accSmrg 410998002Smrgscriptversion=2009-04-28.21; # UTC 5ff7e0accSmrg 610998002Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 710998002Smrg# Software Foundation, Inc. 8ff7e0accSmrg 9ff7e0accSmrg# This program is free software; you can redistribute it and/or modify 10ff7e0accSmrg# it under the terms of the GNU General Public License as published by 11ff7e0accSmrg# the Free Software Foundation; either version 2, or (at your option) 12ff7e0accSmrg# any later version. 13ff7e0accSmrg 14ff7e0accSmrg# This program is distributed in the hope that it will be useful, 15ff7e0accSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16ff7e0accSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17ff7e0accSmrg# GNU General Public License for more details. 18ff7e0accSmrg 19ff7e0accSmrg# You should have received a copy of the GNU General Public License 2010998002Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21ff7e0accSmrg 22ff7e0accSmrg# As a special exception to the GNU General Public License, if you 23ff7e0accSmrg# distribute this file as part of a program that contains a 24ff7e0accSmrg# configuration script generated by Autoconf, you may include it under 25ff7e0accSmrg# the same distribution terms that you use for the rest of that program. 26ff7e0accSmrg 27ff7e0accSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28ff7e0accSmrg 29ff7e0accSmrgcase $1 in 30ff7e0accSmrg '') 31ff7e0accSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32ff7e0accSmrg exit 1; 33ff7e0accSmrg ;; 34ff7e0accSmrg -h | --h*) 35ff7e0accSmrg cat <<\EOF 36ff7e0accSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37ff7e0accSmrg 38ff7e0accSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39ff7e0accSmrgas side-effects. 40ff7e0accSmrg 41ff7e0accSmrgEnvironment variables: 42ff7e0accSmrg depmode Dependency tracking mode. 43ff7e0accSmrg source Source file read by `PROGRAMS ARGS'. 44ff7e0accSmrg object Object file output by `PROGRAMS ARGS'. 45ff7e0accSmrg DEPDIR directory where to store dependencies. 46ff7e0accSmrg depfile Dependency file to output. 47ff7e0accSmrg tmpdepfile Temporary file to use when outputing dependencies. 48ff7e0accSmrg libtool Whether libtool is used (yes/no). 49ff7e0accSmrg 50ff7e0accSmrgReport bugs to <bug-automake@gnu.org>. 51ff7e0accSmrgEOF 52ff7e0accSmrg exit $? 53ff7e0accSmrg ;; 54ff7e0accSmrg -v | --v*) 55ff7e0accSmrg echo "depcomp $scriptversion" 56ff7e0accSmrg exit $? 57ff7e0accSmrg ;; 58ff7e0accSmrgesac 59ff7e0accSmrg 60ff7e0accSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61ff7e0accSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62ff7e0accSmrg exit 1 63ff7e0accSmrgfi 64ff7e0accSmrg 65ff7e0accSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66ff7e0accSmrgdepfile=${depfile-`echo "$object" | 67ff7e0accSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68ff7e0accSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69ff7e0accSmrg 70ff7e0accSmrgrm -f "$tmpdepfile" 71ff7e0accSmrg 72ff7e0accSmrg# Some modes work just like other modes, but use different flags. We 73ff7e0accSmrg# parameterize here, but still list the modes in the big case below, 74ff7e0accSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75ff7e0accSmrg# here, because this file can only contain one case statement. 76ff7e0accSmrgif test "$depmode" = hp; then 77ff7e0accSmrg # HP compiler uses -M and no extra arg. 78ff7e0accSmrg gccflag=-M 79ff7e0accSmrg depmode=gcc 80ff7e0accSmrgfi 81ff7e0accSmrg 82ff7e0accSmrgif test "$depmode" = dashXmstdout; then 83ff7e0accSmrg # This is just like dashmstdout with a different argument. 84ff7e0accSmrg dashmflag=-xM 85ff7e0accSmrg depmode=dashmstdout 86ff7e0accSmrgfi 87ff7e0accSmrg 8810998002Smrgcygpath_u="cygpath -u -f -" 8910998002Smrgif test "$depmode" = msvcmsys; then 9010998002Smrg # This is just like msvisualcpp but w/o cygpath translation. 9110998002Smrg # Just convert the backslash-escaped backslashes to single forward 9210998002Smrg # slashes to satisfy depend.m4 9310998002Smrg cygpath_u="sed s,\\\\\\\\,/,g" 9410998002Smrg depmode=msvisualcpp 9510998002Smrgfi 9610998002Smrg 97ff7e0accSmrgcase "$depmode" in 98ff7e0accSmrggcc3) 99ff7e0accSmrg## gcc 3 implements dependency tracking that does exactly what 100ff7e0accSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101ff7e0accSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 102ff7e0accSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103ff7e0accSmrg## the command line argument order; so add the flags where they 104ff7e0accSmrg## appear in depend2.am. Note that the slowdown incurred here 105ff7e0accSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106ff7e0accSmrg for arg 107ff7e0accSmrg do 108ff7e0accSmrg case $arg in 109ff7e0accSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110ff7e0accSmrg *) set fnord "$@" "$arg" ;; 111ff7e0accSmrg esac 112ff7e0accSmrg shift # fnord 113ff7e0accSmrg shift # $arg 114ff7e0accSmrg done 115ff7e0accSmrg "$@" 116ff7e0accSmrg stat=$? 117ff7e0accSmrg if test $stat -eq 0; then : 118ff7e0accSmrg else 119ff7e0accSmrg rm -f "$tmpdepfile" 120ff7e0accSmrg exit $stat 121ff7e0accSmrg fi 122ff7e0accSmrg mv "$tmpdepfile" "$depfile" 123ff7e0accSmrg ;; 124ff7e0accSmrg 125ff7e0accSmrggcc) 126ff7e0accSmrg## There are various ways to get dependency output from gcc. Here's 127ff7e0accSmrg## why we pick this rather obscure method: 128ff7e0accSmrg## - Don't want to use -MD because we'd like the dependencies to end 129ff7e0accSmrg## up in a subdir. Having to rename by hand is ugly. 130ff7e0accSmrg## (We might end up doing this anyway to support other compilers.) 131ff7e0accSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132ff7e0accSmrg## -MM, not -M (despite what the docs say). 133ff7e0accSmrg## - Using -M directly means running the compiler twice (even worse 134ff7e0accSmrg## than renaming). 135ff7e0accSmrg if test -z "$gccflag"; then 136ff7e0accSmrg gccflag=-MD, 137ff7e0accSmrg fi 138ff7e0accSmrg "$@" -Wp,"$gccflag$tmpdepfile" 139ff7e0accSmrg stat=$? 140ff7e0accSmrg if test $stat -eq 0; then : 141ff7e0accSmrg else 142ff7e0accSmrg rm -f "$tmpdepfile" 143ff7e0accSmrg exit $stat 144ff7e0accSmrg fi 145ff7e0accSmrg rm -f "$depfile" 146ff7e0accSmrg echo "$object : \\" > "$depfile" 147ff7e0accSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148ff7e0accSmrg## The second -e expression handles DOS-style file names with drive letters. 149ff7e0accSmrg sed -e 's/^[^:]*: / /' \ 150ff7e0accSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151ff7e0accSmrg## This next piece of magic avoids the `deleted header file' problem. 152ff7e0accSmrg## The problem is that when a header file which appears in a .P file 153ff7e0accSmrg## is deleted, the dependency causes make to die (because there is 154ff7e0accSmrg## typically no way to rebuild the header). We avoid this by adding 155ff7e0accSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 156ff7e0accSmrg## this for us directly. 157ff7e0accSmrg tr ' ' ' 158ff7e0accSmrg' < "$tmpdepfile" | 159ff7e0accSmrg## Some versions of gcc put a space before the `:'. On the theory 160ff7e0accSmrg## that the space means something, we add a space to the output as 161ff7e0accSmrg## well. 162ff7e0accSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 163ff7e0accSmrg## correctly. Breaking it into two sed invocations is a workaround. 164ff7e0accSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165ff7e0accSmrg rm -f "$tmpdepfile" 166ff7e0accSmrg ;; 167ff7e0accSmrg 168ff7e0accSmrghp) 169ff7e0accSmrg # This case exists only to let depend.m4 do its work. It works by 170ff7e0accSmrg # looking at the text of this script. This case will never be run, 171ff7e0accSmrg # since it is checked for above. 172ff7e0accSmrg exit 1 173ff7e0accSmrg ;; 174ff7e0accSmrg 175ff7e0accSmrgsgi) 176ff7e0accSmrg if test "$libtool" = yes; then 177ff7e0accSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 178ff7e0accSmrg else 179ff7e0accSmrg "$@" -MDupdate "$tmpdepfile" 180ff7e0accSmrg fi 181ff7e0accSmrg stat=$? 182ff7e0accSmrg if test $stat -eq 0; then : 183ff7e0accSmrg else 184ff7e0accSmrg rm -f "$tmpdepfile" 185ff7e0accSmrg exit $stat 186ff7e0accSmrg fi 187ff7e0accSmrg rm -f "$depfile" 188ff7e0accSmrg 189ff7e0accSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190ff7e0accSmrg echo "$object : \\" > "$depfile" 191ff7e0accSmrg 192ff7e0accSmrg # Clip off the initial element (the dependent). Don't try to be 193ff7e0accSmrg # clever and replace this with sed code, as IRIX sed won't handle 194ff7e0accSmrg # lines with more than a fixed number of characters (4096 in 195ff7e0accSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196ff7e0accSmrg # the IRIX cc adds comments like `#:fec' to the end of the 197ff7e0accSmrg # dependency line. 198ff7e0accSmrg tr ' ' ' 199ff7e0accSmrg' < "$tmpdepfile" \ 200ff7e0accSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201ff7e0accSmrg tr ' 20210998002Smrg' ' ' >> "$depfile" 20310998002Smrg echo >> "$depfile" 204ff7e0accSmrg 205ff7e0accSmrg # The second pass generates a dummy entry for each header file. 206ff7e0accSmrg tr ' ' ' 207ff7e0accSmrg' < "$tmpdepfile" \ 208ff7e0accSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 20910998002Smrg >> "$depfile" 210ff7e0accSmrg else 211ff7e0accSmrg # The sourcefile does not contain any dependencies, so just 212ff7e0accSmrg # store a dummy comment line, to avoid errors with the Makefile 213ff7e0accSmrg # "include basename.Plo" scheme. 214ff7e0accSmrg echo "#dummy" > "$depfile" 215ff7e0accSmrg fi 216ff7e0accSmrg rm -f "$tmpdepfile" 217ff7e0accSmrg ;; 218ff7e0accSmrg 219ff7e0accSmrgaix) 220ff7e0accSmrg # The C for AIX Compiler uses -M and outputs the dependencies 221ff7e0accSmrg # in a .u file. In older versions, this file always lives in the 222ff7e0accSmrg # current directory. Also, the AIX compiler puts `$object:' at the 223ff7e0accSmrg # start of each line; $object doesn't have directory information. 224ff7e0accSmrg # Version 6 uses the directory in both cases. 225a005d216Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226a005d216Smrg test "x$dir" = "x$object" && dir= 227a005d216Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228ff7e0accSmrg if test "$libtool" = yes; then 229a005d216Smrg tmpdepfile1=$dir$base.u 230a005d216Smrg tmpdepfile2=$base.u 231a005d216Smrg tmpdepfile3=$dir.libs/$base.u 232ff7e0accSmrg "$@" -Wc,-M 233ff7e0accSmrg else 234a005d216Smrg tmpdepfile1=$dir$base.u 235a005d216Smrg tmpdepfile2=$dir$base.u 236a005d216Smrg tmpdepfile3=$dir$base.u 237ff7e0accSmrg "$@" -M 238ff7e0accSmrg fi 239ff7e0accSmrg stat=$? 240ff7e0accSmrg 241ff7e0accSmrg if test $stat -eq 0; then : 242ff7e0accSmrg else 243a005d216Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244ff7e0accSmrg exit $stat 245ff7e0accSmrg fi 246ff7e0accSmrg 247a005d216Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248a005d216Smrg do 249a005d216Smrg test -f "$tmpdepfile" && break 250a005d216Smrg done 251ff7e0accSmrg if test -f "$tmpdepfile"; then 252ff7e0accSmrg # Each line is of the form `foo.o: dependent.h'. 253ff7e0accSmrg # Do two passes, one to just change these to 254ff7e0accSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 255a005d216Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256a005d216Smrg # That's a tab and a space in the []. 257a005d216Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258ff7e0accSmrg else 259ff7e0accSmrg # The sourcefile does not contain any dependencies, so just 260ff7e0accSmrg # store a dummy comment line, to avoid errors with the Makefile 261ff7e0accSmrg # "include basename.Plo" scheme. 262ff7e0accSmrg echo "#dummy" > "$depfile" 263ff7e0accSmrg fi 264ff7e0accSmrg rm -f "$tmpdepfile" 265ff7e0accSmrg ;; 266ff7e0accSmrg 267ff7e0accSmrgicc) 268ff7e0accSmrg # Intel's C compiler understands `-MD -MF file'. However on 269ff7e0accSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270ff7e0accSmrg # ICC 7.0 will fill foo.d with something like 271ff7e0accSmrg # foo.o: sub/foo.c 272ff7e0accSmrg # foo.o: sub/foo.h 273ff7e0accSmrg # which is wrong. We want: 274ff7e0accSmrg # sub/foo.o: sub/foo.c 275ff7e0accSmrg # sub/foo.o: sub/foo.h 276ff7e0accSmrg # sub/foo.c: 277ff7e0accSmrg # sub/foo.h: 278ff7e0accSmrg # ICC 7.1 will output 279ff7e0accSmrg # foo.o: sub/foo.c sub/foo.h 280ff7e0accSmrg # and will wrap long lines using \ : 281ff7e0accSmrg # foo.o: sub/foo.c ... \ 282ff7e0accSmrg # sub/foo.h ... \ 283ff7e0accSmrg # ... 284ff7e0accSmrg 285ff7e0accSmrg "$@" -MD -MF "$tmpdepfile" 286ff7e0accSmrg stat=$? 287ff7e0accSmrg if test $stat -eq 0; then : 288ff7e0accSmrg else 289ff7e0accSmrg rm -f "$tmpdepfile" 290ff7e0accSmrg exit $stat 291ff7e0accSmrg fi 292ff7e0accSmrg rm -f "$depfile" 293ff7e0accSmrg # Each line is of the form `foo.o: dependent.h', 294ff7e0accSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295ff7e0accSmrg # Do two passes, one to just change these to 296ff7e0accSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 297ff7e0accSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298ff7e0accSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 299ff7e0accSmrg # correctly. Breaking it into two sed invocations is a workaround. 300ff7e0accSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301ff7e0accSmrg sed -e 's/$/ :/' >> "$depfile" 302ff7e0accSmrg rm -f "$tmpdepfile" 303ff7e0accSmrg ;; 304ff7e0accSmrg 305ff7e0accSmrghp2) 306ff7e0accSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307ff7e0accSmrg # compilers, which have integrated preprocessors. The correct option 308ff7e0accSmrg # to use with these is +Maked; it writes dependencies to a file named 309ff7e0accSmrg # 'foo.d', which lands next to the object file, wherever that 310ff7e0accSmrg # happens to be. 311ff7e0accSmrg # Much of this is similar to the tru64 case; see comments there. 312ff7e0accSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313ff7e0accSmrg test "x$dir" = "x$object" && dir= 314ff7e0accSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315ff7e0accSmrg if test "$libtool" = yes; then 316ff7e0accSmrg tmpdepfile1=$dir$base.d 317ff7e0accSmrg tmpdepfile2=$dir.libs/$base.d 318ff7e0accSmrg "$@" -Wc,+Maked 319ff7e0accSmrg else 320ff7e0accSmrg tmpdepfile1=$dir$base.d 321ff7e0accSmrg tmpdepfile2=$dir$base.d 322ff7e0accSmrg "$@" +Maked 323ff7e0accSmrg fi 324ff7e0accSmrg stat=$? 325ff7e0accSmrg if test $stat -eq 0; then : 326ff7e0accSmrg else 327ff7e0accSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 328ff7e0accSmrg exit $stat 329ff7e0accSmrg fi 330ff7e0accSmrg 331ff7e0accSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332ff7e0accSmrg do 333ff7e0accSmrg test -f "$tmpdepfile" && break 334ff7e0accSmrg done 335ff7e0accSmrg if test -f "$tmpdepfile"; then 336ff7e0accSmrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337ff7e0accSmrg # Add `dependent.h:' lines. 33810998002Smrg sed -ne '2,${ 33910998002Smrg s/^ *// 34010998002Smrg s/ \\*$// 34110998002Smrg s/$/:/ 34210998002Smrg p 34310998002Smrg }' "$tmpdepfile" >> "$depfile" 344ff7e0accSmrg else 345ff7e0accSmrg echo "#dummy" > "$depfile" 346ff7e0accSmrg fi 347ff7e0accSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 348ff7e0accSmrg ;; 349ff7e0accSmrg 350ff7e0accSmrgtru64) 351ff7e0accSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 352ff7e0accSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353ff7e0accSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354ff7e0accSmrg # dependencies in `foo.d' instead, so we check for that too. 355ff7e0accSmrg # Subdirectories are respected. 356ff7e0accSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357ff7e0accSmrg test "x$dir" = "x$object" && dir= 358ff7e0accSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359ff7e0accSmrg 360ff7e0accSmrg if test "$libtool" = yes; then 361ff7e0accSmrg # With Tru64 cc, shared objects can also be used to make a 362ff7e0accSmrg # static library. This mechanism is used in libtool 1.4 series to 363ff7e0accSmrg # handle both shared and static libraries in a single compilation. 364ff7e0accSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365ff7e0accSmrg # 366ff7e0accSmrg # With libtool 1.5 this exception was removed, and libtool now 367ff7e0accSmrg # generates 2 separate objects for the 2 libraries. These two 368ff7e0accSmrg # compilations output dependencies in $dir.libs/$base.o.d and 369ff7e0accSmrg # in $dir$base.o.d. We have to check for both files, because 370ff7e0accSmrg # one of the two compilations can be disabled. We should prefer 371ff7e0accSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372ff7e0accSmrg # automatically cleaned when .libs/ is deleted, while ignoring 373ff7e0accSmrg # the former would cause a distcleancheck panic. 374ff7e0accSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375ff7e0accSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 376ff7e0accSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377ff7e0accSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378ff7e0accSmrg "$@" -Wc,-MD 379ff7e0accSmrg else 380ff7e0accSmrg tmpdepfile1=$dir$base.o.d 381ff7e0accSmrg tmpdepfile2=$dir$base.d 382ff7e0accSmrg tmpdepfile3=$dir$base.d 383ff7e0accSmrg tmpdepfile4=$dir$base.d 384ff7e0accSmrg "$@" -MD 385ff7e0accSmrg fi 386ff7e0accSmrg 387ff7e0accSmrg stat=$? 388ff7e0accSmrg if test $stat -eq 0; then : 389ff7e0accSmrg else 390ff7e0accSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391ff7e0accSmrg exit $stat 392ff7e0accSmrg fi 393ff7e0accSmrg 394ff7e0accSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395ff7e0accSmrg do 396ff7e0accSmrg test -f "$tmpdepfile" && break 397ff7e0accSmrg done 398ff7e0accSmrg if test -f "$tmpdepfile"; then 399ff7e0accSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400ff7e0accSmrg # That's a tab and a space in the []. 401ff7e0accSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402ff7e0accSmrg else 403ff7e0accSmrg echo "#dummy" > "$depfile" 404ff7e0accSmrg fi 405ff7e0accSmrg rm -f "$tmpdepfile" 406ff7e0accSmrg ;; 407ff7e0accSmrg 408ff7e0accSmrg#nosideeffect) 409ff7e0accSmrg # This comment above is used by automake to tell side-effect 410ff7e0accSmrg # dependency tracking mechanisms from slower ones. 411ff7e0accSmrg 412ff7e0accSmrgdashmstdout) 413ff7e0accSmrg # Important note: in order to support this mode, a compiler *must* 414ff7e0accSmrg # always write the preprocessed file to stdout, regardless of -o. 415ff7e0accSmrg "$@" || exit $? 416ff7e0accSmrg 417ff7e0accSmrg # Remove the call to Libtool. 418ff7e0accSmrg if test "$libtool" = yes; then 41910998002Smrg while test "X$1" != 'X--mode=compile'; do 420ff7e0accSmrg shift 421ff7e0accSmrg done 422ff7e0accSmrg shift 423ff7e0accSmrg fi 424ff7e0accSmrg 425ff7e0accSmrg # Remove `-o $object'. 426ff7e0accSmrg IFS=" " 427ff7e0accSmrg for arg 428ff7e0accSmrg do 429ff7e0accSmrg case $arg in 430ff7e0accSmrg -o) 431ff7e0accSmrg shift 432ff7e0accSmrg ;; 433ff7e0accSmrg $object) 434ff7e0accSmrg shift 435ff7e0accSmrg ;; 436ff7e0accSmrg *) 437ff7e0accSmrg set fnord "$@" "$arg" 438ff7e0accSmrg shift # fnord 439ff7e0accSmrg shift # $arg 440ff7e0accSmrg ;; 441ff7e0accSmrg esac 442ff7e0accSmrg done 443ff7e0accSmrg 444ff7e0accSmrg test -z "$dashmflag" && dashmflag=-M 445ff7e0accSmrg # Require at least two characters before searching for `:' 446ff7e0accSmrg # in the target name. This is to cope with DOS-style filenames: 447ff7e0accSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448ff7e0accSmrg "$@" $dashmflag | 449ff7e0accSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450ff7e0accSmrg rm -f "$depfile" 451ff7e0accSmrg cat < "$tmpdepfile" > "$depfile" 452ff7e0accSmrg tr ' ' ' 453ff7e0accSmrg' < "$tmpdepfile" | \ 454ff7e0accSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 455ff7e0accSmrg## correctly. Breaking it into two sed invocations is a workaround. 456ff7e0accSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457ff7e0accSmrg rm -f "$tmpdepfile" 458ff7e0accSmrg ;; 459ff7e0accSmrg 460ff7e0accSmrgdashXmstdout) 461ff7e0accSmrg # This case only exists to satisfy depend.m4. It is never actually 462ff7e0accSmrg # run, as this mode is specially recognized in the preamble. 463ff7e0accSmrg exit 1 464ff7e0accSmrg ;; 465ff7e0accSmrg 466ff7e0accSmrgmakedepend) 467ff7e0accSmrg "$@" || exit $? 468ff7e0accSmrg # Remove any Libtool call 469ff7e0accSmrg if test "$libtool" = yes; then 47010998002Smrg while test "X$1" != 'X--mode=compile'; do 471ff7e0accSmrg shift 472ff7e0accSmrg done 473ff7e0accSmrg shift 474ff7e0accSmrg fi 475ff7e0accSmrg # X makedepend 476ff7e0accSmrg shift 47710998002Smrg cleared=no eat=no 47810998002Smrg for arg 47910998002Smrg do 480ff7e0accSmrg case $cleared in 481ff7e0accSmrg no) 482ff7e0accSmrg set ""; shift 483ff7e0accSmrg cleared=yes ;; 484ff7e0accSmrg esac 48510998002Smrg if test $eat = yes; then 48610998002Smrg eat=no 48710998002Smrg continue 48810998002Smrg fi 489ff7e0accSmrg case "$arg" in 490ff7e0accSmrg -D*|-I*) 491ff7e0accSmrg set fnord "$@" "$arg"; shift ;; 492ff7e0accSmrg # Strip any option that makedepend may not understand. Remove 493ff7e0accSmrg # the object too, otherwise makedepend will parse it as a source file. 49410998002Smrg -arch) 49510998002Smrg eat=yes ;; 496ff7e0accSmrg -*|$object) 497ff7e0accSmrg ;; 498ff7e0accSmrg *) 499ff7e0accSmrg set fnord "$@" "$arg"; shift ;; 500ff7e0accSmrg esac 501ff7e0accSmrg done 50210998002Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 503ff7e0accSmrg touch "$tmpdepfile" 504ff7e0accSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505ff7e0accSmrg rm -f "$depfile" 506ff7e0accSmrg cat < "$tmpdepfile" > "$depfile" 507ff7e0accSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 508ff7e0accSmrg' | \ 509ff7e0accSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 510ff7e0accSmrg## correctly. Breaking it into two sed invocations is a workaround. 511ff7e0accSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512ff7e0accSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 513ff7e0accSmrg ;; 514ff7e0accSmrg 515ff7e0accSmrgcpp) 516ff7e0accSmrg # Important note: in order to support this mode, a compiler *must* 517ff7e0accSmrg # always write the preprocessed file to stdout. 518ff7e0accSmrg "$@" || exit $? 519ff7e0accSmrg 520ff7e0accSmrg # Remove the call to Libtool. 521ff7e0accSmrg if test "$libtool" = yes; then 52210998002Smrg while test "X$1" != 'X--mode=compile'; do 523ff7e0accSmrg shift 524ff7e0accSmrg done 525ff7e0accSmrg shift 526ff7e0accSmrg fi 527ff7e0accSmrg 528ff7e0accSmrg # Remove `-o $object'. 529ff7e0accSmrg IFS=" " 530ff7e0accSmrg for arg 531ff7e0accSmrg do 532ff7e0accSmrg case $arg in 533ff7e0accSmrg -o) 534ff7e0accSmrg shift 535ff7e0accSmrg ;; 536ff7e0accSmrg $object) 537ff7e0accSmrg shift 538ff7e0accSmrg ;; 539ff7e0accSmrg *) 540ff7e0accSmrg set fnord "$@" "$arg" 541ff7e0accSmrg shift # fnord 542ff7e0accSmrg shift # $arg 543ff7e0accSmrg ;; 544ff7e0accSmrg esac 545ff7e0accSmrg done 546ff7e0accSmrg 547ff7e0accSmrg "$@" -E | 548ff7e0accSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549ff7e0accSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550ff7e0accSmrg sed '$ s: \\$::' > "$tmpdepfile" 551ff7e0accSmrg rm -f "$depfile" 552ff7e0accSmrg echo "$object : \\" > "$depfile" 553ff7e0accSmrg cat < "$tmpdepfile" >> "$depfile" 554ff7e0accSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555ff7e0accSmrg rm -f "$tmpdepfile" 556ff7e0accSmrg ;; 557ff7e0accSmrg 558ff7e0accSmrgmsvisualcpp) 559ff7e0accSmrg # Important note: in order to support this mode, a compiler *must* 56010998002Smrg # always write the preprocessed file to stdout. 561ff7e0accSmrg "$@" || exit $? 56210998002Smrg 56310998002Smrg # Remove the call to Libtool. 56410998002Smrg if test "$libtool" = yes; then 56510998002Smrg while test "X$1" != 'X--mode=compile'; do 56610998002Smrg shift 56710998002Smrg done 56810998002Smrg shift 56910998002Smrg fi 57010998002Smrg 571ff7e0accSmrg IFS=" " 572ff7e0accSmrg for arg 573ff7e0accSmrg do 574ff7e0accSmrg case "$arg" in 57510998002Smrg -o) 57610998002Smrg shift 57710998002Smrg ;; 57810998002Smrg $object) 57910998002Smrg shift 58010998002Smrg ;; 581ff7e0accSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582ff7e0accSmrg set fnord "$@" 583ff7e0accSmrg shift 584ff7e0accSmrg shift 585ff7e0accSmrg ;; 586ff7e0accSmrg *) 587ff7e0accSmrg set fnord "$@" "$arg" 588ff7e0accSmrg shift 589ff7e0accSmrg shift 590ff7e0accSmrg ;; 591ff7e0accSmrg esac 592ff7e0accSmrg done 59310998002Smrg "$@" -E 2>/dev/null | 59410998002Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595ff7e0accSmrg rm -f "$depfile" 596ff7e0accSmrg echo "$object : \\" > "$depfile" 59710998002Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598ff7e0accSmrg echo " " >> "$depfile" 59910998002Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600ff7e0accSmrg rm -f "$tmpdepfile" 601ff7e0accSmrg ;; 602ff7e0accSmrg 60310998002Smrgmsvcmsys) 60410998002Smrg # This case exists only to let depend.m4 do its work. It works by 60510998002Smrg # looking at the text of this script. This case will never be run, 60610998002Smrg # since it is checked for above. 60710998002Smrg exit 1 60810998002Smrg ;; 60910998002Smrg 610ff7e0accSmrgnone) 611ff7e0accSmrg exec "$@" 612ff7e0accSmrg ;; 613ff7e0accSmrg 614ff7e0accSmrg*) 615ff7e0accSmrg echo "Unknown depmode $depmode" 1>&2 616ff7e0accSmrg exit 1 617ff7e0accSmrg ;; 618ff7e0accSmrgesac 619ff7e0accSmrg 620ff7e0accSmrgexit 0 621ff7e0accSmrg 622ff7e0accSmrg# Local Variables: 623ff7e0accSmrg# mode: shell-script 624ff7e0accSmrg# sh-indentation: 2 625ff7e0accSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 626ff7e0accSmrg# time-stamp-start: "scriptversion=" 627ff7e0accSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 62810998002Smrg# time-stamp-time-zone: "UTC" 62910998002Smrg# time-stamp-end: "; # UTC" 630ff7e0accSmrg# End: 631