depcomp revision bf2eeab3
114c0a534Smrg#! /bin/sh 214c0a534Smrg# depcomp - compile a program generating dependencies as side-effects 314c0a534Smrg 4bf2eeab3Smrgscriptversion=2009-04-28.21; # UTC 514c0a534Smrg 6bf2eeab3Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7bf2eeab3Smrg# Software Foundation, Inc. 814c0a534Smrg 914c0a534Smrg# This program is free software; you can redistribute it and/or modify 1014c0a534Smrg# it under the terms of the GNU General Public License as published by 1114c0a534Smrg# the Free Software Foundation; either version 2, or (at your option) 1214c0a534Smrg# any later version. 1314c0a534Smrg 1414c0a534Smrg# This program is distributed in the hope that it will be useful, 1514c0a534Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1614c0a534Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1714c0a534Smrg# GNU General Public License for more details. 1814c0a534Smrg 1914c0a534Smrg# You should have received a copy of the GNU General Public License 20bf2eeab3Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2114c0a534Smrg 2214c0a534Smrg# As a special exception to the GNU General Public License, if you 2314c0a534Smrg# distribute this file as part of a program that contains a 2414c0a534Smrg# configuration script generated by Autoconf, you may include it under 2514c0a534Smrg# the same distribution terms that you use for the rest of that program. 2614c0a534Smrg 2714c0a534Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2814c0a534Smrg 2914c0a534Smrgcase $1 in 3014c0a534Smrg '') 3114c0a534Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3214c0a534Smrg exit 1; 3314c0a534Smrg ;; 3414c0a534Smrg -h | --h*) 3514c0a534Smrg cat <<\EOF 3614c0a534SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3714c0a534Smrg 3814c0a534SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3914c0a534Smrgas side-effects. 4014c0a534Smrg 4114c0a534SmrgEnvironment variables: 4214c0a534Smrg depmode Dependency tracking mode. 4314c0a534Smrg source Source file read by `PROGRAMS ARGS'. 4414c0a534Smrg object Object file output by `PROGRAMS ARGS'. 4514c0a534Smrg DEPDIR directory where to store dependencies. 4614c0a534Smrg depfile Dependency file to output. 4714c0a534Smrg tmpdepfile Temporary file to use when outputing dependencies. 4814c0a534Smrg libtool Whether libtool is used (yes/no). 4914c0a534Smrg 5014c0a534SmrgReport bugs to <bug-automake@gnu.org>. 5114c0a534SmrgEOF 5214c0a534Smrg exit $? 5314c0a534Smrg ;; 5414c0a534Smrg -v | --v*) 5514c0a534Smrg echo "depcomp $scriptversion" 5614c0a534Smrg exit $? 5714c0a534Smrg ;; 5814c0a534Smrgesac 5914c0a534Smrg 6014c0a534Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6114c0a534Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6214c0a534Smrg exit 1 6314c0a534Smrgfi 6414c0a534Smrg 6514c0a534Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6614c0a534Smrgdepfile=${depfile-`echo "$object" | 6714c0a534Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6814c0a534Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 6914c0a534Smrg 7014c0a534Smrgrm -f "$tmpdepfile" 7114c0a534Smrg 7214c0a534Smrg# Some modes work just like other modes, but use different flags. We 7314c0a534Smrg# parameterize here, but still list the modes in the big case below, 7414c0a534Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7514c0a534Smrg# here, because this file can only contain one case statement. 7614c0a534Smrgif test "$depmode" = hp; then 7714c0a534Smrg # HP compiler uses -M and no extra arg. 7814c0a534Smrg gccflag=-M 7914c0a534Smrg depmode=gcc 8014c0a534Smrgfi 8114c0a534Smrg 8214c0a534Smrgif test "$depmode" = dashXmstdout; then 8314c0a534Smrg # This is just like dashmstdout with a different argument. 8414c0a534Smrg dashmflag=-xM 8514c0a534Smrg depmode=dashmstdout 8614c0a534Smrgfi 8714c0a534Smrg 88bf2eeab3Smrgcygpath_u="cygpath -u -f -" 89bf2eeab3Smrgif test "$depmode" = msvcmsys; then 90bf2eeab3Smrg # This is just like msvisualcpp but w/o cygpath translation. 91bf2eeab3Smrg # Just convert the backslash-escaped backslashes to single forward 92bf2eeab3Smrg # slashes to satisfy depend.m4 93bf2eeab3Smrg cygpath_u="sed s,\\\\\\\\,/,g" 94bf2eeab3Smrg depmode=msvisualcpp 95bf2eeab3Smrgfi 96bf2eeab3Smrg 9714c0a534Smrgcase "$depmode" in 9814c0a534Smrggcc3) 9914c0a534Smrg## gcc 3 implements dependency tracking that does exactly what 10014c0a534Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 10114c0a534Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 102bf2eeab3Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103bf2eeab3Smrg## the command line argument order; so add the flags where they 104bf2eeab3Smrg## appear in depend2.am. Note that the slowdown incurred here 105bf2eeab3Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106bf2eeab3Smrg for arg 107bf2eeab3Smrg do 108bf2eeab3Smrg case $arg in 109bf2eeab3Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110bf2eeab3Smrg *) set fnord "$@" "$arg" ;; 111bf2eeab3Smrg esac 112bf2eeab3Smrg shift # fnord 113bf2eeab3Smrg shift # $arg 114bf2eeab3Smrg done 115bf2eeab3Smrg "$@" 11614c0a534Smrg stat=$? 11714c0a534Smrg if test $stat -eq 0; then : 11814c0a534Smrg else 11914c0a534Smrg rm -f "$tmpdepfile" 12014c0a534Smrg exit $stat 12114c0a534Smrg fi 12214c0a534Smrg mv "$tmpdepfile" "$depfile" 12314c0a534Smrg ;; 12414c0a534Smrg 12514c0a534Smrggcc) 12614c0a534Smrg## There are various ways to get dependency output from gcc. Here's 12714c0a534Smrg## why we pick this rather obscure method: 12814c0a534Smrg## - Don't want to use -MD because we'd like the dependencies to end 12914c0a534Smrg## up in a subdir. Having to rename by hand is ugly. 13014c0a534Smrg## (We might end up doing this anyway to support other compilers.) 13114c0a534Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 13214c0a534Smrg## -MM, not -M (despite what the docs say). 13314c0a534Smrg## - Using -M directly means running the compiler twice (even worse 13414c0a534Smrg## than renaming). 13514c0a534Smrg if test -z "$gccflag"; then 13614c0a534Smrg gccflag=-MD, 13714c0a534Smrg fi 13814c0a534Smrg "$@" -Wp,"$gccflag$tmpdepfile" 13914c0a534Smrg stat=$? 14014c0a534Smrg if test $stat -eq 0; then : 14114c0a534Smrg else 14214c0a534Smrg rm -f "$tmpdepfile" 14314c0a534Smrg exit $stat 14414c0a534Smrg fi 14514c0a534Smrg rm -f "$depfile" 14614c0a534Smrg echo "$object : \\" > "$depfile" 14714c0a534Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 14814c0a534Smrg## The second -e expression handles DOS-style file names with drive letters. 14914c0a534Smrg sed -e 's/^[^:]*: / /' \ 15014c0a534Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 15114c0a534Smrg## This next piece of magic avoids the `deleted header file' problem. 15214c0a534Smrg## The problem is that when a header file which appears in a .P file 15314c0a534Smrg## is deleted, the dependency causes make to die (because there is 15414c0a534Smrg## typically no way to rebuild the header). We avoid this by adding 15514c0a534Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 15614c0a534Smrg## this for us directly. 15714c0a534Smrg tr ' ' ' 15814c0a534Smrg' < "$tmpdepfile" | 15914c0a534Smrg## Some versions of gcc put a space before the `:'. On the theory 16014c0a534Smrg## that the space means something, we add a space to the output as 16114c0a534Smrg## well. 16214c0a534Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 16314c0a534Smrg## correctly. Breaking it into two sed invocations is a workaround. 16414c0a534Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 16514c0a534Smrg rm -f "$tmpdepfile" 16614c0a534Smrg ;; 16714c0a534Smrg 16814c0a534Smrghp) 16914c0a534Smrg # This case exists only to let depend.m4 do its work. It works by 17014c0a534Smrg # looking at the text of this script. This case will never be run, 17114c0a534Smrg # since it is checked for above. 17214c0a534Smrg exit 1 17314c0a534Smrg ;; 17414c0a534Smrg 17514c0a534Smrgsgi) 17614c0a534Smrg if test "$libtool" = yes; then 17714c0a534Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 17814c0a534Smrg else 17914c0a534Smrg "$@" -MDupdate "$tmpdepfile" 18014c0a534Smrg fi 18114c0a534Smrg stat=$? 18214c0a534Smrg if test $stat -eq 0; then : 18314c0a534Smrg else 18414c0a534Smrg rm -f "$tmpdepfile" 18514c0a534Smrg exit $stat 18614c0a534Smrg fi 18714c0a534Smrg rm -f "$depfile" 18814c0a534Smrg 18914c0a534Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 19014c0a534Smrg echo "$object : \\" > "$depfile" 19114c0a534Smrg 19214c0a534Smrg # Clip off the initial element (the dependent). Don't try to be 19314c0a534Smrg # clever and replace this with sed code, as IRIX sed won't handle 19414c0a534Smrg # lines with more than a fixed number of characters (4096 in 19514c0a534Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 19614c0a534Smrg # the IRIX cc adds comments like `#:fec' to the end of the 19714c0a534Smrg # dependency line. 19814c0a534Smrg tr ' ' ' 19914c0a534Smrg' < "$tmpdepfile" \ 20014c0a534Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 20114c0a534Smrg tr ' 202bf2eeab3Smrg' ' ' >> "$depfile" 203bf2eeab3Smrg echo >> "$depfile" 20414c0a534Smrg 20514c0a534Smrg # The second pass generates a dummy entry for each header file. 20614c0a534Smrg tr ' ' ' 20714c0a534Smrg' < "$tmpdepfile" \ 20814c0a534Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209bf2eeab3Smrg >> "$depfile" 21014c0a534Smrg else 21114c0a534Smrg # The sourcefile does not contain any dependencies, so just 21214c0a534Smrg # store a dummy comment line, to avoid errors with the Makefile 21314c0a534Smrg # "include basename.Plo" scheme. 21414c0a534Smrg echo "#dummy" > "$depfile" 21514c0a534Smrg fi 21614c0a534Smrg rm -f "$tmpdepfile" 21714c0a534Smrg ;; 21814c0a534Smrg 21914c0a534Smrgaix) 22014c0a534Smrg # The C for AIX Compiler uses -M and outputs the dependencies 22114c0a534Smrg # in a .u file. In older versions, this file always lives in the 22214c0a534Smrg # current directory. Also, the AIX compiler puts `$object:' at the 22314c0a534Smrg # start of each line; $object doesn't have directory information. 22414c0a534Smrg # Version 6 uses the directory in both cases. 225bf2eeab3Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226bf2eeab3Smrg test "x$dir" = "x$object" && dir= 227bf2eeab3Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 22814c0a534Smrg if test "$libtool" = yes; then 229bf2eeab3Smrg tmpdepfile1=$dir$base.u 230bf2eeab3Smrg tmpdepfile2=$base.u 231bf2eeab3Smrg tmpdepfile3=$dir.libs/$base.u 23214c0a534Smrg "$@" -Wc,-M 23314c0a534Smrg else 234bf2eeab3Smrg tmpdepfile1=$dir$base.u 235bf2eeab3Smrg tmpdepfile2=$dir$base.u 236bf2eeab3Smrg tmpdepfile3=$dir$base.u 23714c0a534Smrg "$@" -M 23814c0a534Smrg fi 23914c0a534Smrg stat=$? 24014c0a534Smrg 24114c0a534Smrg if test $stat -eq 0; then : 24214c0a534Smrg else 243bf2eeab3Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24414c0a534Smrg exit $stat 24514c0a534Smrg fi 24614c0a534Smrg 247bf2eeab3Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248bf2eeab3Smrg do 249bf2eeab3Smrg test -f "$tmpdepfile" && break 250bf2eeab3Smrg done 25114c0a534Smrg if test -f "$tmpdepfile"; then 25214c0a534Smrg # Each line is of the form `foo.o: dependent.h'. 25314c0a534Smrg # Do two passes, one to just change these to 25414c0a534Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 255bf2eeab3Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256bf2eeab3Smrg # That's a tab and a space in the []. 257bf2eeab3Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 25814c0a534Smrg else 25914c0a534Smrg # The sourcefile does not contain any dependencies, so just 26014c0a534Smrg # store a dummy comment line, to avoid errors with the Makefile 26114c0a534Smrg # "include basename.Plo" scheme. 26214c0a534Smrg echo "#dummy" > "$depfile" 26314c0a534Smrg fi 26414c0a534Smrg rm -f "$tmpdepfile" 26514c0a534Smrg ;; 26614c0a534Smrg 26714c0a534Smrgicc) 26814c0a534Smrg # Intel's C compiler understands `-MD -MF file'. However on 26914c0a534Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 27014c0a534Smrg # ICC 7.0 will fill foo.d with something like 27114c0a534Smrg # foo.o: sub/foo.c 27214c0a534Smrg # foo.o: sub/foo.h 27314c0a534Smrg # which is wrong. We want: 27414c0a534Smrg # sub/foo.o: sub/foo.c 27514c0a534Smrg # sub/foo.o: sub/foo.h 27614c0a534Smrg # sub/foo.c: 27714c0a534Smrg # sub/foo.h: 27814c0a534Smrg # ICC 7.1 will output 27914c0a534Smrg # foo.o: sub/foo.c sub/foo.h 28014c0a534Smrg # and will wrap long lines using \ : 28114c0a534Smrg # foo.o: sub/foo.c ... \ 28214c0a534Smrg # sub/foo.h ... \ 28314c0a534Smrg # ... 28414c0a534Smrg 28514c0a534Smrg "$@" -MD -MF "$tmpdepfile" 28614c0a534Smrg stat=$? 28714c0a534Smrg if test $stat -eq 0; then : 28814c0a534Smrg else 28914c0a534Smrg rm -f "$tmpdepfile" 29014c0a534Smrg exit $stat 29114c0a534Smrg fi 29214c0a534Smrg rm -f "$depfile" 29314c0a534Smrg # Each line is of the form `foo.o: dependent.h', 29414c0a534Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 29514c0a534Smrg # Do two passes, one to just change these to 29614c0a534Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 29714c0a534Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 29814c0a534Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 29914c0a534Smrg # correctly. Breaking it into two sed invocations is a workaround. 30014c0a534Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 30114c0a534Smrg sed -e 's/$/ :/' >> "$depfile" 30214c0a534Smrg rm -f "$tmpdepfile" 30314c0a534Smrg ;; 30414c0a534Smrg 305bf2eeab3Smrghp2) 306bf2eeab3Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307bf2eeab3Smrg # compilers, which have integrated preprocessors. The correct option 308bf2eeab3Smrg # to use with these is +Maked; it writes dependencies to a file named 309bf2eeab3Smrg # 'foo.d', which lands next to the object file, wherever that 310bf2eeab3Smrg # happens to be. 311bf2eeab3Smrg # Much of this is similar to the tru64 case; see comments there. 312bf2eeab3Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313bf2eeab3Smrg test "x$dir" = "x$object" && dir= 314bf2eeab3Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315bf2eeab3Smrg if test "$libtool" = yes; then 316bf2eeab3Smrg tmpdepfile1=$dir$base.d 317bf2eeab3Smrg tmpdepfile2=$dir.libs/$base.d 318bf2eeab3Smrg "$@" -Wc,+Maked 319bf2eeab3Smrg else 320bf2eeab3Smrg tmpdepfile1=$dir$base.d 321bf2eeab3Smrg tmpdepfile2=$dir$base.d 322bf2eeab3Smrg "$@" +Maked 323bf2eeab3Smrg fi 324bf2eeab3Smrg stat=$? 325bf2eeab3Smrg if test $stat -eq 0; then : 326bf2eeab3Smrg else 327bf2eeab3Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 328bf2eeab3Smrg exit $stat 329bf2eeab3Smrg fi 330bf2eeab3Smrg 331bf2eeab3Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332bf2eeab3Smrg do 333bf2eeab3Smrg test -f "$tmpdepfile" && break 334bf2eeab3Smrg done 335bf2eeab3Smrg if test -f "$tmpdepfile"; then 336bf2eeab3Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337bf2eeab3Smrg # Add `dependent.h:' lines. 338bf2eeab3Smrg sed -ne '2,${ 339bf2eeab3Smrg s/^ *// 340bf2eeab3Smrg s/ \\*$// 341bf2eeab3Smrg s/$/:/ 342bf2eeab3Smrg p 343bf2eeab3Smrg }' "$tmpdepfile" >> "$depfile" 344bf2eeab3Smrg else 345bf2eeab3Smrg echo "#dummy" > "$depfile" 346bf2eeab3Smrg fi 347bf2eeab3Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 348bf2eeab3Smrg ;; 349bf2eeab3Smrg 35014c0a534Smrgtru64) 35114c0a534Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 35214c0a534Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 35314c0a534Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 35414c0a534Smrg # dependencies in `foo.d' instead, so we check for that too. 35514c0a534Smrg # Subdirectories are respected. 35614c0a534Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 35714c0a534Smrg test "x$dir" = "x$object" && dir= 35814c0a534Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 35914c0a534Smrg 36014c0a534Smrg if test "$libtool" = yes; then 36114c0a534Smrg # With Tru64 cc, shared objects can also be used to make a 362bf2eeab3Smrg # static library. This mechanism is used in libtool 1.4 series to 36314c0a534Smrg # handle both shared and static libraries in a single compilation. 36414c0a534Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 36514c0a534Smrg # 36614c0a534Smrg # With libtool 1.5 this exception was removed, and libtool now 36714c0a534Smrg # generates 2 separate objects for the 2 libraries. These two 368bf2eeab3Smrg # compilations output dependencies in $dir.libs/$base.o.d and 36914c0a534Smrg # in $dir$base.o.d. We have to check for both files, because 37014c0a534Smrg # one of the two compilations can be disabled. We should prefer 37114c0a534Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 37214c0a534Smrg # automatically cleaned when .libs/ is deleted, while ignoring 37314c0a534Smrg # the former would cause a distcleancheck panic. 37414c0a534Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 37514c0a534Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 37614c0a534Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 37714c0a534Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 37814c0a534Smrg "$@" -Wc,-MD 37914c0a534Smrg else 38014c0a534Smrg tmpdepfile1=$dir$base.o.d 38114c0a534Smrg tmpdepfile2=$dir$base.d 38214c0a534Smrg tmpdepfile3=$dir$base.d 38314c0a534Smrg tmpdepfile4=$dir$base.d 38414c0a534Smrg "$@" -MD 38514c0a534Smrg fi 38614c0a534Smrg 38714c0a534Smrg stat=$? 38814c0a534Smrg if test $stat -eq 0; then : 38914c0a534Smrg else 39014c0a534Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39114c0a534Smrg exit $stat 39214c0a534Smrg fi 39314c0a534Smrg 39414c0a534Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39514c0a534Smrg do 39614c0a534Smrg test -f "$tmpdepfile" && break 39714c0a534Smrg done 39814c0a534Smrg if test -f "$tmpdepfile"; then 39914c0a534Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 40014c0a534Smrg # That's a tab and a space in the []. 40114c0a534Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 40214c0a534Smrg else 40314c0a534Smrg echo "#dummy" > "$depfile" 40414c0a534Smrg fi 40514c0a534Smrg rm -f "$tmpdepfile" 40614c0a534Smrg ;; 40714c0a534Smrg 40814c0a534Smrg#nosideeffect) 40914c0a534Smrg # This comment above is used by automake to tell side-effect 41014c0a534Smrg # dependency tracking mechanisms from slower ones. 41114c0a534Smrg 41214c0a534Smrgdashmstdout) 41314c0a534Smrg # Important note: in order to support this mode, a compiler *must* 41414c0a534Smrg # always write the preprocessed file to stdout, regardless of -o. 41514c0a534Smrg "$@" || exit $? 41614c0a534Smrg 41714c0a534Smrg # Remove the call to Libtool. 41814c0a534Smrg if test "$libtool" = yes; then 419bf2eeab3Smrg while test "X$1" != 'X--mode=compile'; do 42014c0a534Smrg shift 42114c0a534Smrg done 42214c0a534Smrg shift 42314c0a534Smrg fi 42414c0a534Smrg 42514c0a534Smrg # Remove `-o $object'. 42614c0a534Smrg IFS=" " 42714c0a534Smrg for arg 42814c0a534Smrg do 42914c0a534Smrg case $arg in 43014c0a534Smrg -o) 43114c0a534Smrg shift 43214c0a534Smrg ;; 43314c0a534Smrg $object) 43414c0a534Smrg shift 43514c0a534Smrg ;; 43614c0a534Smrg *) 43714c0a534Smrg set fnord "$@" "$arg" 43814c0a534Smrg shift # fnord 43914c0a534Smrg shift # $arg 44014c0a534Smrg ;; 44114c0a534Smrg esac 44214c0a534Smrg done 44314c0a534Smrg 44414c0a534Smrg test -z "$dashmflag" && dashmflag=-M 44514c0a534Smrg # Require at least two characters before searching for `:' 44614c0a534Smrg # in the target name. This is to cope with DOS-style filenames: 44714c0a534Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 44814c0a534Smrg "$@" $dashmflag | 44914c0a534Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 45014c0a534Smrg rm -f "$depfile" 45114c0a534Smrg cat < "$tmpdepfile" > "$depfile" 45214c0a534Smrg tr ' ' ' 45314c0a534Smrg' < "$tmpdepfile" | \ 45414c0a534Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 45514c0a534Smrg## correctly. Breaking it into two sed invocations is a workaround. 45614c0a534Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 45714c0a534Smrg rm -f "$tmpdepfile" 45814c0a534Smrg ;; 45914c0a534Smrg 46014c0a534SmrgdashXmstdout) 46114c0a534Smrg # This case only exists to satisfy depend.m4. It is never actually 46214c0a534Smrg # run, as this mode is specially recognized in the preamble. 46314c0a534Smrg exit 1 46414c0a534Smrg ;; 46514c0a534Smrg 46614c0a534Smrgmakedepend) 46714c0a534Smrg "$@" || exit $? 46814c0a534Smrg # Remove any Libtool call 46914c0a534Smrg if test "$libtool" = yes; then 470bf2eeab3Smrg while test "X$1" != 'X--mode=compile'; do 47114c0a534Smrg shift 47214c0a534Smrg done 47314c0a534Smrg shift 47414c0a534Smrg fi 47514c0a534Smrg # X makedepend 47614c0a534Smrg shift 477bf2eeab3Smrg cleared=no eat=no 478bf2eeab3Smrg for arg 479bf2eeab3Smrg do 48014c0a534Smrg case $cleared in 48114c0a534Smrg no) 48214c0a534Smrg set ""; shift 48314c0a534Smrg cleared=yes ;; 48414c0a534Smrg esac 485bf2eeab3Smrg if test $eat = yes; then 486bf2eeab3Smrg eat=no 487bf2eeab3Smrg continue 488bf2eeab3Smrg fi 48914c0a534Smrg case "$arg" in 49014c0a534Smrg -D*|-I*) 49114c0a534Smrg set fnord "$@" "$arg"; shift ;; 49214c0a534Smrg # Strip any option that makedepend may not understand. Remove 49314c0a534Smrg # the object too, otherwise makedepend will parse it as a source file. 494bf2eeab3Smrg -arch) 495bf2eeab3Smrg eat=yes ;; 49614c0a534Smrg -*|$object) 49714c0a534Smrg ;; 49814c0a534Smrg *) 49914c0a534Smrg set fnord "$@" "$arg"; shift ;; 50014c0a534Smrg esac 50114c0a534Smrg done 502bf2eeab3Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 50314c0a534Smrg touch "$tmpdepfile" 50414c0a534Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 50514c0a534Smrg rm -f "$depfile" 50614c0a534Smrg cat < "$tmpdepfile" > "$depfile" 50714c0a534Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 50814c0a534Smrg' | \ 50914c0a534Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 51014c0a534Smrg## correctly. Breaking it into two sed invocations is a workaround. 51114c0a534Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 51214c0a534Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 51314c0a534Smrg ;; 51414c0a534Smrg 51514c0a534Smrgcpp) 51614c0a534Smrg # Important note: in order to support this mode, a compiler *must* 51714c0a534Smrg # always write the preprocessed file to stdout. 51814c0a534Smrg "$@" || exit $? 51914c0a534Smrg 52014c0a534Smrg # Remove the call to Libtool. 52114c0a534Smrg if test "$libtool" = yes; then 522bf2eeab3Smrg while test "X$1" != 'X--mode=compile'; do 52314c0a534Smrg shift 52414c0a534Smrg done 52514c0a534Smrg shift 52614c0a534Smrg fi 52714c0a534Smrg 52814c0a534Smrg # Remove `-o $object'. 52914c0a534Smrg IFS=" " 53014c0a534Smrg for arg 53114c0a534Smrg do 53214c0a534Smrg case $arg in 53314c0a534Smrg -o) 53414c0a534Smrg shift 53514c0a534Smrg ;; 53614c0a534Smrg $object) 53714c0a534Smrg shift 53814c0a534Smrg ;; 53914c0a534Smrg *) 54014c0a534Smrg set fnord "$@" "$arg" 54114c0a534Smrg shift # fnord 54214c0a534Smrg shift # $arg 54314c0a534Smrg ;; 54414c0a534Smrg esac 54514c0a534Smrg done 54614c0a534Smrg 54714c0a534Smrg "$@" -E | 54814c0a534Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 54914c0a534Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 55014c0a534Smrg sed '$ s: \\$::' > "$tmpdepfile" 55114c0a534Smrg rm -f "$depfile" 55214c0a534Smrg echo "$object : \\" > "$depfile" 55314c0a534Smrg cat < "$tmpdepfile" >> "$depfile" 55414c0a534Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 55514c0a534Smrg rm -f "$tmpdepfile" 55614c0a534Smrg ;; 55714c0a534Smrg 55814c0a534Smrgmsvisualcpp) 55914c0a534Smrg # Important note: in order to support this mode, a compiler *must* 560bf2eeab3Smrg # always write the preprocessed file to stdout. 56114c0a534Smrg "$@" || exit $? 562bf2eeab3Smrg 563bf2eeab3Smrg # Remove the call to Libtool. 564bf2eeab3Smrg if test "$libtool" = yes; then 565bf2eeab3Smrg while test "X$1" != 'X--mode=compile'; do 566bf2eeab3Smrg shift 567bf2eeab3Smrg done 568bf2eeab3Smrg shift 569bf2eeab3Smrg fi 570bf2eeab3Smrg 57114c0a534Smrg IFS=" " 57214c0a534Smrg for arg 57314c0a534Smrg do 57414c0a534Smrg case "$arg" in 575bf2eeab3Smrg -o) 576bf2eeab3Smrg shift 577bf2eeab3Smrg ;; 578bf2eeab3Smrg $object) 579bf2eeab3Smrg shift 580bf2eeab3Smrg ;; 58114c0a534Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 58214c0a534Smrg set fnord "$@" 58314c0a534Smrg shift 58414c0a534Smrg shift 58514c0a534Smrg ;; 58614c0a534Smrg *) 58714c0a534Smrg set fnord "$@" "$arg" 58814c0a534Smrg shift 58914c0a534Smrg shift 59014c0a534Smrg ;; 59114c0a534Smrg esac 59214c0a534Smrg done 593bf2eeab3Smrg "$@" -E 2>/dev/null | 594bf2eeab3Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 59514c0a534Smrg rm -f "$depfile" 59614c0a534Smrg echo "$object : \\" > "$depfile" 597bf2eeab3Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 59814c0a534Smrg echo " " >> "$depfile" 599bf2eeab3Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 60014c0a534Smrg rm -f "$tmpdepfile" 60114c0a534Smrg ;; 60214c0a534Smrg 603bf2eeab3Smrgmsvcmsys) 604bf2eeab3Smrg # This case exists only to let depend.m4 do its work. It works by 605bf2eeab3Smrg # looking at the text of this script. This case will never be run, 606bf2eeab3Smrg # since it is checked for above. 607bf2eeab3Smrg exit 1 608bf2eeab3Smrg ;; 609bf2eeab3Smrg 61014c0a534Smrgnone) 61114c0a534Smrg exec "$@" 61214c0a534Smrg ;; 61314c0a534Smrg 61414c0a534Smrg*) 61514c0a534Smrg echo "Unknown depmode $depmode" 1>&2 61614c0a534Smrg exit 1 61714c0a534Smrg ;; 61814c0a534Smrgesac 61914c0a534Smrg 62014c0a534Smrgexit 0 62114c0a534Smrg 62214c0a534Smrg# Local Variables: 62314c0a534Smrg# mode: shell-script 62414c0a534Smrg# sh-indentation: 2 62514c0a534Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 62614c0a534Smrg# time-stamp-start: "scriptversion=" 62714c0a534Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 628bf2eeab3Smrg# time-stamp-time-zone: "UTC" 629bf2eeab3Smrg# time-stamp-end: "; # UTC" 63014c0a534Smrg# End: 631