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