depcomp revision 7d575c90
1fdb3d228Smrg#! /bin/sh 2fdb3d228Smrg# depcomp - compile a program generating dependencies as side-effects 39b41ff1aSmrg 47d575c90Smrgscriptversion=2011-12-04.11; # UTC 59b41ff1aSmrg 67d575c90Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 77d575c90Smrg# 2011 Free Software Foundation, Inc. 8fdb3d228Smrg 9fdb3d228Smrg# This program is free software; you can redistribute it and/or modify 10fdb3d228Smrg# it under the terms of the GNU General Public License as published by 11fdb3d228Smrg# the Free Software Foundation; either version 2, or (at your option) 12fdb3d228Smrg# any later version. 13fdb3d228Smrg 14fdb3d228Smrg# This program is distributed in the hope that it will be useful, 15fdb3d228Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16fdb3d228Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17fdb3d228Smrg# GNU General Public License for more details. 18fdb3d228Smrg 19fdb3d228Smrg# You should have received a copy of the GNU General Public License 209b41ff1aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21fdb3d228Smrg 22fdb3d228Smrg# As a special exception to the GNU General Public License, if you 23fdb3d228Smrg# distribute this file as part of a program that contains a 24fdb3d228Smrg# configuration script generated by Autoconf, you may include it under 25fdb3d228Smrg# the same distribution terms that you use for the rest of that program. 26fdb3d228Smrg 27fdb3d228Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28fdb3d228Smrg 299b41ff1aSmrgcase $1 in 309b41ff1aSmrg '') 319b41ff1aSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 329b41ff1aSmrg exit 1; 339b41ff1aSmrg ;; 349b41ff1aSmrg -h | --h*) 359b41ff1aSmrg cat <<\EOF 369b41ff1aSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 379b41ff1aSmrg 389b41ff1aSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 399b41ff1aSmrgas side-effects. 409b41ff1aSmrg 419b41ff1aSmrgEnvironment variables: 429b41ff1aSmrg depmode Dependency tracking mode. 439b41ff1aSmrg source Source file read by `PROGRAMS ARGS'. 449b41ff1aSmrg object Object file output by `PROGRAMS ARGS'. 459b41ff1aSmrg DEPDIR directory where to store dependencies. 469b41ff1aSmrg depfile Dependency file to output. 477d575c90Smrg tmpdepfile Temporary file to use when outputting dependencies. 489b41ff1aSmrg libtool Whether libtool is used (yes/no). 499b41ff1aSmrg 509b41ff1aSmrgReport bugs to <bug-automake@gnu.org>. 519b41ff1aSmrgEOF 529b41ff1aSmrg exit $? 539b41ff1aSmrg ;; 549b41ff1aSmrg -v | --v*) 559b41ff1aSmrg echo "depcomp $scriptversion" 569b41ff1aSmrg exit $? 579b41ff1aSmrg ;; 589b41ff1aSmrgesac 599b41ff1aSmrg 60fdb3d228Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61fdb3d228Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62fdb3d228Smrg exit 1 63fdb3d228Smrgfi 64fdb3d228Smrg 659b41ff1aSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 669b41ff1aSmrgdepfile=${depfile-`echo "$object" | 679b41ff1aSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68fdb3d228Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69fdb3d228Smrg 70fdb3d228Smrgrm -f "$tmpdepfile" 71fdb3d228Smrg 72fdb3d228Smrg# Some modes work just like other modes, but use different flags. We 73fdb3d228Smrg# parameterize here, but still list the modes in the big case below, 74fdb3d228Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75fdb3d228Smrg# here, because this file can only contain one case statement. 76fdb3d228Smrgif test "$depmode" = hp; then 77fdb3d228Smrg # HP compiler uses -M and no extra arg. 78fdb3d228Smrg gccflag=-M 79fdb3d228Smrg depmode=gcc 80fdb3d228Smrgfi 81fdb3d228Smrg 82fdb3d228Smrgif test "$depmode" = dashXmstdout; then 83fdb3d228Smrg # This is just like dashmstdout with a different argument. 84fdb3d228Smrg dashmflag=-xM 85fdb3d228Smrg depmode=dashmstdout 86fdb3d228Smrgfi 87fdb3d228Smrg 889b41ff1aSmrgcygpath_u="cygpath -u -f -" 899b41ff1aSmrgif test "$depmode" = msvcmsys; then 909b41ff1aSmrg # This is just like msvisualcpp but w/o cygpath translation. 919b41ff1aSmrg # Just convert the backslash-escaped backslashes to single forward 929b41ff1aSmrg # slashes to satisfy depend.m4 937d575c90Smrg cygpath_u='sed s,\\\\,/,g' 949b41ff1aSmrg depmode=msvisualcpp 959b41ff1aSmrgfi 969b41ff1aSmrg 977d575c90Smrgif test "$depmode" = msvc7msys; then 987d575c90Smrg # This is just like msvc7 but w/o cygpath translation. 997d575c90Smrg # Just convert the backslash-escaped backslashes to single forward 1007d575c90Smrg # slashes to satisfy depend.m4 1017d575c90Smrg cygpath_u='sed s,\\\\,/,g' 1027d575c90Smrg depmode=msvc7 1037d575c90Smrgfi 1047d575c90Smrg 105fdb3d228Smrgcase "$depmode" in 106fdb3d228Smrggcc3) 107fdb3d228Smrg## gcc 3 implements dependency tracking that does exactly what 108fdb3d228Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 109fdb3d228Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 1109b41ff1aSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1119b41ff1aSmrg## the command line argument order; so add the flags where they 1129b41ff1aSmrg## appear in depend2.am. Note that the slowdown incurred here 1139b41ff1aSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1149b41ff1aSmrg for arg 1159b41ff1aSmrg do 1169b41ff1aSmrg case $arg in 1179b41ff1aSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1189b41ff1aSmrg *) set fnord "$@" "$arg" ;; 1199b41ff1aSmrg esac 1209b41ff1aSmrg shift # fnord 1219b41ff1aSmrg shift # $arg 1229b41ff1aSmrg done 1239b41ff1aSmrg "$@" 124fdb3d228Smrg stat=$? 125fdb3d228Smrg if test $stat -eq 0; then : 126fdb3d228Smrg else 127fdb3d228Smrg rm -f "$tmpdepfile" 128fdb3d228Smrg exit $stat 129fdb3d228Smrg fi 130fdb3d228Smrg mv "$tmpdepfile" "$depfile" 131fdb3d228Smrg ;; 132fdb3d228Smrg 133fdb3d228Smrggcc) 134fdb3d228Smrg## There are various ways to get dependency output from gcc. Here's 135fdb3d228Smrg## why we pick this rather obscure method: 136fdb3d228Smrg## - Don't want to use -MD because we'd like the dependencies to end 137fdb3d228Smrg## up in a subdir. Having to rename by hand is ugly. 138fdb3d228Smrg## (We might end up doing this anyway to support other compilers.) 139fdb3d228Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 140fdb3d228Smrg## -MM, not -M (despite what the docs say). 141fdb3d228Smrg## - Using -M directly means running the compiler twice (even worse 142fdb3d228Smrg## than renaming). 143fdb3d228Smrg if test -z "$gccflag"; then 144fdb3d228Smrg gccflag=-MD, 145fdb3d228Smrg fi 146fdb3d228Smrg "$@" -Wp,"$gccflag$tmpdepfile" 147fdb3d228Smrg stat=$? 148fdb3d228Smrg if test $stat -eq 0; then : 149fdb3d228Smrg else 150fdb3d228Smrg rm -f "$tmpdepfile" 151fdb3d228Smrg exit $stat 152fdb3d228Smrg fi 153fdb3d228Smrg rm -f "$depfile" 154fdb3d228Smrg echo "$object : \\" > "$depfile" 155fdb3d228Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 156fdb3d228Smrg## The second -e expression handles DOS-style file names with drive letters. 157fdb3d228Smrg sed -e 's/^[^:]*: / /' \ 158fdb3d228Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 159fdb3d228Smrg## This next piece of magic avoids the `deleted header file' problem. 160fdb3d228Smrg## The problem is that when a header file which appears in a .P file 161fdb3d228Smrg## is deleted, the dependency causes make to die (because there is 162fdb3d228Smrg## typically no way to rebuild the header). We avoid this by adding 163fdb3d228Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 164fdb3d228Smrg## this for us directly. 165fdb3d228Smrg tr ' ' ' 166fdb3d228Smrg' < "$tmpdepfile" | 167fdb3d228Smrg## Some versions of gcc put a space before the `:'. On the theory 168fdb3d228Smrg## that the space means something, we add a space to the output as 1697d575c90Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 1707d575c90Smrg## to the object. Take care to not repeat it in the output. 171fdb3d228Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 172fdb3d228Smrg## correctly. Breaking it into two sed invocations is a workaround. 1737d575c90Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 1747d575c90Smrg | sed -e 's/$/ :/' >> "$depfile" 175fdb3d228Smrg rm -f "$tmpdepfile" 176fdb3d228Smrg ;; 177fdb3d228Smrg 178fdb3d228Smrghp) 179fdb3d228Smrg # This case exists only to let depend.m4 do its work. It works by 180fdb3d228Smrg # looking at the text of this script. This case will never be run, 181fdb3d228Smrg # since it is checked for above. 182fdb3d228Smrg exit 1 183fdb3d228Smrg ;; 184fdb3d228Smrg 185fdb3d228Smrgsgi) 186fdb3d228Smrg if test "$libtool" = yes; then 187fdb3d228Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 188fdb3d228Smrg else 189fdb3d228Smrg "$@" -MDupdate "$tmpdepfile" 190fdb3d228Smrg fi 191fdb3d228Smrg stat=$? 192fdb3d228Smrg if test $stat -eq 0; then : 193fdb3d228Smrg else 194fdb3d228Smrg rm -f "$tmpdepfile" 195fdb3d228Smrg exit $stat 196fdb3d228Smrg fi 197fdb3d228Smrg rm -f "$depfile" 198fdb3d228Smrg 199fdb3d228Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 200fdb3d228Smrg echo "$object : \\" > "$depfile" 201fdb3d228Smrg 202fdb3d228Smrg # Clip off the initial element (the dependent). Don't try to be 203fdb3d228Smrg # clever and replace this with sed code, as IRIX sed won't handle 204fdb3d228Smrg # lines with more than a fixed number of characters (4096 in 205fdb3d228Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 206fdb3d228Smrg # the IRIX cc adds comments like `#:fec' to the end of the 207fdb3d228Smrg # dependency line. 208fdb3d228Smrg tr ' ' ' 209fdb3d228Smrg' < "$tmpdepfile" \ 210fdb3d228Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 211fdb3d228Smrg tr ' 2129b41ff1aSmrg' ' ' >> "$depfile" 2139b41ff1aSmrg echo >> "$depfile" 214fdb3d228Smrg 215fdb3d228Smrg # The second pass generates a dummy entry for each header file. 216fdb3d228Smrg tr ' ' ' 217fdb3d228Smrg' < "$tmpdepfile" \ 218fdb3d228Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2199b41ff1aSmrg >> "$depfile" 220fdb3d228Smrg else 221fdb3d228Smrg # The sourcefile does not contain any dependencies, so just 222fdb3d228Smrg # store a dummy comment line, to avoid errors with the Makefile 223fdb3d228Smrg # "include basename.Plo" scheme. 224fdb3d228Smrg echo "#dummy" > "$depfile" 225fdb3d228Smrg fi 226fdb3d228Smrg rm -f "$tmpdepfile" 227fdb3d228Smrg ;; 228fdb3d228Smrg 229fdb3d228Smrgaix) 230fdb3d228Smrg # The C for AIX Compiler uses -M and outputs the dependencies 231fdb3d228Smrg # in a .u file. In older versions, this file always lives in the 232fdb3d228Smrg # current directory. Also, the AIX compiler puts `$object:' at the 233fdb3d228Smrg # start of each line; $object doesn't have directory information. 234fdb3d228Smrg # Version 6 uses the directory in both cases. 2359b41ff1aSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2369b41ff1aSmrg test "x$dir" = "x$object" && dir= 2379b41ff1aSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 238fdb3d228Smrg if test "$libtool" = yes; then 2399b41ff1aSmrg tmpdepfile1=$dir$base.u 2409b41ff1aSmrg tmpdepfile2=$base.u 2419b41ff1aSmrg tmpdepfile3=$dir.libs/$base.u 242fdb3d228Smrg "$@" -Wc,-M 243fdb3d228Smrg else 2449b41ff1aSmrg tmpdepfile1=$dir$base.u 2459b41ff1aSmrg tmpdepfile2=$dir$base.u 2469b41ff1aSmrg tmpdepfile3=$dir$base.u 247fdb3d228Smrg "$@" -M 248fdb3d228Smrg fi 249fdb3d228Smrg stat=$? 250fdb3d228Smrg 251fdb3d228Smrg if test $stat -eq 0; then : 252fdb3d228Smrg else 2539b41ff1aSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 254fdb3d228Smrg exit $stat 255fdb3d228Smrg fi 256fdb3d228Smrg 2579b41ff1aSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2589b41ff1aSmrg do 2599b41ff1aSmrg test -f "$tmpdepfile" && break 2609b41ff1aSmrg done 261fdb3d228Smrg if test -f "$tmpdepfile"; then 262fdb3d228Smrg # Each line is of the form `foo.o: dependent.h'. 263fdb3d228Smrg # Do two passes, one to just change these to 264fdb3d228Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2659b41ff1aSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2669b41ff1aSmrg # That's a tab and a space in the []. 2679b41ff1aSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 268fdb3d228Smrg else 269fdb3d228Smrg # The sourcefile does not contain any dependencies, so just 270fdb3d228Smrg # store a dummy comment line, to avoid errors with the Makefile 271fdb3d228Smrg # "include basename.Plo" scheme. 272fdb3d228Smrg echo "#dummy" > "$depfile" 273fdb3d228Smrg fi 274fdb3d228Smrg rm -f "$tmpdepfile" 275fdb3d228Smrg ;; 276fdb3d228Smrg 277fdb3d228Smrgicc) 278fdb3d228Smrg # Intel's C compiler understands `-MD -MF file'. However on 279fdb3d228Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 280fdb3d228Smrg # ICC 7.0 will fill foo.d with something like 281fdb3d228Smrg # foo.o: sub/foo.c 282fdb3d228Smrg # foo.o: sub/foo.h 283fdb3d228Smrg # which is wrong. We want: 284fdb3d228Smrg # sub/foo.o: sub/foo.c 285fdb3d228Smrg # sub/foo.o: sub/foo.h 286fdb3d228Smrg # sub/foo.c: 287fdb3d228Smrg # sub/foo.h: 288fdb3d228Smrg # ICC 7.1 will output 289fdb3d228Smrg # foo.o: sub/foo.c sub/foo.h 290fdb3d228Smrg # and will wrap long lines using \ : 291fdb3d228Smrg # foo.o: sub/foo.c ... \ 292fdb3d228Smrg # sub/foo.h ... \ 293fdb3d228Smrg # ... 294fdb3d228Smrg 295fdb3d228Smrg "$@" -MD -MF "$tmpdepfile" 296fdb3d228Smrg stat=$? 297fdb3d228Smrg if test $stat -eq 0; then : 298fdb3d228Smrg else 299fdb3d228Smrg rm -f "$tmpdepfile" 300fdb3d228Smrg exit $stat 301fdb3d228Smrg fi 302fdb3d228Smrg rm -f "$depfile" 303fdb3d228Smrg # Each line is of the form `foo.o: dependent.h', 304fdb3d228Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 305fdb3d228Smrg # Do two passes, one to just change these to 306fdb3d228Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 307fdb3d228Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 308fdb3d228Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 309fdb3d228Smrg # correctly. Breaking it into two sed invocations is a workaround. 310fdb3d228Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 311fdb3d228Smrg sed -e 's/$/ :/' >> "$depfile" 312fdb3d228Smrg rm -f "$tmpdepfile" 313fdb3d228Smrg ;; 314fdb3d228Smrg 3159b41ff1aSmrghp2) 3169b41ff1aSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3179b41ff1aSmrg # compilers, which have integrated preprocessors. The correct option 3189b41ff1aSmrg # to use with these is +Maked; it writes dependencies to a file named 3199b41ff1aSmrg # 'foo.d', which lands next to the object file, wherever that 3209b41ff1aSmrg # happens to be. 3219b41ff1aSmrg # Much of this is similar to the tru64 case; see comments there. 3229b41ff1aSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3239b41ff1aSmrg test "x$dir" = "x$object" && dir= 3249b41ff1aSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3259b41ff1aSmrg if test "$libtool" = yes; then 3269b41ff1aSmrg tmpdepfile1=$dir$base.d 3279b41ff1aSmrg tmpdepfile2=$dir.libs/$base.d 3289b41ff1aSmrg "$@" -Wc,+Maked 3299b41ff1aSmrg else 3309b41ff1aSmrg tmpdepfile1=$dir$base.d 3319b41ff1aSmrg tmpdepfile2=$dir$base.d 3329b41ff1aSmrg "$@" +Maked 3339b41ff1aSmrg fi 3349b41ff1aSmrg stat=$? 3359b41ff1aSmrg if test $stat -eq 0; then : 3369b41ff1aSmrg else 3379b41ff1aSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3389b41ff1aSmrg exit $stat 3399b41ff1aSmrg fi 3409b41ff1aSmrg 3419b41ff1aSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3429b41ff1aSmrg do 3439b41ff1aSmrg test -f "$tmpdepfile" && break 3449b41ff1aSmrg done 3459b41ff1aSmrg if test -f "$tmpdepfile"; then 3469b41ff1aSmrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3479b41ff1aSmrg # Add `dependent.h:' lines. 3489b41ff1aSmrg sed -ne '2,${ 3499b41ff1aSmrg s/^ *// 3509b41ff1aSmrg s/ \\*$// 3519b41ff1aSmrg s/$/:/ 3529b41ff1aSmrg p 3539b41ff1aSmrg }' "$tmpdepfile" >> "$depfile" 3549b41ff1aSmrg else 3559b41ff1aSmrg echo "#dummy" > "$depfile" 3569b41ff1aSmrg fi 3579b41ff1aSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 3589b41ff1aSmrg ;; 3599b41ff1aSmrg 360fdb3d228Smrgtru64) 361fdb3d228Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 362fdb3d228Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 363fdb3d228Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 364fdb3d228Smrg # dependencies in `foo.d' instead, so we check for that too. 365fdb3d228Smrg # Subdirectories are respected. 366fdb3d228Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 367fdb3d228Smrg test "x$dir" = "x$object" && dir= 368fdb3d228Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 369fdb3d228Smrg 370fdb3d228Smrg if test "$libtool" = yes; then 3719b41ff1aSmrg # With Tru64 cc, shared objects can also be used to make a 3729b41ff1aSmrg # static library. This mechanism is used in libtool 1.4 series to 3739b41ff1aSmrg # handle both shared and static libraries in a single compilation. 3749b41ff1aSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3759b41ff1aSmrg # 3769b41ff1aSmrg # With libtool 1.5 this exception was removed, and libtool now 3779b41ff1aSmrg # generates 2 separate objects for the 2 libraries. These two 3789b41ff1aSmrg # compilations output dependencies in $dir.libs/$base.o.d and 3799b41ff1aSmrg # in $dir$base.o.d. We have to check for both files, because 3809b41ff1aSmrg # one of the two compilations can be disabled. We should prefer 3819b41ff1aSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3829b41ff1aSmrg # automatically cleaned when .libs/ is deleted, while ignoring 3839b41ff1aSmrg # the former would cause a distcleancheck panic. 3849b41ff1aSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3859b41ff1aSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3869b41ff1aSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3879b41ff1aSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 388fdb3d228Smrg "$@" -Wc,-MD 389fdb3d228Smrg else 3909b41ff1aSmrg tmpdepfile1=$dir$base.o.d 3919b41ff1aSmrg tmpdepfile2=$dir$base.d 3929b41ff1aSmrg tmpdepfile3=$dir$base.d 3939b41ff1aSmrg tmpdepfile4=$dir$base.d 394fdb3d228Smrg "$@" -MD 395fdb3d228Smrg fi 396fdb3d228Smrg 397fdb3d228Smrg stat=$? 398fdb3d228Smrg if test $stat -eq 0; then : 399fdb3d228Smrg else 4009b41ff1aSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 401fdb3d228Smrg exit $stat 402fdb3d228Smrg fi 403fdb3d228Smrg 4049b41ff1aSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 4059b41ff1aSmrg do 4069b41ff1aSmrg test -f "$tmpdepfile" && break 4079b41ff1aSmrg done 408fdb3d228Smrg if test -f "$tmpdepfile"; then 409fdb3d228Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 410fdb3d228Smrg # That's a tab and a space in the []. 411fdb3d228Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 412fdb3d228Smrg else 413fdb3d228Smrg echo "#dummy" > "$depfile" 414fdb3d228Smrg fi 415fdb3d228Smrg rm -f "$tmpdepfile" 416fdb3d228Smrg ;; 417fdb3d228Smrg 4187d575c90Smrgmsvc7) 4197d575c90Smrg if test "$libtool" = yes; then 4207d575c90Smrg showIncludes=-Wc,-showIncludes 4217d575c90Smrg else 4227d575c90Smrg showIncludes=-showIncludes 4237d575c90Smrg fi 4247d575c90Smrg "$@" $showIncludes > "$tmpdepfile" 4257d575c90Smrg stat=$? 4267d575c90Smrg grep -v '^Note: including file: ' "$tmpdepfile" 4277d575c90Smrg if test "$stat" = 0; then : 4287d575c90Smrg else 4297d575c90Smrg rm -f "$tmpdepfile" 4307d575c90Smrg exit $stat 4317d575c90Smrg fi 4327d575c90Smrg rm -f "$depfile" 4337d575c90Smrg echo "$object : \\" > "$depfile" 4347d575c90Smrg # The first sed program below extracts the file names and escapes 4357d575c90Smrg # backslashes for cygpath. The second sed program outputs the file 4367d575c90Smrg # name when reading, but also accumulates all include files in the 4377d575c90Smrg # hold buffer in order to output them again at the end. This only 4387d575c90Smrg # works with sed implementations that can handle large buffers. 4397d575c90Smrg sed < "$tmpdepfile" -n ' 4407d575c90Smrg/^Note: including file: *\(.*\)/ { 4417d575c90Smrg s//\1/ 4427d575c90Smrg s/\\/\\\\/g 4437d575c90Smrg p 4447d575c90Smrg}' | $cygpath_u | sort -u | sed -n ' 4457d575c90Smrgs/ /\\ /g 4467d575c90Smrgs/\(.*\)/ \1 \\/p 4477d575c90Smrgs/.\(.*\) \\/\1:/ 4487d575c90SmrgH 4497d575c90Smrg$ { 4507d575c90Smrg s/.*/ / 4517d575c90Smrg G 4527d575c90Smrg p 4537d575c90Smrg}' >> "$depfile" 4547d575c90Smrg rm -f "$tmpdepfile" 4557d575c90Smrg ;; 4567d575c90Smrg 4577d575c90Smrgmsvc7msys) 4587d575c90Smrg # This case exists only to let depend.m4 do its work. It works by 4597d575c90Smrg # looking at the text of this script. This case will never be run, 4607d575c90Smrg # since it is checked for above. 4617d575c90Smrg exit 1 4627d575c90Smrg ;; 4637d575c90Smrg 464fdb3d228Smrg#nosideeffect) 465fdb3d228Smrg # This comment above is used by automake to tell side-effect 466fdb3d228Smrg # dependency tracking mechanisms from slower ones. 467fdb3d228Smrg 468fdb3d228Smrgdashmstdout) 469fdb3d228Smrg # Important note: in order to support this mode, a compiler *must* 470fdb3d228Smrg # always write the preprocessed file to stdout, regardless of -o. 471fdb3d228Smrg "$@" || exit $? 472fdb3d228Smrg 473fdb3d228Smrg # Remove the call to Libtool. 474fdb3d228Smrg if test "$libtool" = yes; then 4759b41ff1aSmrg while test "X$1" != 'X--mode=compile'; do 476fdb3d228Smrg shift 477fdb3d228Smrg done 478fdb3d228Smrg shift 479fdb3d228Smrg fi 480fdb3d228Smrg 481fdb3d228Smrg # Remove `-o $object'. 482fdb3d228Smrg IFS=" " 483fdb3d228Smrg for arg 484fdb3d228Smrg do 485fdb3d228Smrg case $arg in 486fdb3d228Smrg -o) 487fdb3d228Smrg shift 488fdb3d228Smrg ;; 489fdb3d228Smrg $object) 490fdb3d228Smrg shift 491fdb3d228Smrg ;; 492fdb3d228Smrg *) 493fdb3d228Smrg set fnord "$@" "$arg" 494fdb3d228Smrg shift # fnord 495fdb3d228Smrg shift # $arg 496fdb3d228Smrg ;; 497fdb3d228Smrg esac 498fdb3d228Smrg done 499fdb3d228Smrg 500fdb3d228Smrg test -z "$dashmflag" && dashmflag=-M 501fdb3d228Smrg # Require at least two characters before searching for `:' 502fdb3d228Smrg # in the target name. This is to cope with DOS-style filenames: 503fdb3d228Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 504fdb3d228Smrg "$@" $dashmflag | 505fdb3d228Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 506fdb3d228Smrg rm -f "$depfile" 507fdb3d228Smrg cat < "$tmpdepfile" > "$depfile" 508fdb3d228Smrg tr ' ' ' 509fdb3d228Smrg' < "$tmpdepfile" | \ 510fdb3d228Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 511fdb3d228Smrg## correctly. Breaking it into two sed invocations is a workaround. 512fdb3d228Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 513fdb3d228Smrg rm -f "$tmpdepfile" 514fdb3d228Smrg ;; 515fdb3d228Smrg 516fdb3d228SmrgdashXmstdout) 517fdb3d228Smrg # This case only exists to satisfy depend.m4. It is never actually 518fdb3d228Smrg # run, as this mode is specially recognized in the preamble. 519fdb3d228Smrg exit 1 520fdb3d228Smrg ;; 521fdb3d228Smrg 522fdb3d228Smrgmakedepend) 523fdb3d228Smrg "$@" || exit $? 524fdb3d228Smrg # Remove any Libtool call 525fdb3d228Smrg if test "$libtool" = yes; then 5269b41ff1aSmrg while test "X$1" != 'X--mode=compile'; do 527fdb3d228Smrg shift 528fdb3d228Smrg done 529fdb3d228Smrg shift 530fdb3d228Smrg fi 531fdb3d228Smrg # X makedepend 532fdb3d228Smrg shift 5339b41ff1aSmrg cleared=no eat=no 5349b41ff1aSmrg for arg 5359b41ff1aSmrg do 536fdb3d228Smrg case $cleared in 537fdb3d228Smrg no) 538fdb3d228Smrg set ""; shift 539fdb3d228Smrg cleared=yes ;; 540fdb3d228Smrg esac 5419b41ff1aSmrg if test $eat = yes; then 5429b41ff1aSmrg eat=no 5439b41ff1aSmrg continue 5449b41ff1aSmrg fi 545fdb3d228Smrg case "$arg" in 546fdb3d228Smrg -D*|-I*) 547fdb3d228Smrg set fnord "$@" "$arg"; shift ;; 548fdb3d228Smrg # Strip any option that makedepend may not understand. Remove 549fdb3d228Smrg # the object too, otherwise makedepend will parse it as a source file. 5509b41ff1aSmrg -arch) 5519b41ff1aSmrg eat=yes ;; 552fdb3d228Smrg -*|$object) 553fdb3d228Smrg ;; 554fdb3d228Smrg *) 555fdb3d228Smrg set fnord "$@" "$arg"; shift ;; 556fdb3d228Smrg esac 557fdb3d228Smrg done 5589b41ff1aSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 559fdb3d228Smrg touch "$tmpdepfile" 560fdb3d228Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 561fdb3d228Smrg rm -f "$depfile" 5627d575c90Smrg # makedepend may prepend the VPATH from the source file name to the object. 5637d575c90Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 5647d575c90Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 565fdb3d228Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 566fdb3d228Smrg' | \ 567fdb3d228Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 568fdb3d228Smrg## correctly. Breaking it into two sed invocations is a workaround. 569fdb3d228Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 570fdb3d228Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 571fdb3d228Smrg ;; 572fdb3d228Smrg 573fdb3d228Smrgcpp) 574fdb3d228Smrg # Important note: in order to support this mode, a compiler *must* 575fdb3d228Smrg # always write the preprocessed file to stdout. 576fdb3d228Smrg "$@" || exit $? 577fdb3d228Smrg 578fdb3d228Smrg # Remove the call to Libtool. 579fdb3d228Smrg if test "$libtool" = yes; then 5809b41ff1aSmrg while test "X$1" != 'X--mode=compile'; do 581fdb3d228Smrg shift 582fdb3d228Smrg done 583fdb3d228Smrg shift 584fdb3d228Smrg fi 585fdb3d228Smrg 586fdb3d228Smrg # Remove `-o $object'. 587fdb3d228Smrg IFS=" " 588fdb3d228Smrg for arg 589fdb3d228Smrg do 590fdb3d228Smrg case $arg in 591fdb3d228Smrg -o) 592fdb3d228Smrg shift 593fdb3d228Smrg ;; 594fdb3d228Smrg $object) 595fdb3d228Smrg shift 596fdb3d228Smrg ;; 597fdb3d228Smrg *) 598fdb3d228Smrg set fnord "$@" "$arg" 599fdb3d228Smrg shift # fnord 600fdb3d228Smrg shift # $arg 601fdb3d228Smrg ;; 602fdb3d228Smrg esac 603fdb3d228Smrg done 604fdb3d228Smrg 605fdb3d228Smrg "$@" -E | 6069b41ff1aSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 6079b41ff1aSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 608fdb3d228Smrg sed '$ s: \\$::' > "$tmpdepfile" 609fdb3d228Smrg rm -f "$depfile" 610fdb3d228Smrg echo "$object : \\" > "$depfile" 611fdb3d228Smrg cat < "$tmpdepfile" >> "$depfile" 612fdb3d228Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 613fdb3d228Smrg rm -f "$tmpdepfile" 614fdb3d228Smrg ;; 615fdb3d228Smrg 616fdb3d228Smrgmsvisualcpp) 617fdb3d228Smrg # Important note: in order to support this mode, a compiler *must* 6189b41ff1aSmrg # always write the preprocessed file to stdout. 619fdb3d228Smrg "$@" || exit $? 6209b41ff1aSmrg 6219b41ff1aSmrg # Remove the call to Libtool. 6229b41ff1aSmrg if test "$libtool" = yes; then 6239b41ff1aSmrg while test "X$1" != 'X--mode=compile'; do 6249b41ff1aSmrg shift 6259b41ff1aSmrg done 6269b41ff1aSmrg shift 6279b41ff1aSmrg fi 6289b41ff1aSmrg 629fdb3d228Smrg IFS=" " 630fdb3d228Smrg for arg 631fdb3d228Smrg do 632fdb3d228Smrg case "$arg" in 6339b41ff1aSmrg -o) 6349b41ff1aSmrg shift 6359b41ff1aSmrg ;; 6369b41ff1aSmrg $object) 6379b41ff1aSmrg shift 6389b41ff1aSmrg ;; 639fdb3d228Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 640fdb3d228Smrg set fnord "$@" 641fdb3d228Smrg shift 642fdb3d228Smrg shift 643fdb3d228Smrg ;; 644fdb3d228Smrg *) 645fdb3d228Smrg set fnord "$@" "$arg" 646fdb3d228Smrg shift 647fdb3d228Smrg shift 648fdb3d228Smrg ;; 649fdb3d228Smrg esac 650fdb3d228Smrg done 6519b41ff1aSmrg "$@" -E 2>/dev/null | 6529b41ff1aSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 653fdb3d228Smrg rm -f "$depfile" 654fdb3d228Smrg echo "$object : \\" > "$depfile" 6559b41ff1aSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 656fdb3d228Smrg echo " " >> "$depfile" 6579b41ff1aSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 658fdb3d228Smrg rm -f "$tmpdepfile" 659fdb3d228Smrg ;; 660fdb3d228Smrg 6619b41ff1aSmrgmsvcmsys) 6629b41ff1aSmrg # This case exists only to let depend.m4 do its work. It works by 6639b41ff1aSmrg # looking at the text of this script. This case will never be run, 6649b41ff1aSmrg # since it is checked for above. 6659b41ff1aSmrg exit 1 6669b41ff1aSmrg ;; 6679b41ff1aSmrg 668fdb3d228Smrgnone) 669fdb3d228Smrg exec "$@" 670fdb3d228Smrg ;; 671fdb3d228Smrg 672fdb3d228Smrg*) 673fdb3d228Smrg echo "Unknown depmode $depmode" 1>&2 674fdb3d228Smrg exit 1 675fdb3d228Smrg ;; 676fdb3d228Smrgesac 677fdb3d228Smrg 678fdb3d228Smrgexit 0 6799b41ff1aSmrg 6809b41ff1aSmrg# Local Variables: 6819b41ff1aSmrg# mode: shell-script 6829b41ff1aSmrg# sh-indentation: 2 6839b41ff1aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 6849b41ff1aSmrg# time-stamp-start: "scriptversion=" 6859b41ff1aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 6869b41ff1aSmrg# time-stamp-time-zone: "UTC" 6879b41ff1aSmrg# time-stamp-end: "; # UTC" 6889b41ff1aSmrg# End: 689