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