depcomp revision fbed5abf
117a48c7cSmrg#! /bin/sh 217a48c7cSmrg# depcomp - compile a program generating dependencies as side-effects 317a48c7cSmrg 4fbed5abfSmrgscriptversion=2009-04-28.21; # UTC 517a48c7cSmrg 6fbed5abfSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7fbed5abfSmrg# Software Foundation, Inc. 817a48c7cSmrg 917a48c7cSmrg# This program is free software; you can redistribute it and/or modify 1017a48c7cSmrg# it under the terms of the GNU General Public License as published by 1117a48c7cSmrg# the Free Software Foundation; either version 2, or (at your option) 1217a48c7cSmrg# any later version. 1317a48c7cSmrg 1417a48c7cSmrg# This program is distributed in the hope that it will be useful, 1517a48c7cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1617a48c7cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1717a48c7cSmrg# GNU General Public License for more details. 1817a48c7cSmrg 1917a48c7cSmrg# You should have received a copy of the GNU General Public License 20fbed5abfSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2117a48c7cSmrg 2217a48c7cSmrg# As a special exception to the GNU General Public License, if you 2317a48c7cSmrg# distribute this file as part of a program that contains a 2417a48c7cSmrg# configuration script generated by Autoconf, you may include it under 2517a48c7cSmrg# the same distribution terms that you use for the rest of that program. 2617a48c7cSmrg 2717a48c7cSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2817a48c7cSmrg 2917a48c7cSmrgcase $1 in 3017a48c7cSmrg '') 3117a48c7cSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3217a48c7cSmrg exit 1; 3317a48c7cSmrg ;; 3417a48c7cSmrg -h | --h*) 3517a48c7cSmrg cat <<\EOF 3617a48c7cSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3717a48c7cSmrg 3817a48c7cSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3917a48c7cSmrgas side-effects. 4017a48c7cSmrg 4117a48c7cSmrgEnvironment variables: 4217a48c7cSmrg depmode Dependency tracking mode. 4317a48c7cSmrg source Source file read by `PROGRAMS ARGS'. 4417a48c7cSmrg object Object file output by `PROGRAMS ARGS'. 4517a48c7cSmrg DEPDIR directory where to store dependencies. 4617a48c7cSmrg depfile Dependency file to output. 4717a48c7cSmrg tmpdepfile Temporary file to use when outputing dependencies. 4817a48c7cSmrg libtool Whether libtool is used (yes/no). 4917a48c7cSmrg 5017a48c7cSmrgReport bugs to <bug-automake@gnu.org>. 5117a48c7cSmrgEOF 5217a48c7cSmrg exit $? 5317a48c7cSmrg ;; 5417a48c7cSmrg -v | --v*) 5517a48c7cSmrg echo "depcomp $scriptversion" 5617a48c7cSmrg exit $? 5717a48c7cSmrg ;; 5817a48c7cSmrgesac 5917a48c7cSmrg 6017a48c7cSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6117a48c7cSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6217a48c7cSmrg exit 1 6317a48c7cSmrgfi 6417a48c7cSmrg 6517a48c7cSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6617a48c7cSmrgdepfile=${depfile-`echo "$object" | 6717a48c7cSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6817a48c7cSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 6917a48c7cSmrg 7017a48c7cSmrgrm -f "$tmpdepfile" 7117a48c7cSmrg 7217a48c7cSmrg# Some modes work just like other modes, but use different flags. We 7317a48c7cSmrg# parameterize here, but still list the modes in the big case below, 7417a48c7cSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7517a48c7cSmrg# here, because this file can only contain one case statement. 7617a48c7cSmrgif test "$depmode" = hp; then 7717a48c7cSmrg # HP compiler uses -M and no extra arg. 7817a48c7cSmrg gccflag=-M 7917a48c7cSmrg depmode=gcc 8017a48c7cSmrgfi 8117a48c7cSmrg 8217a48c7cSmrgif test "$depmode" = dashXmstdout; then 8317a48c7cSmrg # This is just like dashmstdout with a different argument. 8417a48c7cSmrg dashmflag=-xM 8517a48c7cSmrg depmode=dashmstdout 8617a48c7cSmrgfi 8717a48c7cSmrg 88fbed5abfSmrgcygpath_u="cygpath -u -f -" 89fbed5abfSmrgif test "$depmode" = msvcmsys; then 90fbed5abfSmrg # This is just like msvisualcpp but w/o cygpath translation. 91fbed5abfSmrg # Just convert the backslash-escaped backslashes to single forward 92fbed5abfSmrg # slashes to satisfy depend.m4 93fbed5abfSmrg cygpath_u="sed s,\\\\\\\\,/,g" 94fbed5abfSmrg depmode=msvisualcpp 95fbed5abfSmrgfi 96fbed5abfSmrg 9717a48c7cSmrgcase "$depmode" in 9817a48c7cSmrggcc3) 9917a48c7cSmrg## gcc 3 implements dependency tracking that does exactly what 10017a48c7cSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 10117a48c7cSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 1028e0ed500Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1038e0ed500Smrg## the command line argument order; so add the flags where they 1048e0ed500Smrg## appear in depend2.am. Note that the slowdown incurred here 1058e0ed500Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1068e0ed500Smrg for arg 1078e0ed500Smrg do 1088e0ed500Smrg case $arg in 1098e0ed500Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1108e0ed500Smrg *) set fnord "$@" "$arg" ;; 1118e0ed500Smrg esac 1128e0ed500Smrg shift # fnord 1138e0ed500Smrg shift # $arg 1148e0ed500Smrg done 1158e0ed500Smrg "$@" 11617a48c7cSmrg stat=$? 11717a48c7cSmrg if test $stat -eq 0; then : 11817a48c7cSmrg else 11917a48c7cSmrg rm -f "$tmpdepfile" 12017a48c7cSmrg exit $stat 12117a48c7cSmrg fi 12217a48c7cSmrg mv "$tmpdepfile" "$depfile" 12317a48c7cSmrg ;; 12417a48c7cSmrg 12517a48c7cSmrggcc) 12617a48c7cSmrg## There are various ways to get dependency output from gcc. Here's 12717a48c7cSmrg## why we pick this rather obscure method: 12817a48c7cSmrg## - Don't want to use -MD because we'd like the dependencies to end 12917a48c7cSmrg## up in a subdir. Having to rename by hand is ugly. 13017a48c7cSmrg## (We might end up doing this anyway to support other compilers.) 13117a48c7cSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 13217a48c7cSmrg## -MM, not -M (despite what the docs say). 13317a48c7cSmrg## - Using -M directly means running the compiler twice (even worse 13417a48c7cSmrg## than renaming). 13517a48c7cSmrg if test -z "$gccflag"; then 13617a48c7cSmrg gccflag=-MD, 13717a48c7cSmrg fi 13817a48c7cSmrg "$@" -Wp,"$gccflag$tmpdepfile" 13917a48c7cSmrg stat=$? 14017a48c7cSmrg if test $stat -eq 0; then : 14117a48c7cSmrg else 14217a48c7cSmrg rm -f "$tmpdepfile" 14317a48c7cSmrg exit $stat 14417a48c7cSmrg fi 14517a48c7cSmrg rm -f "$depfile" 14617a48c7cSmrg echo "$object : \\" > "$depfile" 14717a48c7cSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 14817a48c7cSmrg## The second -e expression handles DOS-style file names with drive letters. 14917a48c7cSmrg sed -e 's/^[^:]*: / /' \ 15017a48c7cSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 15117a48c7cSmrg## This next piece of magic avoids the `deleted header file' problem. 15217a48c7cSmrg## The problem is that when a header file which appears in a .P file 15317a48c7cSmrg## is deleted, the dependency causes make to die (because there is 15417a48c7cSmrg## typically no way to rebuild the header). We avoid this by adding 15517a48c7cSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 15617a48c7cSmrg## this for us directly. 15717a48c7cSmrg tr ' ' ' 15817a48c7cSmrg' < "$tmpdepfile" | 15917a48c7cSmrg## Some versions of gcc put a space before the `:'. On the theory 16017a48c7cSmrg## that the space means something, we add a space to the output as 16117a48c7cSmrg## well. 16217a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 16317a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 16417a48c7cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 16517a48c7cSmrg rm -f "$tmpdepfile" 16617a48c7cSmrg ;; 16717a48c7cSmrg 16817a48c7cSmrghp) 16917a48c7cSmrg # This case exists only to let depend.m4 do its work. It works by 17017a48c7cSmrg # looking at the text of this script. This case will never be run, 17117a48c7cSmrg # since it is checked for above. 17217a48c7cSmrg exit 1 17317a48c7cSmrg ;; 17417a48c7cSmrg 17517a48c7cSmrgsgi) 17617a48c7cSmrg if test "$libtool" = yes; then 17717a48c7cSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 17817a48c7cSmrg else 17917a48c7cSmrg "$@" -MDupdate "$tmpdepfile" 18017a48c7cSmrg fi 18117a48c7cSmrg stat=$? 18217a48c7cSmrg if test $stat -eq 0; then : 18317a48c7cSmrg else 18417a48c7cSmrg rm -f "$tmpdepfile" 18517a48c7cSmrg exit $stat 18617a48c7cSmrg fi 18717a48c7cSmrg rm -f "$depfile" 18817a48c7cSmrg 18917a48c7cSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 19017a48c7cSmrg echo "$object : \\" > "$depfile" 19117a48c7cSmrg 19217a48c7cSmrg # Clip off the initial element (the dependent). Don't try to be 19317a48c7cSmrg # clever and replace this with sed code, as IRIX sed won't handle 19417a48c7cSmrg # lines with more than a fixed number of characters (4096 in 19517a48c7cSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 19617a48c7cSmrg # the IRIX cc adds comments like `#:fec' to the end of the 19717a48c7cSmrg # dependency line. 19817a48c7cSmrg tr ' ' ' 19917a48c7cSmrg' < "$tmpdepfile" \ 20017a48c7cSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 20117a48c7cSmrg tr ' 202fbed5abfSmrg' ' ' >> "$depfile" 203fbed5abfSmrg echo >> "$depfile" 20417a48c7cSmrg 20517a48c7cSmrg # The second pass generates a dummy entry for each header file. 20617a48c7cSmrg tr ' ' ' 20717a48c7cSmrg' < "$tmpdepfile" \ 20817a48c7cSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209fbed5abfSmrg >> "$depfile" 21017a48c7cSmrg else 21117a48c7cSmrg # The sourcefile does not contain any dependencies, so just 21217a48c7cSmrg # store a dummy comment line, to avoid errors with the Makefile 21317a48c7cSmrg # "include basename.Plo" scheme. 21417a48c7cSmrg echo "#dummy" > "$depfile" 21517a48c7cSmrg fi 21617a48c7cSmrg rm -f "$tmpdepfile" 21717a48c7cSmrg ;; 21817a48c7cSmrg 21917a48c7cSmrgaix) 22017a48c7cSmrg # The C for AIX Compiler uses -M and outputs the dependencies 22117a48c7cSmrg # in a .u file. In older versions, this file always lives in the 22217a48c7cSmrg # current directory. Also, the AIX compiler puts `$object:' at the 22317a48c7cSmrg # start of each line; $object doesn't have directory information. 22417a48c7cSmrg # Version 6 uses the directory in both cases. 225fbed5abfSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226fbed5abfSmrg test "x$dir" = "x$object" && dir= 227fbed5abfSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 22817a48c7cSmrg if test "$libtool" = yes; then 229fbed5abfSmrg tmpdepfile1=$dir$base.u 230fbed5abfSmrg tmpdepfile2=$base.u 231fbed5abfSmrg tmpdepfile3=$dir.libs/$base.u 23217a48c7cSmrg "$@" -Wc,-M 23317a48c7cSmrg else 234fbed5abfSmrg tmpdepfile1=$dir$base.u 235fbed5abfSmrg tmpdepfile2=$dir$base.u 236fbed5abfSmrg tmpdepfile3=$dir$base.u 23717a48c7cSmrg "$@" -M 23817a48c7cSmrg fi 23917a48c7cSmrg stat=$? 24017a48c7cSmrg 24117a48c7cSmrg if test $stat -eq 0; then : 24217a48c7cSmrg else 243fbed5abfSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24417a48c7cSmrg exit $stat 24517a48c7cSmrg fi 24617a48c7cSmrg 247fbed5abfSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248fbed5abfSmrg do 249fbed5abfSmrg test -f "$tmpdepfile" && break 250fbed5abfSmrg done 25117a48c7cSmrg if test -f "$tmpdepfile"; then 25217a48c7cSmrg # Each line is of the form `foo.o: dependent.h'. 25317a48c7cSmrg # Do two passes, one to just change these to 25417a48c7cSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 255fbed5abfSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256fbed5abfSmrg # That's a tab and a space in the []. 257fbed5abfSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 25817a48c7cSmrg else 25917a48c7cSmrg # The sourcefile does not contain any dependencies, so just 26017a48c7cSmrg # store a dummy comment line, to avoid errors with the Makefile 26117a48c7cSmrg # "include basename.Plo" scheme. 26217a48c7cSmrg echo "#dummy" > "$depfile" 26317a48c7cSmrg fi 26417a48c7cSmrg rm -f "$tmpdepfile" 26517a48c7cSmrg ;; 26617a48c7cSmrg 26717a48c7cSmrgicc) 26817a48c7cSmrg # Intel's C compiler understands `-MD -MF file'. However on 26917a48c7cSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 27017a48c7cSmrg # ICC 7.0 will fill foo.d with something like 27117a48c7cSmrg # foo.o: sub/foo.c 27217a48c7cSmrg # foo.o: sub/foo.h 27317a48c7cSmrg # which is wrong. We want: 27417a48c7cSmrg # sub/foo.o: sub/foo.c 27517a48c7cSmrg # sub/foo.o: sub/foo.h 27617a48c7cSmrg # sub/foo.c: 27717a48c7cSmrg # sub/foo.h: 27817a48c7cSmrg # ICC 7.1 will output 27917a48c7cSmrg # foo.o: sub/foo.c sub/foo.h 28017a48c7cSmrg # and will wrap long lines using \ : 28117a48c7cSmrg # foo.o: sub/foo.c ... \ 28217a48c7cSmrg # sub/foo.h ... \ 28317a48c7cSmrg # ... 28417a48c7cSmrg 28517a48c7cSmrg "$@" -MD -MF "$tmpdepfile" 28617a48c7cSmrg stat=$? 28717a48c7cSmrg if test $stat -eq 0; then : 28817a48c7cSmrg else 28917a48c7cSmrg rm -f "$tmpdepfile" 29017a48c7cSmrg exit $stat 29117a48c7cSmrg fi 29217a48c7cSmrg rm -f "$depfile" 29317a48c7cSmrg # Each line is of the form `foo.o: dependent.h', 29417a48c7cSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 29517a48c7cSmrg # Do two passes, one to just change these to 29617a48c7cSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 29717a48c7cSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 29817a48c7cSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 29917a48c7cSmrg # correctly. Breaking it into two sed invocations is a workaround. 30017a48c7cSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 30117a48c7cSmrg sed -e 's/$/ :/' >> "$depfile" 30217a48c7cSmrg rm -f "$tmpdepfile" 30317a48c7cSmrg ;; 30417a48c7cSmrg 3058e0ed500Smrghp2) 3068e0ed500Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3078e0ed500Smrg # compilers, which have integrated preprocessors. The correct option 3088e0ed500Smrg # to use with these is +Maked; it writes dependencies to a file named 3098e0ed500Smrg # 'foo.d', which lands next to the object file, wherever that 3108e0ed500Smrg # happens to be. 3118e0ed500Smrg # Much of this is similar to the tru64 case; see comments there. 3128e0ed500Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3138e0ed500Smrg test "x$dir" = "x$object" && dir= 3148e0ed500Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3158e0ed500Smrg if test "$libtool" = yes; then 3168e0ed500Smrg tmpdepfile1=$dir$base.d 3178e0ed500Smrg tmpdepfile2=$dir.libs/$base.d 3188e0ed500Smrg "$@" -Wc,+Maked 3198e0ed500Smrg else 3208e0ed500Smrg tmpdepfile1=$dir$base.d 3218e0ed500Smrg tmpdepfile2=$dir$base.d 3228e0ed500Smrg "$@" +Maked 3238e0ed500Smrg fi 3248e0ed500Smrg stat=$? 3258e0ed500Smrg if test $stat -eq 0; then : 3268e0ed500Smrg else 3278e0ed500Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3288e0ed500Smrg exit $stat 3298e0ed500Smrg fi 3308e0ed500Smrg 3318e0ed500Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3328e0ed500Smrg do 3338e0ed500Smrg test -f "$tmpdepfile" && break 3348e0ed500Smrg done 3358e0ed500Smrg if test -f "$tmpdepfile"; then 3368e0ed500Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3378e0ed500Smrg # Add `dependent.h:' lines. 338fbed5abfSmrg sed -ne '2,${ 339fbed5abfSmrg s/^ *// 340fbed5abfSmrg s/ \\*$// 341fbed5abfSmrg s/$/:/ 342fbed5abfSmrg p 343fbed5abfSmrg }' "$tmpdepfile" >> "$depfile" 3448e0ed500Smrg else 3458e0ed500Smrg echo "#dummy" > "$depfile" 3468e0ed500Smrg fi 3478e0ed500Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3488e0ed500Smrg ;; 3498e0ed500Smrg 35017a48c7cSmrgtru64) 35117a48c7cSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 35217a48c7cSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 35317a48c7cSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 35417a48c7cSmrg # dependencies in `foo.d' instead, so we check for that too. 35517a48c7cSmrg # Subdirectories are respected. 35617a48c7cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 35717a48c7cSmrg test "x$dir" = "x$object" && dir= 35817a48c7cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 35917a48c7cSmrg 36017a48c7cSmrg if test "$libtool" = yes; then 36117a48c7cSmrg # With Tru64 cc, shared objects can also be used to make a 3628e0ed500Smrg # static library. This mechanism is used in libtool 1.4 series to 36317a48c7cSmrg # handle both shared and static libraries in a single compilation. 36417a48c7cSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 36517a48c7cSmrg # 36617a48c7cSmrg # With libtool 1.5 this exception was removed, and libtool now 36717a48c7cSmrg # generates 2 separate objects for the 2 libraries. These two 3688e0ed500Smrg # compilations output dependencies in $dir.libs/$base.o.d and 36917a48c7cSmrg # in $dir$base.o.d. We have to check for both files, because 37017a48c7cSmrg # one of the two compilations can be disabled. We should prefer 37117a48c7cSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 37217a48c7cSmrg # automatically cleaned when .libs/ is deleted, while ignoring 37317a48c7cSmrg # the former would cause a distcleancheck panic. 37417a48c7cSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 37517a48c7cSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 37617a48c7cSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 37717a48c7cSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 37817a48c7cSmrg "$@" -Wc,-MD 37917a48c7cSmrg else 38017a48c7cSmrg tmpdepfile1=$dir$base.o.d 38117a48c7cSmrg tmpdepfile2=$dir$base.d 38217a48c7cSmrg tmpdepfile3=$dir$base.d 38317a48c7cSmrg tmpdepfile4=$dir$base.d 38417a48c7cSmrg "$@" -MD 38517a48c7cSmrg fi 38617a48c7cSmrg 38717a48c7cSmrg stat=$? 38817a48c7cSmrg if test $stat -eq 0; then : 38917a48c7cSmrg else 39017a48c7cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39117a48c7cSmrg exit $stat 39217a48c7cSmrg fi 39317a48c7cSmrg 39417a48c7cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39517a48c7cSmrg do 39617a48c7cSmrg test -f "$tmpdepfile" && break 39717a48c7cSmrg done 39817a48c7cSmrg if test -f "$tmpdepfile"; then 39917a48c7cSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 40017a48c7cSmrg # That's a tab and a space in the []. 40117a48c7cSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 40217a48c7cSmrg else 40317a48c7cSmrg echo "#dummy" > "$depfile" 40417a48c7cSmrg fi 40517a48c7cSmrg rm -f "$tmpdepfile" 40617a48c7cSmrg ;; 40717a48c7cSmrg 40817a48c7cSmrg#nosideeffect) 40917a48c7cSmrg # This comment above is used by automake to tell side-effect 41017a48c7cSmrg # dependency tracking mechanisms from slower ones. 41117a48c7cSmrg 41217a48c7cSmrgdashmstdout) 41317a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 41417a48c7cSmrg # always write the preprocessed file to stdout, regardless of -o. 41517a48c7cSmrg "$@" || exit $? 41617a48c7cSmrg 41717a48c7cSmrg # Remove the call to Libtool. 41817a48c7cSmrg if test "$libtool" = yes; then 419fbed5abfSmrg while test "X$1" != 'X--mode=compile'; do 42017a48c7cSmrg shift 42117a48c7cSmrg done 42217a48c7cSmrg shift 42317a48c7cSmrg fi 42417a48c7cSmrg 42517a48c7cSmrg # Remove `-o $object'. 42617a48c7cSmrg IFS=" " 42717a48c7cSmrg for arg 42817a48c7cSmrg do 42917a48c7cSmrg case $arg in 43017a48c7cSmrg -o) 43117a48c7cSmrg shift 43217a48c7cSmrg ;; 43317a48c7cSmrg $object) 43417a48c7cSmrg shift 43517a48c7cSmrg ;; 43617a48c7cSmrg *) 43717a48c7cSmrg set fnord "$@" "$arg" 43817a48c7cSmrg shift # fnord 43917a48c7cSmrg shift # $arg 44017a48c7cSmrg ;; 44117a48c7cSmrg esac 44217a48c7cSmrg done 44317a48c7cSmrg 44417a48c7cSmrg test -z "$dashmflag" && dashmflag=-M 44517a48c7cSmrg # Require at least two characters before searching for `:' 44617a48c7cSmrg # in the target name. This is to cope with DOS-style filenames: 44717a48c7cSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 44817a48c7cSmrg "$@" $dashmflag | 44917a48c7cSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 45017a48c7cSmrg rm -f "$depfile" 45117a48c7cSmrg cat < "$tmpdepfile" > "$depfile" 45217a48c7cSmrg tr ' ' ' 45317a48c7cSmrg' < "$tmpdepfile" | \ 45417a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 45517a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 45617a48c7cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 45717a48c7cSmrg rm -f "$tmpdepfile" 45817a48c7cSmrg ;; 45917a48c7cSmrg 46017a48c7cSmrgdashXmstdout) 46117a48c7cSmrg # This case only exists to satisfy depend.m4. It is never actually 46217a48c7cSmrg # run, as this mode is specially recognized in the preamble. 46317a48c7cSmrg exit 1 46417a48c7cSmrg ;; 46517a48c7cSmrg 46617a48c7cSmrgmakedepend) 46717a48c7cSmrg "$@" || exit $? 46817a48c7cSmrg # Remove any Libtool call 46917a48c7cSmrg if test "$libtool" = yes; then 470fbed5abfSmrg while test "X$1" != 'X--mode=compile'; do 47117a48c7cSmrg shift 47217a48c7cSmrg done 47317a48c7cSmrg shift 47417a48c7cSmrg fi 47517a48c7cSmrg # X makedepend 47617a48c7cSmrg shift 477fbed5abfSmrg cleared=no eat=no 478fbed5abfSmrg for arg 479fbed5abfSmrg do 48017a48c7cSmrg case $cleared in 48117a48c7cSmrg no) 48217a48c7cSmrg set ""; shift 48317a48c7cSmrg cleared=yes ;; 48417a48c7cSmrg esac 485fbed5abfSmrg if test $eat = yes; then 486fbed5abfSmrg eat=no 487fbed5abfSmrg continue 488fbed5abfSmrg fi 48917a48c7cSmrg case "$arg" in 49017a48c7cSmrg -D*|-I*) 49117a48c7cSmrg set fnord "$@" "$arg"; shift ;; 49217a48c7cSmrg # Strip any option that makedepend may not understand. Remove 49317a48c7cSmrg # the object too, otherwise makedepend will parse it as a source file. 494fbed5abfSmrg -arch) 495fbed5abfSmrg eat=yes ;; 49617a48c7cSmrg -*|$object) 49717a48c7cSmrg ;; 49817a48c7cSmrg *) 49917a48c7cSmrg set fnord "$@" "$arg"; shift ;; 50017a48c7cSmrg esac 50117a48c7cSmrg done 502fbed5abfSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 50317a48c7cSmrg touch "$tmpdepfile" 50417a48c7cSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 50517a48c7cSmrg rm -f "$depfile" 50617a48c7cSmrg cat < "$tmpdepfile" > "$depfile" 50717a48c7cSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 50817a48c7cSmrg' | \ 50917a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 51017a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 51117a48c7cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 51217a48c7cSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 51317a48c7cSmrg ;; 51417a48c7cSmrg 51517a48c7cSmrgcpp) 51617a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 51717a48c7cSmrg # always write the preprocessed file to stdout. 51817a48c7cSmrg "$@" || exit $? 51917a48c7cSmrg 52017a48c7cSmrg # Remove the call to Libtool. 52117a48c7cSmrg if test "$libtool" = yes; then 522fbed5abfSmrg while test "X$1" != 'X--mode=compile'; do 52317a48c7cSmrg shift 52417a48c7cSmrg done 52517a48c7cSmrg shift 52617a48c7cSmrg fi 52717a48c7cSmrg 52817a48c7cSmrg # Remove `-o $object'. 52917a48c7cSmrg IFS=" " 53017a48c7cSmrg for arg 53117a48c7cSmrg do 53217a48c7cSmrg case $arg in 53317a48c7cSmrg -o) 53417a48c7cSmrg shift 53517a48c7cSmrg ;; 53617a48c7cSmrg $object) 53717a48c7cSmrg shift 53817a48c7cSmrg ;; 53917a48c7cSmrg *) 54017a48c7cSmrg set fnord "$@" "$arg" 54117a48c7cSmrg shift # fnord 54217a48c7cSmrg shift # $arg 54317a48c7cSmrg ;; 54417a48c7cSmrg esac 54517a48c7cSmrg done 54617a48c7cSmrg 54717a48c7cSmrg "$@" -E | 54817a48c7cSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 54917a48c7cSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 55017a48c7cSmrg sed '$ s: \\$::' > "$tmpdepfile" 55117a48c7cSmrg rm -f "$depfile" 55217a48c7cSmrg echo "$object : \\" > "$depfile" 55317a48c7cSmrg cat < "$tmpdepfile" >> "$depfile" 55417a48c7cSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 55517a48c7cSmrg rm -f "$tmpdepfile" 55617a48c7cSmrg ;; 55717a48c7cSmrg 55817a48c7cSmrgmsvisualcpp) 55917a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 560fbed5abfSmrg # always write the preprocessed file to stdout. 56117a48c7cSmrg "$@" || exit $? 562fbed5abfSmrg 563fbed5abfSmrg # Remove the call to Libtool. 564fbed5abfSmrg if test "$libtool" = yes; then 565fbed5abfSmrg while test "X$1" != 'X--mode=compile'; do 566fbed5abfSmrg shift 567fbed5abfSmrg done 568fbed5abfSmrg shift 569fbed5abfSmrg fi 570fbed5abfSmrg 57117a48c7cSmrg IFS=" " 57217a48c7cSmrg for arg 57317a48c7cSmrg do 57417a48c7cSmrg case "$arg" in 575fbed5abfSmrg -o) 576fbed5abfSmrg shift 577fbed5abfSmrg ;; 578fbed5abfSmrg $object) 579fbed5abfSmrg shift 580fbed5abfSmrg ;; 58117a48c7cSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 58217a48c7cSmrg set fnord "$@" 58317a48c7cSmrg shift 58417a48c7cSmrg shift 58517a48c7cSmrg ;; 58617a48c7cSmrg *) 58717a48c7cSmrg set fnord "$@" "$arg" 58817a48c7cSmrg shift 58917a48c7cSmrg shift 59017a48c7cSmrg ;; 59117a48c7cSmrg esac 59217a48c7cSmrg done 593fbed5abfSmrg "$@" -E 2>/dev/null | 594fbed5abfSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 59517a48c7cSmrg rm -f "$depfile" 59617a48c7cSmrg echo "$object : \\" > "$depfile" 597fbed5abfSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 59817a48c7cSmrg echo " " >> "$depfile" 599fbed5abfSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 60017a48c7cSmrg rm -f "$tmpdepfile" 60117a48c7cSmrg ;; 60217a48c7cSmrg 603fbed5abfSmrgmsvcmsys) 604fbed5abfSmrg # This case exists only to let depend.m4 do its work. It works by 605fbed5abfSmrg # looking at the text of this script. This case will never be run, 606fbed5abfSmrg # since it is checked for above. 607fbed5abfSmrg exit 1 608fbed5abfSmrg ;; 609fbed5abfSmrg 61017a48c7cSmrgnone) 61117a48c7cSmrg exec "$@" 61217a48c7cSmrg ;; 61317a48c7cSmrg 61417a48c7cSmrg*) 61517a48c7cSmrg echo "Unknown depmode $depmode" 1>&2 61617a48c7cSmrg exit 1 61717a48c7cSmrg ;; 61817a48c7cSmrgesac 61917a48c7cSmrg 62017a48c7cSmrgexit 0 62117a48c7cSmrg 62217a48c7cSmrg# Local Variables: 62317a48c7cSmrg# mode: shell-script 62417a48c7cSmrg# sh-indentation: 2 62517a48c7cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 62617a48c7cSmrg# time-stamp-start: "scriptversion=" 62717a48c7cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 628fbed5abfSmrg# time-stamp-time-zone: "UTC" 629fbed5abfSmrg# time-stamp-end: "; # UTC" 63017a48c7cSmrg# End: 631