1*a376eb32SXin Li#! /bin/sh 2*a376eb32SXin Li# depcomp - compile a program generating dependencies as side-effects 3*a376eb32SXin Li 4*a376eb32SXin Liscriptversion=2009-04-28.21; # UTC 5*a376eb32SXin Li 6*a376eb32SXin Li# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7*a376eb32SXin Li# Software Foundation, Inc. 8*a376eb32SXin Li 9*a376eb32SXin Li# This program is free software; you can redistribute it and/or modify 10*a376eb32SXin Li# it under the terms of the GNU General Public License as published by 11*a376eb32SXin Li# the Free Software Foundation; either version 2, or (at your option) 12*a376eb32SXin Li# any later version. 13*a376eb32SXin Li 14*a376eb32SXin Li# This program is distributed in the hope that it will be useful, 15*a376eb32SXin Li# but WITHOUT ANY WARRANTY; without even the implied warranty of 16*a376eb32SXin Li# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*a376eb32SXin Li# GNU General Public License for more details. 18*a376eb32SXin Li 19*a376eb32SXin Li# You should have received a copy of the GNU General Public License 20*a376eb32SXin Li# along with this program. If not, see <http://www.gnu.org/licenses/>. 21*a376eb32SXin Li 22*a376eb32SXin Li# As a special exception to the GNU General Public License, if you 23*a376eb32SXin Li# distribute this file as part of a program that contains a 24*a376eb32SXin Li# configuration script generated by Autoconf, you may include it under 25*a376eb32SXin Li# the same distribution terms that you use for the rest of that program. 26*a376eb32SXin Li 27*a376eb32SXin Li# Originally written by Alexandre Oliva <[email protected]>. 28*a376eb32SXin Li 29*a376eb32SXin Licase $1 in 30*a376eb32SXin Li '') 31*a376eb32SXin Li echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32*a376eb32SXin Li exit 1; 33*a376eb32SXin Li ;; 34*a376eb32SXin Li -h | --h*) 35*a376eb32SXin Li cat <<\EOF 36*a376eb32SXin LiUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37*a376eb32SXin Li 38*a376eb32SXin LiRun PROGRAMS ARGS to compile a file, generating dependencies 39*a376eb32SXin Lias side-effects. 40*a376eb32SXin Li 41*a376eb32SXin LiEnvironment variables: 42*a376eb32SXin Li depmode Dependency tracking mode. 43*a376eb32SXin Li source Source file read by `PROGRAMS ARGS'. 44*a376eb32SXin Li object Object file output by `PROGRAMS ARGS'. 45*a376eb32SXin Li DEPDIR directory where to store dependencies. 46*a376eb32SXin Li depfile Dependency file to output. 47*a376eb32SXin Li tmpdepfile Temporary file to use when outputing dependencies. 48*a376eb32SXin Li libtool Whether libtool is used (yes/no). 49*a376eb32SXin Li 50*a376eb32SXin LiReport bugs to <bug-automake@gnu.org>. 51*a376eb32SXin LiEOF 52*a376eb32SXin Li exit $? 53*a376eb32SXin Li ;; 54*a376eb32SXin Li -v | --v*) 55*a376eb32SXin Li echo "depcomp $scriptversion" 56*a376eb32SXin Li exit $? 57*a376eb32SXin Li ;; 58*a376eb32SXin Liesac 59*a376eb32SXin Li 60*a376eb32SXin Liif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61*a376eb32SXin Li echo "depcomp: Variables source, object and depmode must be set" 1>&2 62*a376eb32SXin Li exit 1 63*a376eb32SXin Lifi 64*a376eb32SXin Li 65*a376eb32SXin Li# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66*a376eb32SXin Lidepfile=${depfile-`echo "$object" | 67*a376eb32SXin Li sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68*a376eb32SXin Litmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69*a376eb32SXin Li 70*a376eb32SXin Lirm -f "$tmpdepfile" 71*a376eb32SXin Li 72*a376eb32SXin Li# Some modes work just like other modes, but use different flags. We 73*a376eb32SXin Li# parameterize here, but still list the modes in the big case below, 74*a376eb32SXin Li# to make depend.m4 easier to write. Note that we *cannot* use a case 75*a376eb32SXin Li# here, because this file can only contain one case statement. 76*a376eb32SXin Liif test "$depmode" = hp; then 77*a376eb32SXin Li # HP compiler uses -M and no extra arg. 78*a376eb32SXin Li gccflag=-M 79*a376eb32SXin Li depmode=gcc 80*a376eb32SXin Lifi 81*a376eb32SXin Li 82*a376eb32SXin Liif test "$depmode" = dashXmstdout; then 83*a376eb32SXin Li # This is just like dashmstdout with a different argument. 84*a376eb32SXin Li dashmflag=-xM 85*a376eb32SXin Li depmode=dashmstdout 86*a376eb32SXin Lifi 87*a376eb32SXin Li 88*a376eb32SXin Licygpath_u="cygpath -u -f -" 89*a376eb32SXin Liif test "$depmode" = msvcmsys; then 90*a376eb32SXin Li # This is just like msvisualcpp but w/o cygpath translation. 91*a376eb32SXin Li # Just convert the backslash-escaped backslashes to single forward 92*a376eb32SXin Li # slashes to satisfy depend.m4 93*a376eb32SXin Li cygpath_u="sed s,\\\\\\\\,/,g" 94*a376eb32SXin Li depmode=msvisualcpp 95*a376eb32SXin Lifi 96*a376eb32SXin Li 97*a376eb32SXin Licase "$depmode" in 98*a376eb32SXin Ligcc3) 99*a376eb32SXin Li## gcc 3 implements dependency tracking that does exactly what 100*a376eb32SXin Li## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101*a376eb32SXin Li## it if -MD -MP comes after the -MF stuff. Hmm. 102*a376eb32SXin Li## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103*a376eb32SXin Li## the command line argument order; so add the flags where they 104*a376eb32SXin Li## appear in depend2.am. Note that the slowdown incurred here 105*a376eb32SXin Li## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106*a376eb32SXin Li for arg 107*a376eb32SXin Li do 108*a376eb32SXin Li case $arg in 109*a376eb32SXin Li -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110*a376eb32SXin Li *) set fnord "$@" "$arg" ;; 111*a376eb32SXin Li esac 112*a376eb32SXin Li shift # fnord 113*a376eb32SXin Li shift # $arg 114*a376eb32SXin Li done 115*a376eb32SXin Li "$@" 116*a376eb32SXin Li stat=$? 117*a376eb32SXin Li if test $stat -eq 0; then : 118*a376eb32SXin Li else 119*a376eb32SXin Li rm -f "$tmpdepfile" 120*a376eb32SXin Li exit $stat 121*a376eb32SXin Li fi 122*a376eb32SXin Li mv "$tmpdepfile" "$depfile" 123*a376eb32SXin Li ;; 124*a376eb32SXin Li 125*a376eb32SXin Ligcc) 126*a376eb32SXin Li## There are various ways to get dependency output from gcc. Here's 127*a376eb32SXin Li## why we pick this rather obscure method: 128*a376eb32SXin Li## - Don't want to use -MD because we'd like the dependencies to end 129*a376eb32SXin Li## up in a subdir. Having to rename by hand is ugly. 130*a376eb32SXin Li## (We might end up doing this anyway to support other compilers.) 131*a376eb32SXin Li## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132*a376eb32SXin Li## -MM, not -M (despite what the docs say). 133*a376eb32SXin Li## - Using -M directly means running the compiler twice (even worse 134*a376eb32SXin Li## than renaming). 135*a376eb32SXin Li if test -z "$gccflag"; then 136*a376eb32SXin Li gccflag=-MD, 137*a376eb32SXin Li fi 138*a376eb32SXin Li "$@" -Wp,"$gccflag$tmpdepfile" 139*a376eb32SXin Li stat=$? 140*a376eb32SXin Li if test $stat -eq 0; then : 141*a376eb32SXin Li else 142*a376eb32SXin Li rm -f "$tmpdepfile" 143*a376eb32SXin Li exit $stat 144*a376eb32SXin Li fi 145*a376eb32SXin Li rm -f "$depfile" 146*a376eb32SXin Li echo "$object : \\" > "$depfile" 147*a376eb32SXin Li alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148*a376eb32SXin Li## The second -e expression handles DOS-style file names with drive letters. 149*a376eb32SXin Li sed -e 's/^[^:]*: / /' \ 150*a376eb32SXin Li -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151*a376eb32SXin Li## This next piece of magic avoids the `deleted header file' problem. 152*a376eb32SXin Li## The problem is that when a header file which appears in a .P file 153*a376eb32SXin Li## is deleted, the dependency causes make to die (because there is 154*a376eb32SXin Li## typically no way to rebuild the header). We avoid this by adding 155*a376eb32SXin Li## dummy dependencies for each header file. Too bad gcc doesn't do 156*a376eb32SXin Li## this for us directly. 157*a376eb32SXin Li tr ' ' ' 158*a376eb32SXin Li' < "$tmpdepfile" | 159*a376eb32SXin Li## Some versions of gcc put a space before the `:'. On the theory 160*a376eb32SXin Li## that the space means something, we add a space to the output as 161*a376eb32SXin Li## well. 162*a376eb32SXin Li## Some versions of the HPUX 10.20 sed can't process this invocation 163*a376eb32SXin Li## correctly. Breaking it into two sed invocations is a workaround. 164*a376eb32SXin Li sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165*a376eb32SXin Li rm -f "$tmpdepfile" 166*a376eb32SXin Li ;; 167*a376eb32SXin Li 168*a376eb32SXin Lihp) 169*a376eb32SXin Li # This case exists only to let depend.m4 do its work. It works by 170*a376eb32SXin Li # looking at the text of this script. This case will never be run, 171*a376eb32SXin Li # since it is checked for above. 172*a376eb32SXin Li exit 1 173*a376eb32SXin Li ;; 174*a376eb32SXin Li 175*a376eb32SXin Lisgi) 176*a376eb32SXin Li if test "$libtool" = yes; then 177*a376eb32SXin Li "$@" "-Wp,-MDupdate,$tmpdepfile" 178*a376eb32SXin Li else 179*a376eb32SXin Li "$@" -MDupdate "$tmpdepfile" 180*a376eb32SXin Li fi 181*a376eb32SXin Li stat=$? 182*a376eb32SXin Li if test $stat -eq 0; then : 183*a376eb32SXin Li else 184*a376eb32SXin Li rm -f "$tmpdepfile" 185*a376eb32SXin Li exit $stat 186*a376eb32SXin Li fi 187*a376eb32SXin Li rm -f "$depfile" 188*a376eb32SXin Li 189*a376eb32SXin Li if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190*a376eb32SXin Li echo "$object : \\" > "$depfile" 191*a376eb32SXin Li 192*a376eb32SXin Li # Clip off the initial element (the dependent). Don't try to be 193*a376eb32SXin Li # clever and replace this with sed code, as IRIX sed won't handle 194*a376eb32SXin Li # lines with more than a fixed number of characters (4096 in 195*a376eb32SXin Li # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196*a376eb32SXin Li # the IRIX cc adds comments like `#:fec' to the end of the 197*a376eb32SXin Li # dependency line. 198*a376eb32SXin Li tr ' ' ' 199*a376eb32SXin Li' < "$tmpdepfile" \ 200*a376eb32SXin Li | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201*a376eb32SXin Li tr ' 202*a376eb32SXin Li' ' ' >> "$depfile" 203*a376eb32SXin Li echo >> "$depfile" 204*a376eb32SXin Li 205*a376eb32SXin Li # The second pass generates a dummy entry for each header file. 206*a376eb32SXin Li tr ' ' ' 207*a376eb32SXin Li' < "$tmpdepfile" \ 208*a376eb32SXin Li | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209*a376eb32SXin Li >> "$depfile" 210*a376eb32SXin Li else 211*a376eb32SXin Li # The sourcefile does not contain any dependencies, so just 212*a376eb32SXin Li # store a dummy comment line, to avoid errors with the Makefile 213*a376eb32SXin Li # "include basename.Plo" scheme. 214*a376eb32SXin Li echo "#dummy" > "$depfile" 215*a376eb32SXin Li fi 216*a376eb32SXin Li rm -f "$tmpdepfile" 217*a376eb32SXin Li ;; 218*a376eb32SXin Li 219*a376eb32SXin Liaix) 220*a376eb32SXin Li # The C for AIX Compiler uses -M and outputs the dependencies 221*a376eb32SXin Li # in a .u file. In older versions, this file always lives in the 222*a376eb32SXin Li # current directory. Also, the AIX compiler puts `$object:' at the 223*a376eb32SXin Li # start of each line; $object doesn't have directory information. 224*a376eb32SXin Li # Version 6 uses the directory in both cases. 225*a376eb32SXin Li dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226*a376eb32SXin Li test "x$dir" = "x$object" && dir= 227*a376eb32SXin Li base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228*a376eb32SXin Li if test "$libtool" = yes; then 229*a376eb32SXin Li tmpdepfile1=$dir$base.u 230*a376eb32SXin Li tmpdepfile2=$base.u 231*a376eb32SXin Li tmpdepfile3=$dir.libs/$base.u 232*a376eb32SXin Li "$@" -Wc,-M 233*a376eb32SXin Li else 234*a376eb32SXin Li tmpdepfile1=$dir$base.u 235*a376eb32SXin Li tmpdepfile2=$dir$base.u 236*a376eb32SXin Li tmpdepfile3=$dir$base.u 237*a376eb32SXin Li "$@" -M 238*a376eb32SXin Li fi 239*a376eb32SXin Li stat=$? 240*a376eb32SXin Li 241*a376eb32SXin Li if test $stat -eq 0; then : 242*a376eb32SXin Li else 243*a376eb32SXin Li rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244*a376eb32SXin Li exit $stat 245*a376eb32SXin Li fi 246*a376eb32SXin Li 247*a376eb32SXin Li for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248*a376eb32SXin Li do 249*a376eb32SXin Li test -f "$tmpdepfile" && break 250*a376eb32SXin Li done 251*a376eb32SXin Li if test -f "$tmpdepfile"; then 252*a376eb32SXin Li # Each line is of the form `foo.o: dependent.h'. 253*a376eb32SXin Li # Do two passes, one to just change these to 254*a376eb32SXin Li # `$object: dependent.h' and one to simply `dependent.h:'. 255*a376eb32SXin Li sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256*a376eb32SXin Li # That's a tab and a space in the []. 257*a376eb32SXin Li sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258*a376eb32SXin Li else 259*a376eb32SXin Li # The sourcefile does not contain any dependencies, so just 260*a376eb32SXin Li # store a dummy comment line, to avoid errors with the Makefile 261*a376eb32SXin Li # "include basename.Plo" scheme. 262*a376eb32SXin Li echo "#dummy" > "$depfile" 263*a376eb32SXin Li fi 264*a376eb32SXin Li rm -f "$tmpdepfile" 265*a376eb32SXin Li ;; 266*a376eb32SXin Li 267*a376eb32SXin Liicc) 268*a376eb32SXin Li # Intel's C compiler understands `-MD -MF file'. However on 269*a376eb32SXin Li # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270*a376eb32SXin Li # ICC 7.0 will fill foo.d with something like 271*a376eb32SXin Li # foo.o: sub/foo.c 272*a376eb32SXin Li # foo.o: sub/foo.h 273*a376eb32SXin Li # which is wrong. We want: 274*a376eb32SXin Li # sub/foo.o: sub/foo.c 275*a376eb32SXin Li # sub/foo.o: sub/foo.h 276*a376eb32SXin Li # sub/foo.c: 277*a376eb32SXin Li # sub/foo.h: 278*a376eb32SXin Li # ICC 7.1 will output 279*a376eb32SXin Li # foo.o: sub/foo.c sub/foo.h 280*a376eb32SXin Li # and will wrap long lines using \ : 281*a376eb32SXin Li # foo.o: sub/foo.c ... \ 282*a376eb32SXin Li # sub/foo.h ... \ 283*a376eb32SXin Li # ... 284*a376eb32SXin Li 285*a376eb32SXin Li "$@" -MD -MF "$tmpdepfile" 286*a376eb32SXin Li stat=$? 287*a376eb32SXin Li if test $stat -eq 0; then : 288*a376eb32SXin Li else 289*a376eb32SXin Li rm -f "$tmpdepfile" 290*a376eb32SXin Li exit $stat 291*a376eb32SXin Li fi 292*a376eb32SXin Li rm -f "$depfile" 293*a376eb32SXin Li # Each line is of the form `foo.o: dependent.h', 294*a376eb32SXin Li # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295*a376eb32SXin Li # Do two passes, one to just change these to 296*a376eb32SXin Li # `$object: dependent.h' and one to simply `dependent.h:'. 297*a376eb32SXin Li sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298*a376eb32SXin Li # Some versions of the HPUX 10.20 sed can't process this invocation 299*a376eb32SXin Li # correctly. Breaking it into two sed invocations is a workaround. 300*a376eb32SXin Li sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301*a376eb32SXin Li sed -e 's/$/ :/' >> "$depfile" 302*a376eb32SXin Li rm -f "$tmpdepfile" 303*a376eb32SXin Li ;; 304*a376eb32SXin Li 305*a376eb32SXin Lihp2) 306*a376eb32SXin Li # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307*a376eb32SXin Li # compilers, which have integrated preprocessors. The correct option 308*a376eb32SXin Li # to use with these is +Maked; it writes dependencies to a file named 309*a376eb32SXin Li # 'foo.d', which lands next to the object file, wherever that 310*a376eb32SXin Li # happens to be. 311*a376eb32SXin Li # Much of this is similar to the tru64 case; see comments there. 312*a376eb32SXin Li dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313*a376eb32SXin Li test "x$dir" = "x$object" && dir= 314*a376eb32SXin Li base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315*a376eb32SXin Li if test "$libtool" = yes; then 316*a376eb32SXin Li tmpdepfile1=$dir$base.d 317*a376eb32SXin Li tmpdepfile2=$dir.libs/$base.d 318*a376eb32SXin Li "$@" -Wc,+Maked 319*a376eb32SXin Li else 320*a376eb32SXin Li tmpdepfile1=$dir$base.d 321*a376eb32SXin Li tmpdepfile2=$dir$base.d 322*a376eb32SXin Li "$@" +Maked 323*a376eb32SXin Li fi 324*a376eb32SXin Li stat=$? 325*a376eb32SXin Li if test $stat -eq 0; then : 326*a376eb32SXin Li else 327*a376eb32SXin Li rm -f "$tmpdepfile1" "$tmpdepfile2" 328*a376eb32SXin Li exit $stat 329*a376eb32SXin Li fi 330*a376eb32SXin Li 331*a376eb32SXin Li for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332*a376eb32SXin Li do 333*a376eb32SXin Li test -f "$tmpdepfile" && break 334*a376eb32SXin Li done 335*a376eb32SXin Li if test -f "$tmpdepfile"; then 336*a376eb32SXin Li sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337*a376eb32SXin Li # Add `dependent.h:' lines. 338*a376eb32SXin Li sed -ne '2,${ 339*a376eb32SXin Li s/^ *// 340*a376eb32SXin Li s/ \\*$// 341*a376eb32SXin Li s/$/:/ 342*a376eb32SXin Li p 343*a376eb32SXin Li }' "$tmpdepfile" >> "$depfile" 344*a376eb32SXin Li else 345*a376eb32SXin Li echo "#dummy" > "$depfile" 346*a376eb32SXin Li fi 347*a376eb32SXin Li rm -f "$tmpdepfile" "$tmpdepfile2" 348*a376eb32SXin Li ;; 349*a376eb32SXin Li 350*a376eb32SXin Litru64) 351*a376eb32SXin Li # The Tru64 compiler uses -MD to generate dependencies as a side 352*a376eb32SXin Li # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353*a376eb32SXin Li # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354*a376eb32SXin Li # dependencies in `foo.d' instead, so we check for that too. 355*a376eb32SXin Li # Subdirectories are respected. 356*a376eb32SXin Li dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357*a376eb32SXin Li test "x$dir" = "x$object" && dir= 358*a376eb32SXin Li base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359*a376eb32SXin Li 360*a376eb32SXin Li if test "$libtool" = yes; then 361*a376eb32SXin Li # With Tru64 cc, shared objects can also be used to make a 362*a376eb32SXin Li # static library. This mechanism is used in libtool 1.4 series to 363*a376eb32SXin Li # handle both shared and static libraries in a single compilation. 364*a376eb32SXin Li # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365*a376eb32SXin Li # 366*a376eb32SXin Li # With libtool 1.5 this exception was removed, and libtool now 367*a376eb32SXin Li # generates 2 separate objects for the 2 libraries. These two 368*a376eb32SXin Li # compilations output dependencies in $dir.libs/$base.o.d and 369*a376eb32SXin Li # in $dir$base.o.d. We have to check for both files, because 370*a376eb32SXin Li # one of the two compilations can be disabled. We should prefer 371*a376eb32SXin Li # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372*a376eb32SXin Li # automatically cleaned when .libs/ is deleted, while ignoring 373*a376eb32SXin Li # the former would cause a distcleancheck panic. 374*a376eb32SXin Li tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375*a376eb32SXin Li tmpdepfile2=$dir$base.o.d # libtool 1.5 376*a376eb32SXin Li tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377*a376eb32SXin Li tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378*a376eb32SXin Li "$@" -Wc,-MD 379*a376eb32SXin Li else 380*a376eb32SXin Li tmpdepfile1=$dir$base.o.d 381*a376eb32SXin Li tmpdepfile2=$dir$base.d 382*a376eb32SXin Li tmpdepfile3=$dir$base.d 383*a376eb32SXin Li tmpdepfile4=$dir$base.d 384*a376eb32SXin Li "$@" -MD 385*a376eb32SXin Li fi 386*a376eb32SXin Li 387*a376eb32SXin Li stat=$? 388*a376eb32SXin Li if test $stat -eq 0; then : 389*a376eb32SXin Li else 390*a376eb32SXin Li rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391*a376eb32SXin Li exit $stat 392*a376eb32SXin Li fi 393*a376eb32SXin Li 394*a376eb32SXin Li for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395*a376eb32SXin Li do 396*a376eb32SXin Li test -f "$tmpdepfile" && break 397*a376eb32SXin Li done 398*a376eb32SXin Li if test -f "$tmpdepfile"; then 399*a376eb32SXin Li sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400*a376eb32SXin Li # That's a tab and a space in the []. 401*a376eb32SXin Li sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402*a376eb32SXin Li else 403*a376eb32SXin Li echo "#dummy" > "$depfile" 404*a376eb32SXin Li fi 405*a376eb32SXin Li rm -f "$tmpdepfile" 406*a376eb32SXin Li ;; 407*a376eb32SXin Li 408*a376eb32SXin Li#nosideeffect) 409*a376eb32SXin Li # This comment above is used by automake to tell side-effect 410*a376eb32SXin Li # dependency tracking mechanisms from slower ones. 411*a376eb32SXin Li 412*a376eb32SXin Lidashmstdout) 413*a376eb32SXin Li # Important note: in order to support this mode, a compiler *must* 414*a376eb32SXin Li # always write the preprocessed file to stdout, regardless of -o. 415*a376eb32SXin Li "$@" || exit $? 416*a376eb32SXin Li 417*a376eb32SXin Li # Remove the call to Libtool. 418*a376eb32SXin Li if test "$libtool" = yes; then 419*a376eb32SXin Li while test "X$1" != 'X--mode=compile'; do 420*a376eb32SXin Li shift 421*a376eb32SXin Li done 422*a376eb32SXin Li shift 423*a376eb32SXin Li fi 424*a376eb32SXin Li 425*a376eb32SXin Li # Remove `-o $object'. 426*a376eb32SXin Li IFS=" " 427*a376eb32SXin Li for arg 428*a376eb32SXin Li do 429*a376eb32SXin Li case $arg in 430*a376eb32SXin Li -o) 431*a376eb32SXin Li shift 432*a376eb32SXin Li ;; 433*a376eb32SXin Li $object) 434*a376eb32SXin Li shift 435*a376eb32SXin Li ;; 436*a376eb32SXin Li *) 437*a376eb32SXin Li set fnord "$@" "$arg" 438*a376eb32SXin Li shift # fnord 439*a376eb32SXin Li shift # $arg 440*a376eb32SXin Li ;; 441*a376eb32SXin Li esac 442*a376eb32SXin Li done 443*a376eb32SXin Li 444*a376eb32SXin Li test -z "$dashmflag" && dashmflag=-M 445*a376eb32SXin Li # Require at least two characters before searching for `:' 446*a376eb32SXin Li # in the target name. This is to cope with DOS-style filenames: 447*a376eb32SXin Li # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448*a376eb32SXin Li "$@" $dashmflag | 449*a376eb32SXin Li sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450*a376eb32SXin Li rm -f "$depfile" 451*a376eb32SXin Li cat < "$tmpdepfile" > "$depfile" 452*a376eb32SXin Li tr ' ' ' 453*a376eb32SXin Li' < "$tmpdepfile" | \ 454*a376eb32SXin Li## Some versions of the HPUX 10.20 sed can't process this invocation 455*a376eb32SXin Li## correctly. Breaking it into two sed invocations is a workaround. 456*a376eb32SXin Li sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457*a376eb32SXin Li rm -f "$tmpdepfile" 458*a376eb32SXin Li ;; 459*a376eb32SXin Li 460*a376eb32SXin LidashXmstdout) 461*a376eb32SXin Li # This case only exists to satisfy depend.m4. It is never actually 462*a376eb32SXin Li # run, as this mode is specially recognized in the preamble. 463*a376eb32SXin Li exit 1 464*a376eb32SXin Li ;; 465*a376eb32SXin Li 466*a376eb32SXin Limakedepend) 467*a376eb32SXin Li "$@" || exit $? 468*a376eb32SXin Li # Remove any Libtool call 469*a376eb32SXin Li if test "$libtool" = yes; then 470*a376eb32SXin Li while test "X$1" != 'X--mode=compile'; do 471*a376eb32SXin Li shift 472*a376eb32SXin Li done 473*a376eb32SXin Li shift 474*a376eb32SXin Li fi 475*a376eb32SXin Li # X makedepend 476*a376eb32SXin Li shift 477*a376eb32SXin Li cleared=no eat=no 478*a376eb32SXin Li for arg 479*a376eb32SXin Li do 480*a376eb32SXin Li case $cleared in 481*a376eb32SXin Li no) 482*a376eb32SXin Li set ""; shift 483*a376eb32SXin Li cleared=yes ;; 484*a376eb32SXin Li esac 485*a376eb32SXin Li if test $eat = yes; then 486*a376eb32SXin Li eat=no 487*a376eb32SXin Li continue 488*a376eb32SXin Li fi 489*a376eb32SXin Li case "$arg" in 490*a376eb32SXin Li -D*|-I*) 491*a376eb32SXin Li set fnord "$@" "$arg"; shift ;; 492*a376eb32SXin Li # Strip any option that makedepend may not understand. Remove 493*a376eb32SXin Li # the object too, otherwise makedepend will parse it as a source file. 494*a376eb32SXin Li -arch) 495*a376eb32SXin Li eat=yes ;; 496*a376eb32SXin Li -*|$object) 497*a376eb32SXin Li ;; 498*a376eb32SXin Li *) 499*a376eb32SXin Li set fnord "$@" "$arg"; shift ;; 500*a376eb32SXin Li esac 501*a376eb32SXin Li done 502*a376eb32SXin Li obj_suffix=`echo "$object" | sed 's/^.*\././'` 503*a376eb32SXin Li touch "$tmpdepfile" 504*a376eb32SXin Li ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505*a376eb32SXin Li rm -f "$depfile" 506*a376eb32SXin Li cat < "$tmpdepfile" > "$depfile" 507*a376eb32SXin Li sed '1,2d' "$tmpdepfile" | tr ' ' ' 508*a376eb32SXin Li' | \ 509*a376eb32SXin Li## Some versions of the HPUX 10.20 sed can't process this invocation 510*a376eb32SXin Li## correctly. Breaking it into two sed invocations is a workaround. 511*a376eb32SXin Li sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512*a376eb32SXin Li rm -f "$tmpdepfile" "$tmpdepfile".bak 513*a376eb32SXin Li ;; 514*a376eb32SXin Li 515*a376eb32SXin Licpp) 516*a376eb32SXin Li # Important note: in order to support this mode, a compiler *must* 517*a376eb32SXin Li # always write the preprocessed file to stdout. 518*a376eb32SXin Li "$@" || exit $? 519*a376eb32SXin Li 520*a376eb32SXin Li # Remove the call to Libtool. 521*a376eb32SXin Li if test "$libtool" = yes; then 522*a376eb32SXin Li while test "X$1" != 'X--mode=compile'; do 523*a376eb32SXin Li shift 524*a376eb32SXin Li done 525*a376eb32SXin Li shift 526*a376eb32SXin Li fi 527*a376eb32SXin Li 528*a376eb32SXin Li # Remove `-o $object'. 529*a376eb32SXin Li IFS=" " 530*a376eb32SXin Li for arg 531*a376eb32SXin Li do 532*a376eb32SXin Li case $arg in 533*a376eb32SXin Li -o) 534*a376eb32SXin Li shift 535*a376eb32SXin Li ;; 536*a376eb32SXin Li $object) 537*a376eb32SXin Li shift 538*a376eb32SXin Li ;; 539*a376eb32SXin Li *) 540*a376eb32SXin Li set fnord "$@" "$arg" 541*a376eb32SXin Li shift # fnord 542*a376eb32SXin Li shift # $arg 543*a376eb32SXin Li ;; 544*a376eb32SXin Li esac 545*a376eb32SXin Li done 546*a376eb32SXin Li 547*a376eb32SXin Li "$@" -E | 548*a376eb32SXin Li sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549*a376eb32SXin Li -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550*a376eb32SXin Li sed '$ s: \\$::' > "$tmpdepfile" 551*a376eb32SXin Li rm -f "$depfile" 552*a376eb32SXin Li echo "$object : \\" > "$depfile" 553*a376eb32SXin Li cat < "$tmpdepfile" >> "$depfile" 554*a376eb32SXin Li sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555*a376eb32SXin Li rm -f "$tmpdepfile" 556*a376eb32SXin Li ;; 557*a376eb32SXin Li 558*a376eb32SXin Limsvisualcpp) 559*a376eb32SXin Li # Important note: in order to support this mode, a compiler *must* 560*a376eb32SXin Li # always write the preprocessed file to stdout. 561*a376eb32SXin Li "$@" || exit $? 562*a376eb32SXin Li 563*a376eb32SXin Li # Remove the call to Libtool. 564*a376eb32SXin Li if test "$libtool" = yes; then 565*a376eb32SXin Li while test "X$1" != 'X--mode=compile'; do 566*a376eb32SXin Li shift 567*a376eb32SXin Li done 568*a376eb32SXin Li shift 569*a376eb32SXin Li fi 570*a376eb32SXin Li 571*a376eb32SXin Li IFS=" " 572*a376eb32SXin Li for arg 573*a376eb32SXin Li do 574*a376eb32SXin Li case "$arg" in 575*a376eb32SXin Li -o) 576*a376eb32SXin Li shift 577*a376eb32SXin Li ;; 578*a376eb32SXin Li $object) 579*a376eb32SXin Li shift 580*a376eb32SXin Li ;; 581*a376eb32SXin Li "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582*a376eb32SXin Li set fnord "$@" 583*a376eb32SXin Li shift 584*a376eb32SXin Li shift 585*a376eb32SXin Li ;; 586*a376eb32SXin Li *) 587*a376eb32SXin Li set fnord "$@" "$arg" 588*a376eb32SXin Li shift 589*a376eb32SXin Li shift 590*a376eb32SXin Li ;; 591*a376eb32SXin Li esac 592*a376eb32SXin Li done 593*a376eb32SXin Li "$@" -E 2>/dev/null | 594*a376eb32SXin Li sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595*a376eb32SXin Li rm -f "$depfile" 596*a376eb32SXin Li echo "$object : \\" > "$depfile" 597*a376eb32SXin Li sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598*a376eb32SXin Li echo " " >> "$depfile" 599*a376eb32SXin Li sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600*a376eb32SXin Li rm -f "$tmpdepfile" 601*a376eb32SXin Li ;; 602*a376eb32SXin Li 603*a376eb32SXin Limsvcmsys) 604*a376eb32SXin Li # This case exists only to let depend.m4 do its work. It works by 605*a376eb32SXin Li # looking at the text of this script. This case will never be run, 606*a376eb32SXin Li # since it is checked for above. 607*a376eb32SXin Li exit 1 608*a376eb32SXin Li ;; 609*a376eb32SXin Li 610*a376eb32SXin Linone) 611*a376eb32SXin Li exec "$@" 612*a376eb32SXin Li ;; 613*a376eb32SXin Li 614*a376eb32SXin Li*) 615*a376eb32SXin Li echo "Unknown depmode $depmode" 1>&2 616*a376eb32SXin Li exit 1 617*a376eb32SXin Li ;; 618*a376eb32SXin Liesac 619*a376eb32SXin Li 620*a376eb32SXin Liexit 0 621*a376eb32SXin Li 622*a376eb32SXin Li# Local Variables: 623*a376eb32SXin Li# mode: shell-script 624*a376eb32SXin Li# sh-indentation: 2 625*a376eb32SXin Li# eval: (add-hook 'write-file-hooks 'time-stamp) 626*a376eb32SXin Li# time-stamp-start: "scriptversion=" 627*a376eb32SXin Li# time-stamp-format: "%:y-%02m-%02d.%02H" 628*a376eb32SXin Li# time-stamp-time-zone: "UTC" 629*a376eb32SXin Li# time-stamp-end: "; # UTC" 630*a376eb32SXin Li# End: 631