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