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