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