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