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