depcomp revision 5715adc0
129459361Smrg#! /bin/sh 229459361Smrg# depcomp - compile a program generating dependencies as side-effects 329459361Smrg 45715adc0Smrgscriptversion=2009-04-28.21; # UTC 529459361Smrg 65715adc0Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 75715adc0Smrg# 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 205715adc0Smrg# 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 885715adc0Smrgcygpath_u="cygpath -u -f -" 895715adc0Smrgif test "$depmode" = msvcmsys; then 905715adc0Smrg # This is just like msvisualcpp but w/o cygpath translation. 915715adc0Smrg # Just convert the backslash-escaped backslashes to single forward 925715adc0Smrg # slashes to satisfy depend.m4 935715adc0Smrg cygpath_u="sed s,\\\\\\\\,/,g" 945715adc0Smrg depmode=msvisualcpp 955715adc0Smrgfi 965715adc0Smrg 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. 1025715adc0Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1035715adc0Smrg## the command line argument order; so add the flags where they 1045715adc0Smrg## appear in depend2.am. Note that the slowdown incurred here 1055715adc0Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1065715adc0Smrg for arg 1075715adc0Smrg do 1085715adc0Smrg case $arg in 1095715adc0Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1105715adc0Smrg *) set fnord "$@" "$arg" ;; 1115715adc0Smrg esac 1125715adc0Smrg shift # fnord 1135715adc0Smrg shift # $arg 1145715adc0Smrg done 1155715adc0Smrg "$@" 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 ' 2025715adc0Smrg' ' ' >> "$depfile" 2035715adc0Smrg 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/$/:/' \ 2095715adc0Smrg >> "$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. 2255715adc0Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2265715adc0Smrg test "x$dir" = "x$object" && dir= 2275715adc0Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 22829459361Smrg if test "$libtool" = yes; then 2295715adc0Smrg tmpdepfile1=$dir$base.u 2305715adc0Smrg tmpdepfile2=$base.u 2315715adc0Smrg tmpdepfile3=$dir.libs/$base.u 23229459361Smrg "$@" -Wc,-M 23329459361Smrg else 2345715adc0Smrg tmpdepfile1=$dir$base.u 2355715adc0Smrg tmpdepfile2=$dir$base.u 2365715adc0Smrg tmpdepfile3=$dir$base.u 23729459361Smrg "$@" -M 23829459361Smrg fi 23929459361Smrg stat=$? 24029459361Smrg 24129459361Smrg if test $stat -eq 0; then : 24229459361Smrg else 2435715adc0Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24429459361Smrg exit $stat 24529459361Smrg fi 24629459361Smrg 2475715adc0Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2485715adc0Smrg do 2495715adc0Smrg test -f "$tmpdepfile" && break 2505715adc0Smrg 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:'. 2555715adc0Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2565715adc0Smrg # That's a tab and a space in the []. 2575715adc0Smrg 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 3055715adc0Smrghp2) 3065715adc0Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3075715adc0Smrg # compilers, which have integrated preprocessors. The correct option 3085715adc0Smrg # to use with these is +Maked; it writes dependencies to a file named 3095715adc0Smrg # 'foo.d', which lands next to the object file, wherever that 3105715adc0Smrg # happens to be. 3115715adc0Smrg # Much of this is similar to the tru64 case; see comments there. 3125715adc0Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3135715adc0Smrg test "x$dir" = "x$object" && dir= 3145715adc0Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3155715adc0Smrg if test "$libtool" = yes; then 3165715adc0Smrg tmpdepfile1=$dir$base.d 3175715adc0Smrg tmpdepfile2=$dir.libs/$base.d 3185715adc0Smrg "$@" -Wc,+Maked 3195715adc0Smrg else 3205715adc0Smrg tmpdepfile1=$dir$base.d 3215715adc0Smrg tmpdepfile2=$dir$base.d 3225715adc0Smrg "$@" +Maked 3235715adc0Smrg fi 3245715adc0Smrg stat=$? 3255715adc0Smrg if test $stat -eq 0; then : 3265715adc0Smrg else 3275715adc0Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3285715adc0Smrg exit $stat 3295715adc0Smrg fi 3305715adc0Smrg 3315715adc0Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3325715adc0Smrg do 3335715adc0Smrg test -f "$tmpdepfile" && break 3345715adc0Smrg done 3355715adc0Smrg if test -f "$tmpdepfile"; then 3365715adc0Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3375715adc0Smrg # Add `dependent.h:' lines. 3385715adc0Smrg sed -ne '2,${ 3395715adc0Smrg s/^ *// 3405715adc0Smrg s/ \\*$// 3415715adc0Smrg s/$/:/ 3425715adc0Smrg p 3435715adc0Smrg }' "$tmpdepfile" >> "$depfile" 3445715adc0Smrg else 3455715adc0Smrg echo "#dummy" > "$depfile" 3465715adc0Smrg fi 3475715adc0Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3485715adc0Smrg ;; 3495715adc0Smrg 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 3625715adc0Smrg # 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 3685715adc0Smrg # 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 4195715adc0Smrg 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 4705715adc0Smrg while test "X$1" != 'X--mode=compile'; do 47129459361Smrg shift 47229459361Smrg done 47329459361Smrg shift 47429459361Smrg fi 47529459361Smrg # X makedepend 47629459361Smrg shift 4775715adc0Smrg cleared=no eat=no 4785715adc0Smrg for arg 4795715adc0Smrg do 48029459361Smrg case $cleared in 48129459361Smrg no) 48229459361Smrg set ""; shift 48329459361Smrg cleared=yes ;; 48429459361Smrg esac 4855715adc0Smrg if test $eat = yes; then 4865715adc0Smrg eat=no 4875715adc0Smrg continue 4885715adc0Smrg 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. 4945715adc0Smrg -arch) 4955715adc0Smrg eat=yes ;; 49629459361Smrg -*|$object) 49729459361Smrg ;; 49829459361Smrg *) 49929459361Smrg set fnord "$@" "$arg"; shift ;; 50029459361Smrg esac 50129459361Smrg done 5025715adc0Smrg 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 5225715adc0Smrg 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* 5605715adc0Smrg # always write the preprocessed file to stdout. 56129459361Smrg "$@" || exit $? 5625715adc0Smrg 5635715adc0Smrg # Remove the call to Libtool. 5645715adc0Smrg if test "$libtool" = yes; then 5655715adc0Smrg while test "X$1" != 'X--mode=compile'; do 5665715adc0Smrg shift 5675715adc0Smrg done 5685715adc0Smrg shift 5695715adc0Smrg fi 5705715adc0Smrg 57129459361Smrg IFS=" " 57229459361Smrg for arg 57329459361Smrg do 57429459361Smrg case "$arg" in 5755715adc0Smrg -o) 5765715adc0Smrg shift 5775715adc0Smrg ;; 5785715adc0Smrg $object) 5795715adc0Smrg shift 5805715adc0Smrg ;; 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 5935715adc0Smrg "$@" -E 2>/dev/null | 5945715adc0Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 59529459361Smrg rm -f "$depfile" 59629459361Smrg echo "$object : \\" > "$depfile" 5975715adc0Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 59829459361Smrg echo " " >> "$depfile" 5995715adc0Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 60029459361Smrg rm -f "$tmpdepfile" 60129459361Smrg ;; 60229459361Smrg 6035715adc0Smrgmsvcmsys) 6045715adc0Smrg # This case exists only to let depend.m4 do its work. It works by 6055715adc0Smrg # looking at the text of this script. This case will never be run, 6065715adc0Smrg # since it is checked for above. 6075715adc0Smrg exit 1 6085715adc0Smrg ;; 6095715adc0Smrg 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" 6285715adc0Smrg# time-stamp-time-zone: "UTC" 6295715adc0Smrg# time-stamp-end: "; # UTC" 63029459361Smrg# End: 631