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