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