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