depcomp revision 47202d7b
129459361Smrg#! /bin/sh 229459361Smrg# depcomp - compile a program generating dependencies as side-effects 329459361Smrg 447202d7bSmrgscriptversion=2009-04-28.21; # UTC 529459361Smrg 647202d7bSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 747202d7bSmrg# Software Foundation, Inc. 829459361Smrg 929459361Smrg# This program is free software; you can redistribute it and/or modify 1029459361Smrg# it under the terms of the GNU General Public License as published by 1129459361Smrg# the Free Software Foundation; either version 2, or (at your option) 1229459361Smrg# any later version. 1329459361Smrg 1429459361Smrg# This program is distributed in the hope that it will be useful, 1529459361Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1629459361Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1729459361Smrg# GNU General Public License for more details. 1829459361Smrg 1929459361Smrg# You should have received a copy of the GNU General Public License 2047202d7bSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2129459361Smrg 2229459361Smrg# As a special exception to the GNU General Public License, if you 2329459361Smrg# distribute this file as part of a program that contains a 2429459361Smrg# configuration script generated by Autoconf, you may include it under 2529459361Smrg# the same distribution terms that you use for the rest of that program. 2629459361Smrg 2729459361Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2829459361Smrg 2929459361Smrgcase $1 in 3029459361Smrg '') 3129459361Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3229459361Smrg exit 1; 3329459361Smrg ;; 3429459361Smrg -h | --h*) 3529459361Smrg cat <<\EOF 3629459361SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3729459361Smrg 3829459361SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3929459361Smrgas side-effects. 4029459361Smrg 4129459361SmrgEnvironment variables: 4229459361Smrg depmode Dependency tracking mode. 4329459361Smrg source Source file read by `PROGRAMS ARGS'. 4429459361Smrg object Object file output by `PROGRAMS ARGS'. 4529459361Smrg DEPDIR directory where to store dependencies. 4629459361Smrg depfile Dependency file to output. 4729459361Smrg tmpdepfile Temporary file to use when outputing dependencies. 4829459361Smrg libtool Whether libtool is used (yes/no). 4929459361Smrg 5029459361SmrgReport bugs to <bug-automake@gnu.org>. 5129459361SmrgEOF 5229459361Smrg exit $? 5329459361Smrg ;; 5429459361Smrg -v | --v*) 5529459361Smrg echo "depcomp $scriptversion" 5629459361Smrg exit $? 5729459361Smrg ;; 5829459361Smrgesac 5929459361Smrg 6029459361Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6129459361Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6229459361Smrg exit 1 6329459361Smrgfi 6429459361Smrg 6529459361Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6629459361Smrgdepfile=${depfile-`echo "$object" | 6729459361Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6829459361Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 6929459361Smrg 7029459361Smrgrm -f "$tmpdepfile" 7129459361Smrg 7229459361Smrg# Some modes work just like other modes, but use different flags. We 7329459361Smrg# parameterize here, but still list the modes in the big case below, 7429459361Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7529459361Smrg# here, because this file can only contain one case statement. 7629459361Smrgif test "$depmode" = hp; then 7729459361Smrg # HP compiler uses -M and no extra arg. 7829459361Smrg gccflag=-M 7929459361Smrg depmode=gcc 8029459361Smrgfi 8129459361Smrg 8229459361Smrgif test "$depmode" = dashXmstdout; then 8329459361Smrg # This is just like dashmstdout with a different argument. 8429459361Smrg dashmflag=-xM 8529459361Smrg depmode=dashmstdout 8629459361Smrgfi 8729459361Smrg 8847202d7bSmrgcygpath_u="cygpath -u -f -" 8947202d7bSmrgif test "$depmode" = msvcmsys; then 9047202d7bSmrg # This is just like msvisualcpp but w/o cygpath translation. 9147202d7bSmrg # Just convert the backslash-escaped backslashes to single forward 9247202d7bSmrg # slashes to satisfy depend.m4 9347202d7bSmrg cygpath_u="sed s,\\\\\\\\,/,g" 9447202d7bSmrg depmode=msvisualcpp 9547202d7bSmrgfi 9647202d7bSmrg 9729459361Smrgcase "$depmode" in 9829459361Smrggcc3) 9929459361Smrg## gcc 3 implements dependency tracking that does exactly what 10029459361Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 10129459361Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 10247202d7bSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 10347202d7bSmrg## the command line argument order; so add the flags where they 10447202d7bSmrg## appear in depend2.am. Note that the slowdown incurred here 10547202d7bSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 10647202d7bSmrg for arg 10747202d7bSmrg do 10847202d7bSmrg case $arg in 10947202d7bSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 11047202d7bSmrg *) set fnord "$@" "$arg" ;; 11147202d7bSmrg esac 11247202d7bSmrg shift # fnord 11347202d7bSmrg shift # $arg 11447202d7bSmrg done 11547202d7bSmrg "$@" 11629459361Smrg stat=$? 11729459361Smrg if test $stat -eq 0; then : 11829459361Smrg else 11929459361Smrg rm -f "$tmpdepfile" 12029459361Smrg exit $stat 12129459361Smrg fi 12229459361Smrg mv "$tmpdepfile" "$depfile" 12329459361Smrg ;; 12429459361Smrg 12529459361Smrggcc) 12629459361Smrg## There are various ways to get dependency output from gcc. Here's 12729459361Smrg## why we pick this rather obscure method: 12829459361Smrg## - Don't want to use -MD because we'd like the dependencies to end 12929459361Smrg## up in a subdir. Having to rename by hand is ugly. 13029459361Smrg## (We might end up doing this anyway to support other compilers.) 13129459361Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 13229459361Smrg## -MM, not -M (despite what the docs say). 13329459361Smrg## - Using -M directly means running the compiler twice (even worse 13429459361Smrg## than renaming). 13529459361Smrg if test -z "$gccflag"; then 13629459361Smrg gccflag=-MD, 13729459361Smrg fi 13829459361Smrg "$@" -Wp,"$gccflag$tmpdepfile" 13929459361Smrg stat=$? 14029459361Smrg if test $stat -eq 0; then : 14129459361Smrg else 14229459361Smrg rm -f "$tmpdepfile" 14329459361Smrg exit $stat 14429459361Smrg fi 14529459361Smrg rm -f "$depfile" 14629459361Smrg echo "$object : \\" > "$depfile" 14729459361Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 14829459361Smrg## The second -e expression handles DOS-style file names with drive letters. 14929459361Smrg sed -e 's/^[^:]*: / /' \ 15029459361Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 15129459361Smrg## This next piece of magic avoids the `deleted header file' problem. 15229459361Smrg## The problem is that when a header file which appears in a .P file 15329459361Smrg## is deleted, the dependency causes make to die (because there is 15429459361Smrg## typically no way to rebuild the header). We avoid this by adding 15529459361Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 15629459361Smrg## this for us directly. 15729459361Smrg tr ' ' ' 15829459361Smrg' < "$tmpdepfile" | 15929459361Smrg## Some versions of gcc put a space before the `:'. On the theory 16029459361Smrg## that the space means something, we add a space to the output as 16129459361Smrg## well. 16229459361Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 16329459361Smrg## correctly. Breaking it into two sed invocations is a workaround. 16429459361Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 16529459361Smrg rm -f "$tmpdepfile" 16629459361Smrg ;; 16729459361Smrg 16829459361Smrghp) 16929459361Smrg # This case exists only to let depend.m4 do its work. It works by 17029459361Smrg # looking at the text of this script. This case will never be run, 17129459361Smrg # since it is checked for above. 17229459361Smrg exit 1 17329459361Smrg ;; 17429459361Smrg 17529459361Smrgsgi) 17629459361Smrg if test "$libtool" = yes; then 17729459361Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 17829459361Smrg else 17929459361Smrg "$@" -MDupdate "$tmpdepfile" 18029459361Smrg fi 18129459361Smrg stat=$? 18229459361Smrg if test $stat -eq 0; then : 18329459361Smrg else 18429459361Smrg rm -f "$tmpdepfile" 18529459361Smrg exit $stat 18629459361Smrg fi 18729459361Smrg rm -f "$depfile" 18829459361Smrg 18929459361Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 19029459361Smrg echo "$object : \\" > "$depfile" 19129459361Smrg 19229459361Smrg # Clip off the initial element (the dependent). Don't try to be 19329459361Smrg # clever and replace this with sed code, as IRIX sed won't handle 19429459361Smrg # lines with more than a fixed number of characters (4096 in 19529459361Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 19629459361Smrg # the IRIX cc adds comments like `#:fec' to the end of the 19729459361Smrg # dependency line. 19829459361Smrg tr ' ' ' 19929459361Smrg' < "$tmpdepfile" \ 20029459361Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 20129459361Smrg tr ' 20247202d7bSmrg' ' ' >> "$depfile" 20347202d7bSmrg echo >> "$depfile" 20429459361Smrg 20529459361Smrg # The second pass generates a dummy entry for each header file. 20629459361Smrg tr ' ' ' 20729459361Smrg' < "$tmpdepfile" \ 20829459361Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 20947202d7bSmrg >> "$depfile" 21029459361Smrg else 21129459361Smrg # The sourcefile does not contain any dependencies, so just 21229459361Smrg # store a dummy comment line, to avoid errors with the Makefile 21329459361Smrg # "include basename.Plo" scheme. 21429459361Smrg echo "#dummy" > "$depfile" 21529459361Smrg fi 21629459361Smrg rm -f "$tmpdepfile" 21729459361Smrg ;; 21829459361Smrg 21929459361Smrgaix) 22029459361Smrg # The C for AIX Compiler uses -M and outputs the dependencies 22129459361Smrg # in a .u file. In older versions, this file always lives in the 22229459361Smrg # current directory. Also, the AIX compiler puts `$object:' at the 22329459361Smrg # start of each line; $object doesn't have directory information. 22429459361Smrg # Version 6 uses the directory in both cases. 22547202d7bSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 22647202d7bSmrg test "x$dir" = "x$object" && dir= 22747202d7bSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 22829459361Smrg if test "$libtool" = yes; then 22947202d7bSmrg tmpdepfile1=$dir$base.u 23047202d7bSmrg tmpdepfile2=$base.u 23147202d7bSmrg tmpdepfile3=$dir.libs/$base.u 23229459361Smrg "$@" -Wc,-M 23329459361Smrg else 23447202d7bSmrg tmpdepfile1=$dir$base.u 23547202d7bSmrg tmpdepfile2=$dir$base.u 23647202d7bSmrg tmpdepfile3=$dir$base.u 23729459361Smrg "$@" -M 23829459361Smrg fi 23929459361Smrg stat=$? 24029459361Smrg 24129459361Smrg if test $stat -eq 0; then : 24229459361Smrg else 24347202d7bSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24429459361Smrg exit $stat 24529459361Smrg fi 24629459361Smrg 24747202d7bSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24847202d7bSmrg do 24947202d7bSmrg test -f "$tmpdepfile" && break 25047202d7bSmrg done 25129459361Smrg if test -f "$tmpdepfile"; then 25229459361Smrg # Each line is of the form `foo.o: dependent.h'. 25329459361Smrg # Do two passes, one to just change these to 25429459361Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 25547202d7bSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 25647202d7bSmrg # That's a tab and a space in the []. 25747202d7bSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 25829459361Smrg else 25929459361Smrg # The sourcefile does not contain any dependencies, so just 26029459361Smrg # store a dummy comment line, to avoid errors with the Makefile 26129459361Smrg # "include basename.Plo" scheme. 26229459361Smrg echo "#dummy" > "$depfile" 26329459361Smrg fi 26429459361Smrg rm -f "$tmpdepfile" 26529459361Smrg ;; 26629459361Smrg 26729459361Smrgicc) 26829459361Smrg # Intel's C compiler understands `-MD -MF file'. However on 26929459361Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 27029459361Smrg # ICC 7.0 will fill foo.d with something like 27129459361Smrg # foo.o: sub/foo.c 27229459361Smrg # foo.o: sub/foo.h 27329459361Smrg # which is wrong. We want: 27429459361Smrg # sub/foo.o: sub/foo.c 27529459361Smrg # sub/foo.o: sub/foo.h 27629459361Smrg # sub/foo.c: 27729459361Smrg # sub/foo.h: 27829459361Smrg # ICC 7.1 will output 27929459361Smrg # foo.o: sub/foo.c sub/foo.h 28029459361Smrg # and will wrap long lines using \ : 28129459361Smrg # foo.o: sub/foo.c ... \ 28229459361Smrg # sub/foo.h ... \ 28329459361Smrg # ... 28429459361Smrg 28529459361Smrg "$@" -MD -MF "$tmpdepfile" 28629459361Smrg stat=$? 28729459361Smrg if test $stat -eq 0; then : 28829459361Smrg else 28929459361Smrg rm -f "$tmpdepfile" 29029459361Smrg exit $stat 29129459361Smrg fi 29229459361Smrg rm -f "$depfile" 29329459361Smrg # Each line is of the form `foo.o: dependent.h', 29429459361Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 29529459361Smrg # Do two passes, one to just change these to 29629459361Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 29729459361Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 29829459361Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 29929459361Smrg # correctly. Breaking it into two sed invocations is a workaround. 30029459361Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 30129459361Smrg sed -e 's/$/ :/' >> "$depfile" 30229459361Smrg rm -f "$tmpdepfile" 30329459361Smrg ;; 30429459361Smrg 30547202d7bSmrghp2) 30647202d7bSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 30747202d7bSmrg # compilers, which have integrated preprocessors. The correct option 30847202d7bSmrg # to use with these is +Maked; it writes dependencies to a file named 30947202d7bSmrg # 'foo.d', which lands next to the object file, wherever that 31047202d7bSmrg # happens to be. 31147202d7bSmrg # Much of this is similar to the tru64 case; see comments there. 31247202d7bSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 31347202d7bSmrg test "x$dir" = "x$object" && dir= 31447202d7bSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 31547202d7bSmrg if test "$libtool" = yes; then 31647202d7bSmrg tmpdepfile1=$dir$base.d 31747202d7bSmrg tmpdepfile2=$dir.libs/$base.d 31847202d7bSmrg "$@" -Wc,+Maked 31947202d7bSmrg else 32047202d7bSmrg tmpdepfile1=$dir$base.d 32147202d7bSmrg tmpdepfile2=$dir$base.d 32247202d7bSmrg "$@" +Maked 32347202d7bSmrg fi 32447202d7bSmrg stat=$? 32547202d7bSmrg if test $stat -eq 0; then : 32647202d7bSmrg else 32747202d7bSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 32847202d7bSmrg exit $stat 32947202d7bSmrg fi 33047202d7bSmrg 33147202d7bSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 33247202d7bSmrg do 33347202d7bSmrg test -f "$tmpdepfile" && break 33447202d7bSmrg done 33547202d7bSmrg if test -f "$tmpdepfile"; then 33647202d7bSmrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 33747202d7bSmrg # Add `dependent.h:' lines. 33847202d7bSmrg sed -ne '2,${ 33947202d7bSmrg s/^ *// 34047202d7bSmrg s/ \\*$// 34147202d7bSmrg s/$/:/ 34247202d7bSmrg p 34347202d7bSmrg }' "$tmpdepfile" >> "$depfile" 34447202d7bSmrg else 34547202d7bSmrg echo "#dummy" > "$depfile" 34647202d7bSmrg fi 34747202d7bSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 34847202d7bSmrg ;; 34947202d7bSmrg 35029459361Smrgtru64) 35129459361Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 35229459361Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 35329459361Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 35429459361Smrg # dependencies in `foo.d' instead, so we check for that too. 35529459361Smrg # Subdirectories are respected. 35629459361Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 35729459361Smrg test "x$dir" = "x$object" && dir= 35829459361Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 35929459361Smrg 36029459361Smrg if test "$libtool" = yes; then 36129459361Smrg # With Tru64 cc, shared objects can also be used to make a 36247202d7bSmrg # static library. This mechanism is used in libtool 1.4 series to 36329459361Smrg # handle both shared and static libraries in a single compilation. 36429459361Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 36529459361Smrg # 36629459361Smrg # With libtool 1.5 this exception was removed, and libtool now 36729459361Smrg # generates 2 separate objects for the 2 libraries. These two 36847202d7bSmrg # compilations output dependencies in $dir.libs/$base.o.d and 36929459361Smrg # in $dir$base.o.d. We have to check for both files, because 37029459361Smrg # one of the two compilations can be disabled. We should prefer 37129459361Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 37229459361Smrg # automatically cleaned when .libs/ is deleted, while ignoring 37329459361Smrg # the former would cause a distcleancheck panic. 37429459361Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 37529459361Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 37629459361Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 37729459361Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 37829459361Smrg "$@" -Wc,-MD 37929459361Smrg else 38029459361Smrg tmpdepfile1=$dir$base.o.d 38129459361Smrg tmpdepfile2=$dir$base.d 38229459361Smrg tmpdepfile3=$dir$base.d 38329459361Smrg tmpdepfile4=$dir$base.d 38429459361Smrg "$@" -MD 38529459361Smrg fi 38629459361Smrg 38729459361Smrg stat=$? 38829459361Smrg if test $stat -eq 0; then : 38929459361Smrg else 39029459361Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39129459361Smrg exit $stat 39229459361Smrg fi 39329459361Smrg 39429459361Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39529459361Smrg do 39629459361Smrg test -f "$tmpdepfile" && break 39729459361Smrg done 39829459361Smrg if test -f "$tmpdepfile"; then 39929459361Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 40029459361Smrg # That's a tab and a space in the []. 40129459361Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 40229459361Smrg else 40329459361Smrg echo "#dummy" > "$depfile" 40429459361Smrg fi 40529459361Smrg rm -f "$tmpdepfile" 40629459361Smrg ;; 40729459361Smrg 40829459361Smrg#nosideeffect) 40929459361Smrg # This comment above is used by automake to tell side-effect 41029459361Smrg # dependency tracking mechanisms from slower ones. 41129459361Smrg 41229459361Smrgdashmstdout) 41329459361Smrg # Important note: in order to support this mode, a compiler *must* 41429459361Smrg # always write the preprocessed file to stdout, regardless of -o. 41529459361Smrg "$@" || exit $? 41629459361Smrg 41729459361Smrg # Remove the call to Libtool. 41829459361Smrg if test "$libtool" = yes; then 41947202d7bSmrg while test "X$1" != 'X--mode=compile'; do 42029459361Smrg shift 42129459361Smrg done 42229459361Smrg shift 42329459361Smrg fi 42429459361Smrg 42529459361Smrg # Remove `-o $object'. 42629459361Smrg IFS=" " 42729459361Smrg for arg 42829459361Smrg do 42929459361Smrg case $arg in 43029459361Smrg -o) 43129459361Smrg shift 43229459361Smrg ;; 43329459361Smrg $object) 43429459361Smrg shift 43529459361Smrg ;; 43629459361Smrg *) 43729459361Smrg set fnord "$@" "$arg" 43829459361Smrg shift # fnord 43929459361Smrg shift # $arg 44029459361Smrg ;; 44129459361Smrg esac 44229459361Smrg done 44329459361Smrg 44429459361Smrg test -z "$dashmflag" && dashmflag=-M 44529459361Smrg # Require at least two characters before searching for `:' 44629459361Smrg # in the target name. This is to cope with DOS-style filenames: 44729459361Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 44829459361Smrg "$@" $dashmflag | 44929459361Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 45029459361Smrg rm -f "$depfile" 45129459361Smrg cat < "$tmpdepfile" > "$depfile" 45229459361Smrg tr ' ' ' 45329459361Smrg' < "$tmpdepfile" | \ 45429459361Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 45529459361Smrg## correctly. Breaking it into two sed invocations is a workaround. 45629459361Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 45729459361Smrg rm -f "$tmpdepfile" 45829459361Smrg ;; 45929459361Smrg 46029459361SmrgdashXmstdout) 46129459361Smrg # This case only exists to satisfy depend.m4. It is never actually 46229459361Smrg # run, as this mode is specially recognized in the preamble. 46329459361Smrg exit 1 46429459361Smrg ;; 46529459361Smrg 46629459361Smrgmakedepend) 46729459361Smrg "$@" || exit $? 46829459361Smrg # Remove any Libtool call 46929459361Smrg if test "$libtool" = yes; then 47047202d7bSmrg while test "X$1" != 'X--mode=compile'; do 47129459361Smrg shift 47229459361Smrg done 47329459361Smrg shift 47429459361Smrg fi 47529459361Smrg # X makedepend 47629459361Smrg shift 47747202d7bSmrg cleared=no eat=no 47847202d7bSmrg for arg 47947202d7bSmrg do 48029459361Smrg case $cleared in 48129459361Smrg no) 48229459361Smrg set ""; shift 48329459361Smrg cleared=yes ;; 48429459361Smrg esac 48547202d7bSmrg if test $eat = yes; then 48647202d7bSmrg eat=no 48747202d7bSmrg continue 48847202d7bSmrg fi 48929459361Smrg case "$arg" in 49029459361Smrg -D*|-I*) 49129459361Smrg set fnord "$@" "$arg"; shift ;; 49229459361Smrg # Strip any option that makedepend may not understand. Remove 49329459361Smrg # the object too, otherwise makedepend will parse it as a source file. 49447202d7bSmrg -arch) 49547202d7bSmrg eat=yes ;; 49629459361Smrg -*|$object) 49729459361Smrg ;; 49829459361Smrg *) 49929459361Smrg set fnord "$@" "$arg"; shift ;; 50029459361Smrg esac 50129459361Smrg done 50247202d7bSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 50329459361Smrg touch "$tmpdepfile" 50429459361Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 50529459361Smrg rm -f "$depfile" 50629459361Smrg cat < "$tmpdepfile" > "$depfile" 50729459361Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 50829459361Smrg' | \ 50929459361Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 51029459361Smrg## correctly. Breaking it into two sed invocations is a workaround. 51129459361Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 51229459361Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 51329459361Smrg ;; 51429459361Smrg 51529459361Smrgcpp) 51629459361Smrg # Important note: in order to support this mode, a compiler *must* 51729459361Smrg # always write the preprocessed file to stdout. 51829459361Smrg "$@" || exit $? 51929459361Smrg 52029459361Smrg # Remove the call to Libtool. 52129459361Smrg if test "$libtool" = yes; then 52247202d7bSmrg while test "X$1" != 'X--mode=compile'; do 52329459361Smrg shift 52429459361Smrg done 52529459361Smrg shift 52629459361Smrg fi 52729459361Smrg 52829459361Smrg # Remove `-o $object'. 52929459361Smrg IFS=" " 53029459361Smrg for arg 53129459361Smrg do 53229459361Smrg case $arg in 53329459361Smrg -o) 53429459361Smrg shift 53529459361Smrg ;; 53629459361Smrg $object) 53729459361Smrg shift 53829459361Smrg ;; 53929459361Smrg *) 54029459361Smrg set fnord "$@" "$arg" 54129459361Smrg shift # fnord 54229459361Smrg shift # $arg 54329459361Smrg ;; 54429459361Smrg esac 54529459361Smrg done 54629459361Smrg 54729459361Smrg "$@" -E | 54829459361Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 54929459361Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 55029459361Smrg sed '$ s: \\$::' > "$tmpdepfile" 55129459361Smrg rm -f "$depfile" 55229459361Smrg echo "$object : \\" > "$depfile" 55329459361Smrg cat < "$tmpdepfile" >> "$depfile" 55429459361Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 55529459361Smrg rm -f "$tmpdepfile" 55629459361Smrg ;; 55729459361Smrg 55829459361Smrgmsvisualcpp) 55929459361Smrg # Important note: in order to support this mode, a compiler *must* 56047202d7bSmrg # always write the preprocessed file to stdout. 56129459361Smrg "$@" || exit $? 56247202d7bSmrg 56347202d7bSmrg # Remove the call to Libtool. 56447202d7bSmrg if test "$libtool" = yes; then 56547202d7bSmrg while test "X$1" != 'X--mode=compile'; do 56647202d7bSmrg shift 56747202d7bSmrg done 56847202d7bSmrg shift 56947202d7bSmrg fi 57047202d7bSmrg 57129459361Smrg IFS=" " 57229459361Smrg for arg 57329459361Smrg do 57429459361Smrg case "$arg" in 57547202d7bSmrg -o) 57647202d7bSmrg shift 57747202d7bSmrg ;; 57847202d7bSmrg $object) 57947202d7bSmrg shift 58047202d7bSmrg ;; 58129459361Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 58229459361Smrg set fnord "$@" 58329459361Smrg shift 58429459361Smrg shift 58529459361Smrg ;; 58629459361Smrg *) 58729459361Smrg set fnord "$@" "$arg" 58829459361Smrg shift 58929459361Smrg shift 59029459361Smrg ;; 59129459361Smrg esac 59229459361Smrg done 59347202d7bSmrg "$@" -E 2>/dev/null | 59447202d7bSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 59529459361Smrg rm -f "$depfile" 59629459361Smrg echo "$object : \\" > "$depfile" 59747202d7bSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 59829459361Smrg echo " " >> "$depfile" 59947202d7bSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 60029459361Smrg rm -f "$tmpdepfile" 60129459361Smrg ;; 60229459361Smrg 60347202d7bSmrgmsvcmsys) 60447202d7bSmrg # This case exists only to let depend.m4 do its work. It works by 60547202d7bSmrg # looking at the text of this script. This case will never be run, 60647202d7bSmrg # since it is checked for above. 60747202d7bSmrg exit 1 60847202d7bSmrg ;; 60947202d7bSmrg 61029459361Smrgnone) 61129459361Smrg exec "$@" 61229459361Smrg ;; 61329459361Smrg 61429459361Smrg*) 61529459361Smrg echo "Unknown depmode $depmode" 1>&2 61629459361Smrg exit 1 61729459361Smrg ;; 61829459361Smrgesac 61929459361Smrg 62029459361Smrgexit 0 62129459361Smrg 62229459361Smrg# Local Variables: 62329459361Smrg# mode: shell-script 62429459361Smrg# sh-indentation: 2 62529459361Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 62629459361Smrg# time-stamp-start: "scriptversion=" 62729459361Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 62847202d7bSmrg# time-stamp-time-zone: "UTC" 62947202d7bSmrg# time-stamp-end: "; # UTC" 63029459361Smrg# End: 631