depcomp revision 14c0a534
114c0a534Smrg#! /bin/sh 214c0a534Smrg# depcomp - compile a program generating dependencies as side-effects 314c0a534Smrg 414c0a534Smrgscriptversion=2005-07-09.11 514c0a534Smrg 614c0a534Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 714c0a534Smrg 814c0a534Smrg# This program is free software; you can redistribute it and/or modify 914c0a534Smrg# it under the terms of the GNU General Public License as published by 1014c0a534Smrg# the Free Software Foundation; either version 2, or (at your option) 1114c0a534Smrg# any later version. 1214c0a534Smrg 1314c0a534Smrg# This program is distributed in the hope that it will be useful, 1414c0a534Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1514c0a534Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1614c0a534Smrg# GNU General Public License for more details. 1714c0a534Smrg 1814c0a534Smrg# You should have received a copy of the GNU General Public License 1914c0a534Smrg# along with this program; if not, write to the Free Software 2014c0a534Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2114c0a534Smrg# 02110-1301, USA. 2214c0a534Smrg 2314c0a534Smrg# As a special exception to the GNU General Public License, if you 2414c0a534Smrg# distribute this file as part of a program that contains a 2514c0a534Smrg# configuration script generated by Autoconf, you may include it under 2614c0a534Smrg# the same distribution terms that you use for the rest of that program. 2714c0a534Smrg 2814c0a534Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2914c0a534Smrg 3014c0a534Smrgcase $1 in 3114c0a534Smrg '') 3214c0a534Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3314c0a534Smrg exit 1; 3414c0a534Smrg ;; 3514c0a534Smrg -h | --h*) 3614c0a534Smrg cat <<\EOF 3714c0a534SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3814c0a534Smrg 3914c0a534SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 4014c0a534Smrgas side-effects. 4114c0a534Smrg 4214c0a534SmrgEnvironment variables: 4314c0a534Smrg depmode Dependency tracking mode. 4414c0a534Smrg source Source file read by `PROGRAMS ARGS'. 4514c0a534Smrg object Object file output by `PROGRAMS ARGS'. 4614c0a534Smrg DEPDIR directory where to store dependencies. 4714c0a534Smrg depfile Dependency file to output. 4814c0a534Smrg tmpdepfile Temporary file to use when outputing dependencies. 4914c0a534Smrg libtool Whether libtool is used (yes/no). 5014c0a534Smrg 5114c0a534SmrgReport bugs to <bug-automake@gnu.org>. 5214c0a534SmrgEOF 5314c0a534Smrg exit $? 5414c0a534Smrg ;; 5514c0a534Smrg -v | --v*) 5614c0a534Smrg echo "depcomp $scriptversion" 5714c0a534Smrg exit $? 5814c0a534Smrg ;; 5914c0a534Smrgesac 6014c0a534Smrg 6114c0a534Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6214c0a534Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6314c0a534Smrg exit 1 6414c0a534Smrgfi 6514c0a534Smrg 6614c0a534Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6714c0a534Smrgdepfile=${depfile-`echo "$object" | 6814c0a534Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6914c0a534Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 7014c0a534Smrg 7114c0a534Smrgrm -f "$tmpdepfile" 7214c0a534Smrg 7314c0a534Smrg# Some modes work just like other modes, but use different flags. We 7414c0a534Smrg# parameterize here, but still list the modes in the big case below, 7514c0a534Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7614c0a534Smrg# here, because this file can only contain one case statement. 7714c0a534Smrgif test "$depmode" = hp; then 7814c0a534Smrg # HP compiler uses -M and no extra arg. 7914c0a534Smrg gccflag=-M 8014c0a534Smrg depmode=gcc 8114c0a534Smrgfi 8214c0a534Smrg 8314c0a534Smrgif test "$depmode" = dashXmstdout; then 8414c0a534Smrg # This is just like dashmstdout with a different argument. 8514c0a534Smrg dashmflag=-xM 8614c0a534Smrg depmode=dashmstdout 8714c0a534Smrgfi 8814c0a534Smrg 8914c0a534Smrgcase "$depmode" in 9014c0a534Smrggcc3) 9114c0a534Smrg## gcc 3 implements dependency tracking that does exactly what 9214c0a534Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 9314c0a534Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 9414c0a534Smrg "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 9514c0a534Smrg stat=$? 9614c0a534Smrg if test $stat -eq 0; then : 9714c0a534Smrg else 9814c0a534Smrg rm -f "$tmpdepfile" 9914c0a534Smrg exit $stat 10014c0a534Smrg fi 10114c0a534Smrg mv "$tmpdepfile" "$depfile" 10214c0a534Smrg ;; 10314c0a534Smrg 10414c0a534Smrggcc) 10514c0a534Smrg## There are various ways to get dependency output from gcc. Here's 10614c0a534Smrg## why we pick this rather obscure method: 10714c0a534Smrg## - Don't want to use -MD because we'd like the dependencies to end 10814c0a534Smrg## up in a subdir. Having to rename by hand is ugly. 10914c0a534Smrg## (We might end up doing this anyway to support other compilers.) 11014c0a534Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 11114c0a534Smrg## -MM, not -M (despite what the docs say). 11214c0a534Smrg## - Using -M directly means running the compiler twice (even worse 11314c0a534Smrg## than renaming). 11414c0a534Smrg if test -z "$gccflag"; then 11514c0a534Smrg gccflag=-MD, 11614c0a534Smrg fi 11714c0a534Smrg "$@" -Wp,"$gccflag$tmpdepfile" 11814c0a534Smrg stat=$? 11914c0a534Smrg if test $stat -eq 0; then : 12014c0a534Smrg else 12114c0a534Smrg rm -f "$tmpdepfile" 12214c0a534Smrg exit $stat 12314c0a534Smrg fi 12414c0a534Smrg rm -f "$depfile" 12514c0a534Smrg echo "$object : \\" > "$depfile" 12614c0a534Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 12714c0a534Smrg## The second -e expression handles DOS-style file names with drive letters. 12814c0a534Smrg sed -e 's/^[^:]*: / /' \ 12914c0a534Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 13014c0a534Smrg## This next piece of magic avoids the `deleted header file' problem. 13114c0a534Smrg## The problem is that when a header file which appears in a .P file 13214c0a534Smrg## is deleted, the dependency causes make to die (because there is 13314c0a534Smrg## typically no way to rebuild the header). We avoid this by adding 13414c0a534Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 13514c0a534Smrg## this for us directly. 13614c0a534Smrg tr ' ' ' 13714c0a534Smrg' < "$tmpdepfile" | 13814c0a534Smrg## Some versions of gcc put a space before the `:'. On the theory 13914c0a534Smrg## that the space means something, we add a space to the output as 14014c0a534Smrg## well. 14114c0a534Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 14214c0a534Smrg## correctly. Breaking it into two sed invocations is a workaround. 14314c0a534Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 14414c0a534Smrg rm -f "$tmpdepfile" 14514c0a534Smrg ;; 14614c0a534Smrg 14714c0a534Smrghp) 14814c0a534Smrg # This case exists only to let depend.m4 do its work. It works by 14914c0a534Smrg # looking at the text of this script. This case will never be run, 15014c0a534Smrg # since it is checked for above. 15114c0a534Smrg exit 1 15214c0a534Smrg ;; 15314c0a534Smrg 15414c0a534Smrgsgi) 15514c0a534Smrg if test "$libtool" = yes; then 15614c0a534Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 15714c0a534Smrg else 15814c0a534Smrg "$@" -MDupdate "$tmpdepfile" 15914c0a534Smrg fi 16014c0a534Smrg stat=$? 16114c0a534Smrg if test $stat -eq 0; then : 16214c0a534Smrg else 16314c0a534Smrg rm -f "$tmpdepfile" 16414c0a534Smrg exit $stat 16514c0a534Smrg fi 16614c0a534Smrg rm -f "$depfile" 16714c0a534Smrg 16814c0a534Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 16914c0a534Smrg echo "$object : \\" > "$depfile" 17014c0a534Smrg 17114c0a534Smrg # Clip off the initial element (the dependent). Don't try to be 17214c0a534Smrg # clever and replace this with sed code, as IRIX sed won't handle 17314c0a534Smrg # lines with more than a fixed number of characters (4096 in 17414c0a534Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 17514c0a534Smrg # the IRIX cc adds comments like `#:fec' to the end of the 17614c0a534Smrg # dependency line. 17714c0a534Smrg tr ' ' ' 17814c0a534Smrg' < "$tmpdepfile" \ 17914c0a534Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 18014c0a534Smrg tr ' 18114c0a534Smrg' ' ' >> $depfile 18214c0a534Smrg echo >> $depfile 18314c0a534Smrg 18414c0a534Smrg # The second pass generates a dummy entry for each header file. 18514c0a534Smrg tr ' ' ' 18614c0a534Smrg' < "$tmpdepfile" \ 18714c0a534Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 18814c0a534Smrg >> $depfile 18914c0a534Smrg else 19014c0a534Smrg # The sourcefile does not contain any dependencies, so just 19114c0a534Smrg # store a dummy comment line, to avoid errors with the Makefile 19214c0a534Smrg # "include basename.Plo" scheme. 19314c0a534Smrg echo "#dummy" > "$depfile" 19414c0a534Smrg fi 19514c0a534Smrg rm -f "$tmpdepfile" 19614c0a534Smrg ;; 19714c0a534Smrg 19814c0a534Smrgaix) 19914c0a534Smrg # The C for AIX Compiler uses -M and outputs the dependencies 20014c0a534Smrg # in a .u file. In older versions, this file always lives in the 20114c0a534Smrg # current directory. Also, the AIX compiler puts `$object:' at the 20214c0a534Smrg # start of each line; $object doesn't have directory information. 20314c0a534Smrg # Version 6 uses the directory in both cases. 20414c0a534Smrg stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` 20514c0a534Smrg tmpdepfile="$stripped.u" 20614c0a534Smrg if test "$libtool" = yes; then 20714c0a534Smrg "$@" -Wc,-M 20814c0a534Smrg else 20914c0a534Smrg "$@" -M 21014c0a534Smrg fi 21114c0a534Smrg stat=$? 21214c0a534Smrg 21314c0a534Smrg if test -f "$tmpdepfile"; then : 21414c0a534Smrg else 21514c0a534Smrg stripped=`echo "$stripped" | sed 's,^.*/,,'` 21614c0a534Smrg tmpdepfile="$stripped.u" 21714c0a534Smrg fi 21814c0a534Smrg 21914c0a534Smrg if test $stat -eq 0; then : 22014c0a534Smrg else 22114c0a534Smrg rm -f "$tmpdepfile" 22214c0a534Smrg exit $stat 22314c0a534Smrg fi 22414c0a534Smrg 22514c0a534Smrg if test -f "$tmpdepfile"; then 22614c0a534Smrg outname="$stripped.o" 22714c0a534Smrg # Each line is of the form `foo.o: dependent.h'. 22814c0a534Smrg # Do two passes, one to just change these to 22914c0a534Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 23014c0a534Smrg sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" 23114c0a534Smrg sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" 23214c0a534Smrg else 23314c0a534Smrg # The sourcefile does not contain any dependencies, so just 23414c0a534Smrg # store a dummy comment line, to avoid errors with the Makefile 23514c0a534Smrg # "include basename.Plo" scheme. 23614c0a534Smrg echo "#dummy" > "$depfile" 23714c0a534Smrg fi 23814c0a534Smrg rm -f "$tmpdepfile" 23914c0a534Smrg ;; 24014c0a534Smrg 24114c0a534Smrgicc) 24214c0a534Smrg # Intel's C compiler understands `-MD -MF file'. However on 24314c0a534Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 24414c0a534Smrg # ICC 7.0 will fill foo.d with something like 24514c0a534Smrg # foo.o: sub/foo.c 24614c0a534Smrg # foo.o: sub/foo.h 24714c0a534Smrg # which is wrong. We want: 24814c0a534Smrg # sub/foo.o: sub/foo.c 24914c0a534Smrg # sub/foo.o: sub/foo.h 25014c0a534Smrg # sub/foo.c: 25114c0a534Smrg # sub/foo.h: 25214c0a534Smrg # ICC 7.1 will output 25314c0a534Smrg # foo.o: sub/foo.c sub/foo.h 25414c0a534Smrg # and will wrap long lines using \ : 25514c0a534Smrg # foo.o: sub/foo.c ... \ 25614c0a534Smrg # sub/foo.h ... \ 25714c0a534Smrg # ... 25814c0a534Smrg 25914c0a534Smrg "$@" -MD -MF "$tmpdepfile" 26014c0a534Smrg stat=$? 26114c0a534Smrg if test $stat -eq 0; then : 26214c0a534Smrg else 26314c0a534Smrg rm -f "$tmpdepfile" 26414c0a534Smrg exit $stat 26514c0a534Smrg fi 26614c0a534Smrg rm -f "$depfile" 26714c0a534Smrg # Each line is of the form `foo.o: dependent.h', 26814c0a534Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 26914c0a534Smrg # Do two passes, one to just change these to 27014c0a534Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 27114c0a534Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 27214c0a534Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 27314c0a534Smrg # correctly. Breaking it into two sed invocations is a workaround. 27414c0a534Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 27514c0a534Smrg sed -e 's/$/ :/' >> "$depfile" 27614c0a534Smrg rm -f "$tmpdepfile" 27714c0a534Smrg ;; 27814c0a534Smrg 27914c0a534Smrgtru64) 28014c0a534Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 28114c0a534Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 28214c0a534Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 28314c0a534Smrg # dependencies in `foo.d' instead, so we check for that too. 28414c0a534Smrg # Subdirectories are respected. 28514c0a534Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 28614c0a534Smrg test "x$dir" = "x$object" && dir= 28714c0a534Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 28814c0a534Smrg 28914c0a534Smrg if test "$libtool" = yes; then 29014c0a534Smrg # With Tru64 cc, shared objects can also be used to make a 29114c0a534Smrg # static library. This mecanism is used in libtool 1.4 series to 29214c0a534Smrg # handle both shared and static libraries in a single compilation. 29314c0a534Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 29414c0a534Smrg # 29514c0a534Smrg # With libtool 1.5 this exception was removed, and libtool now 29614c0a534Smrg # generates 2 separate objects for the 2 libraries. These two 29714c0a534Smrg # compilations output dependencies in in $dir.libs/$base.o.d and 29814c0a534Smrg # in $dir$base.o.d. We have to check for both files, because 29914c0a534Smrg # one of the two compilations can be disabled. We should prefer 30014c0a534Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 30114c0a534Smrg # automatically cleaned when .libs/ is deleted, while ignoring 30214c0a534Smrg # the former would cause a distcleancheck panic. 30314c0a534Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 30414c0a534Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 30514c0a534Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 30614c0a534Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 30714c0a534Smrg "$@" -Wc,-MD 30814c0a534Smrg else 30914c0a534Smrg tmpdepfile1=$dir$base.o.d 31014c0a534Smrg tmpdepfile2=$dir$base.d 31114c0a534Smrg tmpdepfile3=$dir$base.d 31214c0a534Smrg tmpdepfile4=$dir$base.d 31314c0a534Smrg "$@" -MD 31414c0a534Smrg fi 31514c0a534Smrg 31614c0a534Smrg stat=$? 31714c0a534Smrg if test $stat -eq 0; then : 31814c0a534Smrg else 31914c0a534Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 32014c0a534Smrg exit $stat 32114c0a534Smrg fi 32214c0a534Smrg 32314c0a534Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 32414c0a534Smrg do 32514c0a534Smrg test -f "$tmpdepfile" && break 32614c0a534Smrg done 32714c0a534Smrg if test -f "$tmpdepfile"; then 32814c0a534Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 32914c0a534Smrg # That's a tab and a space in the []. 33014c0a534Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 33114c0a534Smrg else 33214c0a534Smrg echo "#dummy" > "$depfile" 33314c0a534Smrg fi 33414c0a534Smrg rm -f "$tmpdepfile" 33514c0a534Smrg ;; 33614c0a534Smrg 33714c0a534Smrg#nosideeffect) 33814c0a534Smrg # This comment above is used by automake to tell side-effect 33914c0a534Smrg # dependency tracking mechanisms from slower ones. 34014c0a534Smrg 34114c0a534Smrgdashmstdout) 34214c0a534Smrg # Important note: in order to support this mode, a compiler *must* 34314c0a534Smrg # always write the preprocessed file to stdout, regardless of -o. 34414c0a534Smrg "$@" || exit $? 34514c0a534Smrg 34614c0a534Smrg # Remove the call to Libtool. 34714c0a534Smrg if test "$libtool" = yes; then 34814c0a534Smrg while test $1 != '--mode=compile'; do 34914c0a534Smrg shift 35014c0a534Smrg done 35114c0a534Smrg shift 35214c0a534Smrg fi 35314c0a534Smrg 35414c0a534Smrg # Remove `-o $object'. 35514c0a534Smrg IFS=" " 35614c0a534Smrg for arg 35714c0a534Smrg do 35814c0a534Smrg case $arg in 35914c0a534Smrg -o) 36014c0a534Smrg shift 36114c0a534Smrg ;; 36214c0a534Smrg $object) 36314c0a534Smrg shift 36414c0a534Smrg ;; 36514c0a534Smrg *) 36614c0a534Smrg set fnord "$@" "$arg" 36714c0a534Smrg shift # fnord 36814c0a534Smrg shift # $arg 36914c0a534Smrg ;; 37014c0a534Smrg esac 37114c0a534Smrg done 37214c0a534Smrg 37314c0a534Smrg test -z "$dashmflag" && dashmflag=-M 37414c0a534Smrg # Require at least two characters before searching for `:' 37514c0a534Smrg # in the target name. This is to cope with DOS-style filenames: 37614c0a534Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 37714c0a534Smrg "$@" $dashmflag | 37814c0a534Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 37914c0a534Smrg rm -f "$depfile" 38014c0a534Smrg cat < "$tmpdepfile" > "$depfile" 38114c0a534Smrg tr ' ' ' 38214c0a534Smrg' < "$tmpdepfile" | \ 38314c0a534Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 38414c0a534Smrg## correctly. Breaking it into two sed invocations is a workaround. 38514c0a534Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 38614c0a534Smrg rm -f "$tmpdepfile" 38714c0a534Smrg ;; 38814c0a534Smrg 38914c0a534SmrgdashXmstdout) 39014c0a534Smrg # This case only exists to satisfy depend.m4. It is never actually 39114c0a534Smrg # run, as this mode is specially recognized in the preamble. 39214c0a534Smrg exit 1 39314c0a534Smrg ;; 39414c0a534Smrg 39514c0a534Smrgmakedepend) 39614c0a534Smrg "$@" || exit $? 39714c0a534Smrg # Remove any Libtool call 39814c0a534Smrg if test "$libtool" = yes; then 39914c0a534Smrg while test $1 != '--mode=compile'; do 40014c0a534Smrg shift 40114c0a534Smrg done 40214c0a534Smrg shift 40314c0a534Smrg fi 40414c0a534Smrg # X makedepend 40514c0a534Smrg shift 40614c0a534Smrg cleared=no 40714c0a534Smrg for arg in "$@"; do 40814c0a534Smrg case $cleared in 40914c0a534Smrg no) 41014c0a534Smrg set ""; shift 41114c0a534Smrg cleared=yes ;; 41214c0a534Smrg esac 41314c0a534Smrg case "$arg" in 41414c0a534Smrg -D*|-I*) 41514c0a534Smrg set fnord "$@" "$arg"; shift ;; 41614c0a534Smrg # Strip any option that makedepend may not understand. Remove 41714c0a534Smrg # the object too, otherwise makedepend will parse it as a source file. 41814c0a534Smrg -*|$object) 41914c0a534Smrg ;; 42014c0a534Smrg *) 42114c0a534Smrg set fnord "$@" "$arg"; shift ;; 42214c0a534Smrg esac 42314c0a534Smrg done 42414c0a534Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 42514c0a534Smrg touch "$tmpdepfile" 42614c0a534Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 42714c0a534Smrg rm -f "$depfile" 42814c0a534Smrg cat < "$tmpdepfile" > "$depfile" 42914c0a534Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 43014c0a534Smrg' | \ 43114c0a534Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 43214c0a534Smrg## correctly. Breaking it into two sed invocations is a workaround. 43314c0a534Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 43414c0a534Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 43514c0a534Smrg ;; 43614c0a534Smrg 43714c0a534Smrgcpp) 43814c0a534Smrg # Important note: in order to support this mode, a compiler *must* 43914c0a534Smrg # always write the preprocessed file to stdout. 44014c0a534Smrg "$@" || exit $? 44114c0a534Smrg 44214c0a534Smrg # Remove the call to Libtool. 44314c0a534Smrg if test "$libtool" = yes; then 44414c0a534Smrg while test $1 != '--mode=compile'; do 44514c0a534Smrg shift 44614c0a534Smrg done 44714c0a534Smrg shift 44814c0a534Smrg fi 44914c0a534Smrg 45014c0a534Smrg # Remove `-o $object'. 45114c0a534Smrg IFS=" " 45214c0a534Smrg for arg 45314c0a534Smrg do 45414c0a534Smrg case $arg in 45514c0a534Smrg -o) 45614c0a534Smrg shift 45714c0a534Smrg ;; 45814c0a534Smrg $object) 45914c0a534Smrg shift 46014c0a534Smrg ;; 46114c0a534Smrg *) 46214c0a534Smrg set fnord "$@" "$arg" 46314c0a534Smrg shift # fnord 46414c0a534Smrg shift # $arg 46514c0a534Smrg ;; 46614c0a534Smrg esac 46714c0a534Smrg done 46814c0a534Smrg 46914c0a534Smrg "$@" -E | 47014c0a534Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 47114c0a534Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 47214c0a534Smrg sed '$ s: \\$::' > "$tmpdepfile" 47314c0a534Smrg rm -f "$depfile" 47414c0a534Smrg echo "$object : \\" > "$depfile" 47514c0a534Smrg cat < "$tmpdepfile" >> "$depfile" 47614c0a534Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 47714c0a534Smrg rm -f "$tmpdepfile" 47814c0a534Smrg ;; 47914c0a534Smrg 48014c0a534Smrgmsvisualcpp) 48114c0a534Smrg # Important note: in order to support this mode, a compiler *must* 48214c0a534Smrg # always write the preprocessed file to stdout, regardless of -o, 48314c0a534Smrg # because we must use -o when running libtool. 48414c0a534Smrg "$@" || exit $? 48514c0a534Smrg IFS=" " 48614c0a534Smrg for arg 48714c0a534Smrg do 48814c0a534Smrg case "$arg" in 48914c0a534Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 49014c0a534Smrg set fnord "$@" 49114c0a534Smrg shift 49214c0a534Smrg shift 49314c0a534Smrg ;; 49414c0a534Smrg *) 49514c0a534Smrg set fnord "$@" "$arg" 49614c0a534Smrg shift 49714c0a534Smrg shift 49814c0a534Smrg ;; 49914c0a534Smrg esac 50014c0a534Smrg done 50114c0a534Smrg "$@" -E | 50214c0a534Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 50314c0a534Smrg rm -f "$depfile" 50414c0a534Smrg echo "$object : \\" > "$depfile" 50514c0a534Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 50614c0a534Smrg echo " " >> "$depfile" 50714c0a534Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 50814c0a534Smrg rm -f "$tmpdepfile" 50914c0a534Smrg ;; 51014c0a534Smrg 51114c0a534Smrgnone) 51214c0a534Smrg exec "$@" 51314c0a534Smrg ;; 51414c0a534Smrg 51514c0a534Smrg*) 51614c0a534Smrg echo "Unknown depmode $depmode" 1>&2 51714c0a534Smrg exit 1 51814c0a534Smrg ;; 51914c0a534Smrgesac 52014c0a534Smrg 52114c0a534Smrgexit 0 52214c0a534Smrg 52314c0a534Smrg# Local Variables: 52414c0a534Smrg# mode: shell-script 52514c0a534Smrg# sh-indentation: 2 52614c0a534Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 52714c0a534Smrg# time-stamp-start: "scriptversion=" 52814c0a534Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 52914c0a534Smrg# time-stamp-end: "$" 53014c0a534Smrg# End: 531