1cacd992dSmrg#! /bin/sh 2cacd992dSmrg# depcomp - compile a program generating dependencies as side-effects 314ddf674Smrg 46758a055Smrgscriptversion=2011-12-04.11; # UTC 514ddf674Smrg 66758a055Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 76758a055Smrg# 2011 Free Software Foundation, Inc. 8cacd992dSmrg 9cacd992dSmrg# This program is free software; you can redistribute it and/or modify 10cacd992dSmrg# it under the terms of the GNU General Public License as published by 11cacd992dSmrg# the Free Software Foundation; either version 2, or (at your option) 12cacd992dSmrg# any later version. 13cacd992dSmrg 14cacd992dSmrg# This program is distributed in the hope that it will be useful, 15cacd992dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16cacd992dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17cacd992dSmrg# GNU General Public License for more details. 18cacd992dSmrg 19cacd992dSmrg# You should have received a copy of the GNU General Public License 2014ddf674Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21cacd992dSmrg 22cacd992dSmrg# As a special exception to the GNU General Public License, if you 23cacd992dSmrg# distribute this file as part of a program that contains a 24cacd992dSmrg# configuration script generated by Autoconf, you may include it under 25cacd992dSmrg# the same distribution terms that you use for the rest of that program. 26cacd992dSmrg 27cacd992dSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28cacd992dSmrg 2914ddf674Smrgcase $1 in 3014ddf674Smrg '') 3114ddf674Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3214ddf674Smrg exit 1; 3314ddf674Smrg ;; 3414ddf674Smrg -h | --h*) 3514ddf674Smrg cat <<\EOF 3614ddf674SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3714ddf674Smrg 3814ddf674SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3914ddf674Smrgas side-effects. 4014ddf674Smrg 4114ddf674SmrgEnvironment variables: 4214ddf674Smrg depmode Dependency tracking mode. 4314ddf674Smrg source Source file read by `PROGRAMS ARGS'. 4414ddf674Smrg object Object file output by `PROGRAMS ARGS'. 4514ddf674Smrg DEPDIR directory where to store dependencies. 4614ddf674Smrg depfile Dependency file to output. 476758a055Smrg tmpdepfile Temporary file to use when outputting dependencies. 4814ddf674Smrg libtool Whether libtool is used (yes/no). 4914ddf674Smrg 5014ddf674SmrgReport bugs to <bug-automake@gnu.org>. 5114ddf674SmrgEOF 5214ddf674Smrg exit $? 5314ddf674Smrg ;; 5414ddf674Smrg -v | --v*) 5514ddf674Smrg echo "depcomp $scriptversion" 5614ddf674Smrg exit $? 5714ddf674Smrg ;; 5814ddf674Smrgesac 5914ddf674Smrg 60cacd992dSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61cacd992dSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62cacd992dSmrg exit 1 63cacd992dSmrgfi 64cacd992dSmrg 6514ddf674Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6614ddf674Smrgdepfile=${depfile-`echo "$object" | 6714ddf674Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68cacd992dSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69cacd992dSmrg 70cacd992dSmrgrm -f "$tmpdepfile" 71cacd992dSmrg 72cacd992dSmrg# Some modes work just like other modes, but use different flags. We 73cacd992dSmrg# parameterize here, but still list the modes in the big case below, 74cacd992dSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75cacd992dSmrg# here, because this file can only contain one case statement. 76cacd992dSmrgif test "$depmode" = hp; then 77cacd992dSmrg # HP compiler uses -M and no extra arg. 78cacd992dSmrg gccflag=-M 79cacd992dSmrg depmode=gcc 80cacd992dSmrgfi 81cacd992dSmrg 82cacd992dSmrgif test "$depmode" = dashXmstdout; then 83cacd992dSmrg # This is just like dashmstdout with a different argument. 84cacd992dSmrg dashmflag=-xM 85cacd992dSmrg depmode=dashmstdout 86cacd992dSmrgfi 87cacd992dSmrg 8814ddf674Smrgcygpath_u="cygpath -u -f -" 8914ddf674Smrgif test "$depmode" = msvcmsys; then 9014ddf674Smrg # This is just like msvisualcpp but w/o cygpath translation. 9114ddf674Smrg # Just convert the backslash-escaped backslashes to single forward 9214ddf674Smrg # slashes to satisfy depend.m4 936758a055Smrg cygpath_u='sed s,\\\\,/,g' 9414ddf674Smrg depmode=msvisualcpp 9514ddf674Smrgfi 9614ddf674Smrg 976758a055Smrgif test "$depmode" = msvc7msys; then 986758a055Smrg # This is just like msvc7 but w/o cygpath translation. 996758a055Smrg # Just convert the backslash-escaped backslashes to single forward 1006758a055Smrg # slashes to satisfy depend.m4 1016758a055Smrg cygpath_u='sed s,\\\\,/,g' 1026758a055Smrg depmode=msvc7 1036758a055Smrgfi 1046758a055Smrg 105cacd992dSmrgcase "$depmode" in 106cacd992dSmrggcc3) 107cacd992dSmrg## gcc 3 implements dependency tracking that does exactly what 108cacd992dSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 109cacd992dSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 11014ddf674Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 11114ddf674Smrg## the command line argument order; so add the flags where they 11214ddf674Smrg## appear in depend2.am. Note that the slowdown incurred here 11314ddf674Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 11414ddf674Smrg for arg 11514ddf674Smrg do 11614ddf674Smrg case $arg in 11714ddf674Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 11814ddf674Smrg *) set fnord "$@" "$arg" ;; 11914ddf674Smrg esac 12014ddf674Smrg shift # fnord 12114ddf674Smrg shift # $arg 12214ddf674Smrg done 12314ddf674Smrg "$@" 124cacd992dSmrg stat=$? 125cacd992dSmrg if test $stat -eq 0; then : 126cacd992dSmrg else 127cacd992dSmrg rm -f "$tmpdepfile" 128cacd992dSmrg exit $stat 129cacd992dSmrg fi 130cacd992dSmrg mv "$tmpdepfile" "$depfile" 131cacd992dSmrg ;; 132cacd992dSmrg 133cacd992dSmrggcc) 134cacd992dSmrg## There are various ways to get dependency output from gcc. Here's 135cacd992dSmrg## why we pick this rather obscure method: 136cacd992dSmrg## - Don't want to use -MD because we'd like the dependencies to end 137cacd992dSmrg## up in a subdir. Having to rename by hand is ugly. 138cacd992dSmrg## (We might end up doing this anyway to support other compilers.) 139cacd992dSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 140cacd992dSmrg## -MM, not -M (despite what the docs say). 141cacd992dSmrg## - Using -M directly means running the compiler twice (even worse 142cacd992dSmrg## than renaming). 143cacd992dSmrg if test -z "$gccflag"; then 144cacd992dSmrg gccflag=-MD, 145cacd992dSmrg fi 146cacd992dSmrg "$@" -Wp,"$gccflag$tmpdepfile" 147cacd992dSmrg stat=$? 148cacd992dSmrg if test $stat -eq 0; then : 149cacd992dSmrg else 150cacd992dSmrg rm -f "$tmpdepfile" 151cacd992dSmrg exit $stat 152cacd992dSmrg fi 153cacd992dSmrg rm -f "$depfile" 154cacd992dSmrg echo "$object : \\" > "$depfile" 155cacd992dSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 156cacd992dSmrg## The second -e expression handles DOS-style file names with drive letters. 157cacd992dSmrg sed -e 's/^[^:]*: / /' \ 158cacd992dSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 159cacd992dSmrg## This next piece of magic avoids the `deleted header file' problem. 160cacd992dSmrg## The problem is that when a header file which appears in a .P file 161cacd992dSmrg## is deleted, the dependency causes make to die (because there is 162cacd992dSmrg## typically no way to rebuild the header). We avoid this by adding 163cacd992dSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 164cacd992dSmrg## this for us directly. 165cacd992dSmrg tr ' ' ' 166cacd992dSmrg' < "$tmpdepfile" | 167cacd992dSmrg## Some versions of gcc put a space before the `:'. On the theory 168cacd992dSmrg## that the space means something, we add a space to the output as 1696758a055Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 1706758a055Smrg## to the object. Take care to not repeat it in the output. 171cacd992dSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 172cacd992dSmrg## correctly. Breaking it into two sed invocations is a workaround. 1736758a055Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 1746758a055Smrg | sed -e 's/$/ :/' >> "$depfile" 175cacd992dSmrg rm -f "$tmpdepfile" 176cacd992dSmrg ;; 177cacd992dSmrg 178cacd992dSmrghp) 179cacd992dSmrg # This case exists only to let depend.m4 do its work. It works by 180cacd992dSmrg # looking at the text of this script. This case will never be run, 181cacd992dSmrg # since it is checked for above. 182cacd992dSmrg exit 1 183cacd992dSmrg ;; 184cacd992dSmrg 185cacd992dSmrgsgi) 186cacd992dSmrg if test "$libtool" = yes; then 187cacd992dSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 188cacd992dSmrg else 189cacd992dSmrg "$@" -MDupdate "$tmpdepfile" 190cacd992dSmrg fi 191cacd992dSmrg stat=$? 192cacd992dSmrg if test $stat -eq 0; then : 193cacd992dSmrg else 194cacd992dSmrg rm -f "$tmpdepfile" 195cacd992dSmrg exit $stat 196cacd992dSmrg fi 197cacd992dSmrg rm -f "$depfile" 198cacd992dSmrg 199cacd992dSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 200cacd992dSmrg echo "$object : \\" > "$depfile" 201cacd992dSmrg 202cacd992dSmrg # Clip off the initial element (the dependent). Don't try to be 203cacd992dSmrg # clever and replace this with sed code, as IRIX sed won't handle 204cacd992dSmrg # lines with more than a fixed number of characters (4096 in 205cacd992dSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 206cacd992dSmrg # the IRIX cc adds comments like `#:fec' to the end of the 207cacd992dSmrg # dependency line. 208cacd992dSmrg tr ' ' ' 209cacd992dSmrg' < "$tmpdepfile" \ 210cacd992dSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 211cacd992dSmrg tr ' 21214ddf674Smrg' ' ' >> "$depfile" 21314ddf674Smrg echo >> "$depfile" 214cacd992dSmrg 215cacd992dSmrg # The second pass generates a dummy entry for each header file. 216cacd992dSmrg tr ' ' ' 217cacd992dSmrg' < "$tmpdepfile" \ 218cacd992dSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 21914ddf674Smrg >> "$depfile" 220cacd992dSmrg else 221cacd992dSmrg # The sourcefile does not contain any dependencies, so just 222cacd992dSmrg # store a dummy comment line, to avoid errors with the Makefile 223cacd992dSmrg # "include basename.Plo" scheme. 224cacd992dSmrg echo "#dummy" > "$depfile" 225cacd992dSmrg fi 226cacd992dSmrg rm -f "$tmpdepfile" 227cacd992dSmrg ;; 228cacd992dSmrg 229cacd992dSmrgaix) 230cacd992dSmrg # The C for AIX Compiler uses -M and outputs the dependencies 231cacd992dSmrg # in a .u file. In older versions, this file always lives in the 232cacd992dSmrg # current directory. Also, the AIX compiler puts `$object:' at the 233cacd992dSmrg # start of each line; $object doesn't have directory information. 234cacd992dSmrg # Version 6 uses the directory in both cases. 23514ddf674Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 23614ddf674Smrg test "x$dir" = "x$object" && dir= 23714ddf674Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 238cacd992dSmrg if test "$libtool" = yes; then 23914ddf674Smrg tmpdepfile1=$dir$base.u 24014ddf674Smrg tmpdepfile2=$base.u 24114ddf674Smrg tmpdepfile3=$dir.libs/$base.u 242cacd992dSmrg "$@" -Wc,-M 243cacd992dSmrg else 24414ddf674Smrg tmpdepfile1=$dir$base.u 24514ddf674Smrg tmpdepfile2=$dir$base.u 24614ddf674Smrg tmpdepfile3=$dir$base.u 247cacd992dSmrg "$@" -M 248cacd992dSmrg fi 249cacd992dSmrg stat=$? 250cacd992dSmrg 251cacd992dSmrg if test $stat -eq 0; then : 252cacd992dSmrg else 25314ddf674Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 254cacd992dSmrg exit $stat 255cacd992dSmrg fi 256cacd992dSmrg 25714ddf674Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 25814ddf674Smrg do 25914ddf674Smrg test -f "$tmpdepfile" && break 26014ddf674Smrg done 261cacd992dSmrg if test -f "$tmpdepfile"; then 262cacd992dSmrg # Each line is of the form `foo.o: dependent.h'. 263cacd992dSmrg # Do two passes, one to just change these to 264cacd992dSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 26514ddf674Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 26614ddf674Smrg # That's a tab and a space in the []. 26714ddf674Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 268cacd992dSmrg else 269cacd992dSmrg # The sourcefile does not contain any dependencies, so just 270cacd992dSmrg # store a dummy comment line, to avoid errors with the Makefile 271cacd992dSmrg # "include basename.Plo" scheme. 272cacd992dSmrg echo "#dummy" > "$depfile" 273cacd992dSmrg fi 274cacd992dSmrg rm -f "$tmpdepfile" 275cacd992dSmrg ;; 276cacd992dSmrg 277cacd992dSmrgicc) 278cacd992dSmrg # Intel's C compiler understands `-MD -MF file'. However on 279cacd992dSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 280cacd992dSmrg # ICC 7.0 will fill foo.d with something like 281cacd992dSmrg # foo.o: sub/foo.c 282cacd992dSmrg # foo.o: sub/foo.h 283cacd992dSmrg # which is wrong. We want: 284cacd992dSmrg # sub/foo.o: sub/foo.c 285cacd992dSmrg # sub/foo.o: sub/foo.h 286cacd992dSmrg # sub/foo.c: 287cacd992dSmrg # sub/foo.h: 288cacd992dSmrg # ICC 7.1 will output 289cacd992dSmrg # foo.o: sub/foo.c sub/foo.h 290cacd992dSmrg # and will wrap long lines using \ : 291cacd992dSmrg # foo.o: sub/foo.c ... \ 292cacd992dSmrg # sub/foo.h ... \ 293cacd992dSmrg # ... 294cacd992dSmrg 295cacd992dSmrg "$@" -MD -MF "$tmpdepfile" 296cacd992dSmrg stat=$? 297cacd992dSmrg if test $stat -eq 0; then : 298cacd992dSmrg else 299cacd992dSmrg rm -f "$tmpdepfile" 300cacd992dSmrg exit $stat 301cacd992dSmrg fi 302cacd992dSmrg rm -f "$depfile" 303cacd992dSmrg # Each line is of the form `foo.o: dependent.h', 304cacd992dSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 305cacd992dSmrg # Do two passes, one to just change these to 306cacd992dSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 307cacd992dSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 308cacd992dSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 309cacd992dSmrg # correctly. Breaking it into two sed invocations is a workaround. 310cacd992dSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 311cacd992dSmrg sed -e 's/$/ :/' >> "$depfile" 312cacd992dSmrg rm -f "$tmpdepfile" 313cacd992dSmrg ;; 314cacd992dSmrg 31514ddf674Smrghp2) 31614ddf674Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 31714ddf674Smrg # compilers, which have integrated preprocessors. The correct option 31814ddf674Smrg # to use with these is +Maked; it writes dependencies to a file named 31914ddf674Smrg # 'foo.d', which lands next to the object file, wherever that 32014ddf674Smrg # happens to be. 32114ddf674Smrg # Much of this is similar to the tru64 case; see comments there. 32214ddf674Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 32314ddf674Smrg test "x$dir" = "x$object" && dir= 32414ddf674Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 32514ddf674Smrg if test "$libtool" = yes; then 32614ddf674Smrg tmpdepfile1=$dir$base.d 32714ddf674Smrg tmpdepfile2=$dir.libs/$base.d 32814ddf674Smrg "$@" -Wc,+Maked 32914ddf674Smrg else 33014ddf674Smrg tmpdepfile1=$dir$base.d 33114ddf674Smrg tmpdepfile2=$dir$base.d 33214ddf674Smrg "$@" +Maked 33314ddf674Smrg fi 33414ddf674Smrg stat=$? 33514ddf674Smrg if test $stat -eq 0; then : 33614ddf674Smrg else 33714ddf674Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 33814ddf674Smrg exit $stat 33914ddf674Smrg fi 34014ddf674Smrg 34114ddf674Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 34214ddf674Smrg do 34314ddf674Smrg test -f "$tmpdepfile" && break 34414ddf674Smrg done 34514ddf674Smrg if test -f "$tmpdepfile"; then 34614ddf674Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 34714ddf674Smrg # Add `dependent.h:' lines. 34814ddf674Smrg sed -ne '2,${ 34914ddf674Smrg s/^ *// 35014ddf674Smrg s/ \\*$// 35114ddf674Smrg s/$/:/ 35214ddf674Smrg p 35314ddf674Smrg }' "$tmpdepfile" >> "$depfile" 35414ddf674Smrg else 35514ddf674Smrg echo "#dummy" > "$depfile" 35614ddf674Smrg fi 35714ddf674Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 35814ddf674Smrg ;; 35914ddf674Smrg 360cacd992dSmrgtru64) 361cacd992dSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 362cacd992dSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 363cacd992dSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 364cacd992dSmrg # dependencies in `foo.d' instead, so we check for that too. 365cacd992dSmrg # Subdirectories are respected. 366cacd992dSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 367cacd992dSmrg test "x$dir" = "x$object" && dir= 368cacd992dSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 369cacd992dSmrg 370cacd992dSmrg if test "$libtool" = yes; then 37114ddf674Smrg # With Tru64 cc, shared objects can also be used to make a 37214ddf674Smrg # static library. This mechanism is used in libtool 1.4 series to 37314ddf674Smrg # handle both shared and static libraries in a single compilation. 37414ddf674Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 37514ddf674Smrg # 37614ddf674Smrg # With libtool 1.5 this exception was removed, and libtool now 37714ddf674Smrg # generates 2 separate objects for the 2 libraries. These two 37814ddf674Smrg # compilations output dependencies in $dir.libs/$base.o.d and 37914ddf674Smrg # in $dir$base.o.d. We have to check for both files, because 38014ddf674Smrg # one of the two compilations can be disabled. We should prefer 38114ddf674Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 38214ddf674Smrg # automatically cleaned when .libs/ is deleted, while ignoring 38314ddf674Smrg # the former would cause a distcleancheck panic. 38414ddf674Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 38514ddf674Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 38614ddf674Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 38714ddf674Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 388cacd992dSmrg "$@" -Wc,-MD 389cacd992dSmrg else 39014ddf674Smrg tmpdepfile1=$dir$base.o.d 39114ddf674Smrg tmpdepfile2=$dir$base.d 39214ddf674Smrg tmpdepfile3=$dir$base.d 39314ddf674Smrg tmpdepfile4=$dir$base.d 394cacd992dSmrg "$@" -MD 395cacd992dSmrg fi 396cacd992dSmrg 397cacd992dSmrg stat=$? 398cacd992dSmrg if test $stat -eq 0; then : 399cacd992dSmrg else 40014ddf674Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 401cacd992dSmrg exit $stat 402cacd992dSmrg fi 403cacd992dSmrg 40414ddf674Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40514ddf674Smrg do 40614ddf674Smrg test -f "$tmpdepfile" && break 40714ddf674Smrg done 408cacd992dSmrg if test -f "$tmpdepfile"; then 409cacd992dSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 410cacd992dSmrg # That's a tab and a space in the []. 411cacd992dSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 412cacd992dSmrg else 413cacd992dSmrg echo "#dummy" > "$depfile" 414cacd992dSmrg fi 415cacd992dSmrg rm -f "$tmpdepfile" 416cacd992dSmrg ;; 417cacd992dSmrg 4186758a055Smrgmsvc7) 4196758a055Smrg if test "$libtool" = yes; then 4206758a055Smrg showIncludes=-Wc,-showIncludes 4216758a055Smrg else 4226758a055Smrg showIncludes=-showIncludes 4236758a055Smrg fi 4246758a055Smrg "$@" $showIncludes > "$tmpdepfile" 4256758a055Smrg stat=$? 4266758a055Smrg grep -v '^Note: including file: ' "$tmpdepfile" 4276758a055Smrg if test "$stat" = 0; then : 4286758a055Smrg else 4296758a055Smrg rm -f "$tmpdepfile" 4306758a055Smrg exit $stat 4316758a055Smrg fi 4326758a055Smrg rm -f "$depfile" 4336758a055Smrg echo "$object : \\" > "$depfile" 4346758a055Smrg # The first sed program below extracts the file names and escapes 4356758a055Smrg # backslashes for cygpath. The second sed program outputs the file 4366758a055Smrg # name when reading, but also accumulates all include files in the 4376758a055Smrg # hold buffer in order to output them again at the end. This only 4386758a055Smrg # works with sed implementations that can handle large buffers. 4396758a055Smrg sed < "$tmpdepfile" -n ' 4406758a055Smrg/^Note: including file: *\(.*\)/ { 4416758a055Smrg s//\1/ 4426758a055Smrg s/\\/\\\\/g 4436758a055Smrg p 4446758a055Smrg}' | $cygpath_u | sort -u | sed -n ' 4456758a055Smrgs/ /\\ /g 4466758a055Smrgs/\(.*\)/ \1 \\/p 4476758a055Smrgs/.\(.*\) \\/\1:/ 4486758a055SmrgH 4496758a055Smrg$ { 4506758a055Smrg s/.*/ / 4516758a055Smrg G 4526758a055Smrg p 4536758a055Smrg}' >> "$depfile" 4546758a055Smrg rm -f "$tmpdepfile" 4556758a055Smrg ;; 4566758a055Smrg 4576758a055Smrgmsvc7msys) 4586758a055Smrg # This case exists only to let depend.m4 do its work. It works by 4596758a055Smrg # looking at the text of this script. This case will never be run, 4606758a055Smrg # since it is checked for above. 4616758a055Smrg exit 1 4626758a055Smrg ;; 4636758a055Smrg 464cacd992dSmrg#nosideeffect) 465cacd992dSmrg # This comment above is used by automake to tell side-effect 466cacd992dSmrg # dependency tracking mechanisms from slower ones. 467cacd992dSmrg 468cacd992dSmrgdashmstdout) 469cacd992dSmrg # Important note: in order to support this mode, a compiler *must* 470cacd992dSmrg # always write the preprocessed file to stdout, regardless of -o. 471cacd992dSmrg "$@" || exit $? 472cacd992dSmrg 473cacd992dSmrg # Remove the call to Libtool. 474cacd992dSmrg if test "$libtool" = yes; then 47514ddf674Smrg while test "X$1" != 'X--mode=compile'; do 476cacd992dSmrg shift 477cacd992dSmrg done 478cacd992dSmrg shift 479cacd992dSmrg fi 480cacd992dSmrg 481cacd992dSmrg # Remove `-o $object'. 482cacd992dSmrg IFS=" " 483cacd992dSmrg for arg 484cacd992dSmrg do 485cacd992dSmrg case $arg in 486cacd992dSmrg -o) 487cacd992dSmrg shift 488cacd992dSmrg ;; 489cacd992dSmrg $object) 490cacd992dSmrg shift 491cacd992dSmrg ;; 492cacd992dSmrg *) 493cacd992dSmrg set fnord "$@" "$arg" 494cacd992dSmrg shift # fnord 495cacd992dSmrg shift # $arg 496cacd992dSmrg ;; 497cacd992dSmrg esac 498cacd992dSmrg done 499cacd992dSmrg 500cacd992dSmrg test -z "$dashmflag" && dashmflag=-M 501cacd992dSmrg # Require at least two characters before searching for `:' 502cacd992dSmrg # in the target name. This is to cope with DOS-style filenames: 503cacd992dSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 504cacd992dSmrg "$@" $dashmflag | 505cacd992dSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 506cacd992dSmrg rm -f "$depfile" 507cacd992dSmrg cat < "$tmpdepfile" > "$depfile" 508cacd992dSmrg tr ' ' ' 509cacd992dSmrg' < "$tmpdepfile" | \ 510cacd992dSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 511cacd992dSmrg## correctly. Breaking it into two sed invocations is a workaround. 512cacd992dSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 513cacd992dSmrg rm -f "$tmpdepfile" 514cacd992dSmrg ;; 515cacd992dSmrg 516cacd992dSmrgdashXmstdout) 517cacd992dSmrg # This case only exists to satisfy depend.m4. It is never actually 518cacd992dSmrg # run, as this mode is specially recognized in the preamble. 519cacd992dSmrg exit 1 520cacd992dSmrg ;; 521cacd992dSmrg 522cacd992dSmrgmakedepend) 523cacd992dSmrg "$@" || exit $? 524cacd992dSmrg # Remove any Libtool call 525cacd992dSmrg if test "$libtool" = yes; then 52614ddf674Smrg while test "X$1" != 'X--mode=compile'; do 527cacd992dSmrg shift 528cacd992dSmrg done 529cacd992dSmrg shift 530cacd992dSmrg fi 531cacd992dSmrg # X makedepend 532cacd992dSmrg shift 53314ddf674Smrg cleared=no eat=no 53414ddf674Smrg for arg 53514ddf674Smrg do 536cacd992dSmrg case $cleared in 537cacd992dSmrg no) 538cacd992dSmrg set ""; shift 539cacd992dSmrg cleared=yes ;; 540cacd992dSmrg esac 54114ddf674Smrg if test $eat = yes; then 54214ddf674Smrg eat=no 54314ddf674Smrg continue 54414ddf674Smrg fi 545cacd992dSmrg case "$arg" in 546cacd992dSmrg -D*|-I*) 547cacd992dSmrg set fnord "$@" "$arg"; shift ;; 548cacd992dSmrg # Strip any option that makedepend may not understand. Remove 549cacd992dSmrg # the object too, otherwise makedepend will parse it as a source file. 55014ddf674Smrg -arch) 55114ddf674Smrg eat=yes ;; 552cacd992dSmrg -*|$object) 553cacd992dSmrg ;; 554cacd992dSmrg *) 555cacd992dSmrg set fnord "$@" "$arg"; shift ;; 556cacd992dSmrg esac 557cacd992dSmrg done 55814ddf674Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 559cacd992dSmrg touch "$tmpdepfile" 560cacd992dSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 561cacd992dSmrg rm -f "$depfile" 5626758a055Smrg # makedepend may prepend the VPATH from the source file name to the object. 5636758a055Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 5646758a055Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 565cacd992dSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 566cacd992dSmrg' | \ 567cacd992dSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 568cacd992dSmrg## correctly. Breaking it into two sed invocations is a workaround. 569cacd992dSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 570cacd992dSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 571cacd992dSmrg ;; 572cacd992dSmrg 573cacd992dSmrgcpp) 574cacd992dSmrg # Important note: in order to support this mode, a compiler *must* 575cacd992dSmrg # always write the preprocessed file to stdout. 576cacd992dSmrg "$@" || exit $? 577cacd992dSmrg 578cacd992dSmrg # Remove the call to Libtool. 579cacd992dSmrg if test "$libtool" = yes; then 58014ddf674Smrg while test "X$1" != 'X--mode=compile'; do 581cacd992dSmrg shift 582cacd992dSmrg done 583cacd992dSmrg shift 584cacd992dSmrg fi 585cacd992dSmrg 586cacd992dSmrg # Remove `-o $object'. 587cacd992dSmrg IFS=" " 588cacd992dSmrg for arg 589cacd992dSmrg do 590cacd992dSmrg case $arg in 591cacd992dSmrg -o) 592cacd992dSmrg shift 593cacd992dSmrg ;; 594cacd992dSmrg $object) 595cacd992dSmrg shift 596cacd992dSmrg ;; 597cacd992dSmrg *) 598cacd992dSmrg set fnord "$@" "$arg" 599cacd992dSmrg shift # fnord 600cacd992dSmrg shift # $arg 601cacd992dSmrg ;; 602cacd992dSmrg esac 603cacd992dSmrg done 604cacd992dSmrg 605cacd992dSmrg "$@" -E | 60614ddf674Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 60714ddf674Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 608cacd992dSmrg sed '$ s: \\$::' > "$tmpdepfile" 609cacd992dSmrg rm -f "$depfile" 610cacd992dSmrg echo "$object : \\" > "$depfile" 611cacd992dSmrg cat < "$tmpdepfile" >> "$depfile" 612cacd992dSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 613cacd992dSmrg rm -f "$tmpdepfile" 614cacd992dSmrg ;; 615cacd992dSmrg 616cacd992dSmrgmsvisualcpp) 617cacd992dSmrg # Important note: in order to support this mode, a compiler *must* 61814ddf674Smrg # always write the preprocessed file to stdout. 619cacd992dSmrg "$@" || exit $? 62014ddf674Smrg 62114ddf674Smrg # Remove the call to Libtool. 62214ddf674Smrg if test "$libtool" = yes; then 62314ddf674Smrg while test "X$1" != 'X--mode=compile'; do 62414ddf674Smrg shift 62514ddf674Smrg done 62614ddf674Smrg shift 62714ddf674Smrg fi 62814ddf674Smrg 629cacd992dSmrg IFS=" " 630cacd992dSmrg for arg 631cacd992dSmrg do 632cacd992dSmrg case "$arg" in 63314ddf674Smrg -o) 63414ddf674Smrg shift 63514ddf674Smrg ;; 63614ddf674Smrg $object) 63714ddf674Smrg shift 63814ddf674Smrg ;; 639cacd992dSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 640cacd992dSmrg set fnord "$@" 641cacd992dSmrg shift 642cacd992dSmrg shift 643cacd992dSmrg ;; 644cacd992dSmrg *) 645cacd992dSmrg set fnord "$@" "$arg" 646cacd992dSmrg shift 647cacd992dSmrg shift 648cacd992dSmrg ;; 649cacd992dSmrg esac 650cacd992dSmrg done 65114ddf674Smrg "$@" -E 2>/dev/null | 65214ddf674Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 653cacd992dSmrg rm -f "$depfile" 654cacd992dSmrg echo "$object : \\" > "$depfile" 65514ddf674Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 656cacd992dSmrg echo " " >> "$depfile" 65714ddf674Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 658cacd992dSmrg rm -f "$tmpdepfile" 659cacd992dSmrg ;; 660cacd992dSmrg 66114ddf674Smrgmsvcmsys) 66214ddf674Smrg # This case exists only to let depend.m4 do its work. It works by 66314ddf674Smrg # looking at the text of this script. This case will never be run, 66414ddf674Smrg # since it is checked for above. 66514ddf674Smrg exit 1 66614ddf674Smrg ;; 66714ddf674Smrg 668cacd992dSmrgnone) 669cacd992dSmrg exec "$@" 670cacd992dSmrg ;; 671cacd992dSmrg 672cacd992dSmrg*) 673cacd992dSmrg echo "Unknown depmode $depmode" 1>&2 674cacd992dSmrg exit 1 675cacd992dSmrg ;; 676cacd992dSmrgesac 677cacd992dSmrg 678cacd992dSmrgexit 0 67914ddf674Smrg 68014ddf674Smrg# Local Variables: 68114ddf674Smrg# mode: shell-script 68214ddf674Smrg# sh-indentation: 2 68314ddf674Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 68414ddf674Smrg# time-stamp-start: "scriptversion=" 68514ddf674Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 68614ddf674Smrg# time-stamp-time-zone: "UTC" 68714ddf674Smrg# time-stamp-end: "; # UTC" 68814ddf674Smrg# End: 689