depcomp revision 70f7c90c
1a850946eSmrg#! /bin/sh 2a850946eSmrg# depcomp - compile a program generating dependencies as side-effects 370f7c90cSmrg 470f7c90cSmrgscriptversion=2009-04-28.21; # UTC 570f7c90cSmrg 670f7c90cSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 770f7c90cSmrg# Software Foundation, Inc. 8a850946eSmrg 9a850946eSmrg# This program is free software; you can redistribute it and/or modify 10a850946eSmrg# it under the terms of the GNU General Public License as published by 11a850946eSmrg# the Free Software Foundation; either version 2, or (at your option) 12a850946eSmrg# any later version. 13a850946eSmrg 14a850946eSmrg# This program is distributed in the hope that it will be useful, 15a850946eSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16a850946eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17a850946eSmrg# GNU General Public License for more details. 18a850946eSmrg 19a850946eSmrg# You should have received a copy of the GNU General Public License 2070f7c90cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21a850946eSmrg 22a850946eSmrg# As a special exception to the GNU General Public License, if you 23a850946eSmrg# distribute this file as part of a program that contains a 24a850946eSmrg# configuration script generated by Autoconf, you may include it under 25a850946eSmrg# the same distribution terms that you use for the rest of that program. 26a850946eSmrg 27a850946eSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28a850946eSmrg 2970f7c90cSmrgcase $1 in 3070f7c90cSmrg '') 3170f7c90cSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3270f7c90cSmrg exit 1; 3370f7c90cSmrg ;; 3470f7c90cSmrg -h | --h*) 3570f7c90cSmrg cat <<\EOF 3670f7c90cSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3770f7c90cSmrg 3870f7c90cSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3970f7c90cSmrgas side-effects. 4070f7c90cSmrg 4170f7c90cSmrgEnvironment variables: 4270f7c90cSmrg depmode Dependency tracking mode. 4370f7c90cSmrg source Source file read by `PROGRAMS ARGS'. 4470f7c90cSmrg object Object file output by `PROGRAMS ARGS'. 4570f7c90cSmrg DEPDIR directory where to store dependencies. 4670f7c90cSmrg depfile Dependency file to output. 4770f7c90cSmrg tmpdepfile Temporary file to use when outputing dependencies. 4870f7c90cSmrg libtool Whether libtool is used (yes/no). 4970f7c90cSmrg 5070f7c90cSmrgReport bugs to <bug-automake@gnu.org>. 5170f7c90cSmrgEOF 5270f7c90cSmrg exit $? 5370f7c90cSmrg ;; 5470f7c90cSmrg -v | --v*) 5570f7c90cSmrg echo "depcomp $scriptversion" 5670f7c90cSmrg exit $? 5770f7c90cSmrg ;; 5870f7c90cSmrgesac 5970f7c90cSmrg 60a850946eSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61a850946eSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62a850946eSmrg exit 1 63a850946eSmrgfi 64a850946eSmrg 6570f7c90cSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6670f7c90cSmrgdepfile=${depfile-`echo "$object" | 6770f7c90cSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68a850946eSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69a850946eSmrg 70a850946eSmrgrm -f "$tmpdepfile" 71a850946eSmrg 72a850946eSmrg# Some modes work just like other modes, but use different flags. We 73a850946eSmrg# parameterize here, but still list the modes in the big case below, 74a850946eSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75a850946eSmrg# here, because this file can only contain one case statement. 76a850946eSmrgif test "$depmode" = hp; then 77a850946eSmrg # HP compiler uses -M and no extra arg. 78a850946eSmrg gccflag=-M 79a850946eSmrg depmode=gcc 80a850946eSmrgfi 81a850946eSmrg 82a850946eSmrgif test "$depmode" = dashXmstdout; then 83a850946eSmrg # This is just like dashmstdout with a different argument. 84a850946eSmrg dashmflag=-xM 85a850946eSmrg depmode=dashmstdout 86a850946eSmrgfi 87a850946eSmrg 8870f7c90cSmrgcygpath_u="cygpath -u -f -" 8970f7c90cSmrgif test "$depmode" = msvcmsys; then 9070f7c90cSmrg # This is just like msvisualcpp but w/o cygpath translation. 9170f7c90cSmrg # Just convert the backslash-escaped backslashes to single forward 9270f7c90cSmrg # slashes to satisfy depend.m4 9370f7c90cSmrg cygpath_u="sed s,\\\\\\\\,/,g" 9470f7c90cSmrg depmode=msvisualcpp 9570f7c90cSmrgfi 9670f7c90cSmrg 97a850946eSmrgcase "$depmode" in 98a850946eSmrggcc3) 99a850946eSmrg## gcc 3 implements dependency tracking that does exactly what 100a850946eSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101a850946eSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 10270f7c90cSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 10370f7c90cSmrg## the command line argument order; so add the flags where they 10470f7c90cSmrg## appear in depend2.am. Note that the slowdown incurred here 10570f7c90cSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 10670f7c90cSmrg for arg 10770f7c90cSmrg do 10870f7c90cSmrg case $arg in 10970f7c90cSmrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 11070f7c90cSmrg *) set fnord "$@" "$arg" ;; 11170f7c90cSmrg esac 11270f7c90cSmrg shift # fnord 11370f7c90cSmrg shift # $arg 11470f7c90cSmrg done 11570f7c90cSmrg "$@" 116a850946eSmrg stat=$? 117a850946eSmrg if test $stat -eq 0; then : 118a850946eSmrg else 119a850946eSmrg rm -f "$tmpdepfile" 120a850946eSmrg exit $stat 121a850946eSmrg fi 122a850946eSmrg mv "$tmpdepfile" "$depfile" 123a850946eSmrg ;; 124a850946eSmrg 125a850946eSmrggcc) 126a850946eSmrg## There are various ways to get dependency output from gcc. Here's 127a850946eSmrg## why we pick this rather obscure method: 128a850946eSmrg## - Don't want to use -MD because we'd like the dependencies to end 129a850946eSmrg## up in a subdir. Having to rename by hand is ugly. 130a850946eSmrg## (We might end up doing this anyway to support other compilers.) 131a850946eSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132a850946eSmrg## -MM, not -M (despite what the docs say). 133a850946eSmrg## - Using -M directly means running the compiler twice (even worse 134a850946eSmrg## than renaming). 135a850946eSmrg if test -z "$gccflag"; then 136a850946eSmrg gccflag=-MD, 137a850946eSmrg fi 138a850946eSmrg "$@" -Wp,"$gccflag$tmpdepfile" 139a850946eSmrg stat=$? 140a850946eSmrg if test $stat -eq 0; then : 141a850946eSmrg else 142a850946eSmrg rm -f "$tmpdepfile" 143a850946eSmrg exit $stat 144a850946eSmrg fi 145a850946eSmrg rm -f "$depfile" 146a850946eSmrg echo "$object : \\" > "$depfile" 147a850946eSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148a850946eSmrg## The second -e expression handles DOS-style file names with drive letters. 149a850946eSmrg sed -e 's/^[^:]*: / /' \ 150a850946eSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151a850946eSmrg## This next piece of magic avoids the `deleted header file' problem. 152a850946eSmrg## The problem is that when a header file which appears in a .P file 153a850946eSmrg## is deleted, the dependency causes make to die (because there is 154a850946eSmrg## typically no way to rebuild the header). We avoid this by adding 155a850946eSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 156a850946eSmrg## this for us directly. 157a850946eSmrg tr ' ' ' 158a850946eSmrg' < "$tmpdepfile" | 159a850946eSmrg## Some versions of gcc put a space before the `:'. On the theory 160a850946eSmrg## that the space means something, we add a space to the output as 161a850946eSmrg## well. 162a850946eSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 163a850946eSmrg## correctly. Breaking it into two sed invocations is a workaround. 164a850946eSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165a850946eSmrg rm -f "$tmpdepfile" 166a850946eSmrg ;; 167a850946eSmrg 168a850946eSmrghp) 169a850946eSmrg # This case exists only to let depend.m4 do its work. It works by 170a850946eSmrg # looking at the text of this script. This case will never be run, 171a850946eSmrg # since it is checked for above. 172a850946eSmrg exit 1 173a850946eSmrg ;; 174a850946eSmrg 175a850946eSmrgsgi) 176a850946eSmrg if test "$libtool" = yes; then 177a850946eSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 178a850946eSmrg else 179a850946eSmrg "$@" -MDupdate "$tmpdepfile" 180a850946eSmrg fi 181a850946eSmrg stat=$? 182a850946eSmrg if test $stat -eq 0; then : 183a850946eSmrg else 184a850946eSmrg rm -f "$tmpdepfile" 185a850946eSmrg exit $stat 186a850946eSmrg fi 187a850946eSmrg rm -f "$depfile" 188a850946eSmrg 189a850946eSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190a850946eSmrg echo "$object : \\" > "$depfile" 191a850946eSmrg 192a850946eSmrg # Clip off the initial element (the dependent). Don't try to be 193a850946eSmrg # clever and replace this with sed code, as IRIX sed won't handle 194a850946eSmrg # lines with more than a fixed number of characters (4096 in 195a850946eSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196a850946eSmrg # the IRIX cc adds comments like `#:fec' to the end of the 197a850946eSmrg # dependency line. 198a850946eSmrg tr ' ' ' 199a850946eSmrg' < "$tmpdepfile" \ 200a850946eSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201a850946eSmrg tr ' 20270f7c90cSmrg' ' ' >> "$depfile" 20370f7c90cSmrg echo >> "$depfile" 204a850946eSmrg 205a850946eSmrg # The second pass generates a dummy entry for each header file. 206a850946eSmrg tr ' ' ' 207a850946eSmrg' < "$tmpdepfile" \ 208a850946eSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 20970f7c90cSmrg >> "$depfile" 210a850946eSmrg else 211a850946eSmrg # The sourcefile does not contain any dependencies, so just 212a850946eSmrg # store a dummy comment line, to avoid errors with the Makefile 213a850946eSmrg # "include basename.Plo" scheme. 214a850946eSmrg echo "#dummy" > "$depfile" 215a850946eSmrg fi 216a850946eSmrg rm -f "$tmpdepfile" 217a850946eSmrg ;; 218a850946eSmrg 219a850946eSmrgaix) 220a850946eSmrg # The C for AIX Compiler uses -M and outputs the dependencies 221a850946eSmrg # in a .u file. In older versions, this file always lives in the 222a850946eSmrg # current directory. Also, the AIX compiler puts `$object:' at the 223a850946eSmrg # start of each line; $object doesn't have directory information. 224a850946eSmrg # Version 6 uses the directory in both cases. 22570f7c90cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 22670f7c90cSmrg test "x$dir" = "x$object" && dir= 22770f7c90cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228a850946eSmrg if test "$libtool" = yes; then 22970f7c90cSmrg tmpdepfile1=$dir$base.u 23070f7c90cSmrg tmpdepfile2=$base.u 23170f7c90cSmrg tmpdepfile3=$dir.libs/$base.u 232a850946eSmrg "$@" -Wc,-M 233a850946eSmrg else 23470f7c90cSmrg tmpdepfile1=$dir$base.u 23570f7c90cSmrg tmpdepfile2=$dir$base.u 23670f7c90cSmrg tmpdepfile3=$dir$base.u 237a850946eSmrg "$@" -M 238a850946eSmrg fi 239a850946eSmrg stat=$? 240a850946eSmrg 241a850946eSmrg if test $stat -eq 0; then : 242a850946eSmrg else 24370f7c90cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244a850946eSmrg exit $stat 245a850946eSmrg fi 246a850946eSmrg 24770f7c90cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24870f7c90cSmrg do 24970f7c90cSmrg test -f "$tmpdepfile" && break 25070f7c90cSmrg done 251a850946eSmrg if test -f "$tmpdepfile"; then 252a850946eSmrg # Each line is of the form `foo.o: dependent.h'. 253a850946eSmrg # Do two passes, one to just change these to 254a850946eSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 25570f7c90cSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 25670f7c90cSmrg # That's a tab and a space in the []. 25770f7c90cSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258a850946eSmrg else 259a850946eSmrg # The sourcefile does not contain any dependencies, so just 260a850946eSmrg # store a dummy comment line, to avoid errors with the Makefile 261a850946eSmrg # "include basename.Plo" scheme. 262a850946eSmrg echo "#dummy" > "$depfile" 263a850946eSmrg fi 264a850946eSmrg rm -f "$tmpdepfile" 265a850946eSmrg ;; 266a850946eSmrg 267a850946eSmrgicc) 268a850946eSmrg # Intel's C compiler understands `-MD -MF file'. However on 269a850946eSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270a850946eSmrg # ICC 7.0 will fill foo.d with something like 271a850946eSmrg # foo.o: sub/foo.c 272a850946eSmrg # foo.o: sub/foo.h 273a850946eSmrg # which is wrong. We want: 274a850946eSmrg # sub/foo.o: sub/foo.c 275a850946eSmrg # sub/foo.o: sub/foo.h 276a850946eSmrg # sub/foo.c: 277a850946eSmrg # sub/foo.h: 278a850946eSmrg # ICC 7.1 will output 279a850946eSmrg # foo.o: sub/foo.c sub/foo.h 280a850946eSmrg # and will wrap long lines using \ : 281a850946eSmrg # foo.o: sub/foo.c ... \ 282a850946eSmrg # sub/foo.h ... \ 283a850946eSmrg # ... 284a850946eSmrg 285a850946eSmrg "$@" -MD -MF "$tmpdepfile" 286a850946eSmrg stat=$? 287a850946eSmrg if test $stat -eq 0; then : 288a850946eSmrg else 289a850946eSmrg rm -f "$tmpdepfile" 290a850946eSmrg exit $stat 291a850946eSmrg fi 292a850946eSmrg rm -f "$depfile" 293a850946eSmrg # Each line is of the form `foo.o: dependent.h', 294a850946eSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295a850946eSmrg # Do two passes, one to just change these to 296a850946eSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 297a850946eSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298a850946eSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 299a850946eSmrg # correctly. Breaking it into two sed invocations is a workaround. 300a850946eSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301a850946eSmrg sed -e 's/$/ :/' >> "$depfile" 302a850946eSmrg rm -f "$tmpdepfile" 303a850946eSmrg ;; 304a850946eSmrg 30570f7c90cSmrghp2) 30670f7c90cSmrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 30770f7c90cSmrg # compilers, which have integrated preprocessors. The correct option 30870f7c90cSmrg # to use with these is +Maked; it writes dependencies to a file named 30970f7c90cSmrg # 'foo.d', which lands next to the object file, wherever that 31070f7c90cSmrg # happens to be. 31170f7c90cSmrg # Much of this is similar to the tru64 case; see comments there. 31270f7c90cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 31370f7c90cSmrg test "x$dir" = "x$object" && dir= 31470f7c90cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 31570f7c90cSmrg if test "$libtool" = yes; then 31670f7c90cSmrg tmpdepfile1=$dir$base.d 31770f7c90cSmrg tmpdepfile2=$dir.libs/$base.d 31870f7c90cSmrg "$@" -Wc,+Maked 31970f7c90cSmrg else 32070f7c90cSmrg tmpdepfile1=$dir$base.d 32170f7c90cSmrg tmpdepfile2=$dir$base.d 32270f7c90cSmrg "$@" +Maked 32370f7c90cSmrg fi 32470f7c90cSmrg stat=$? 32570f7c90cSmrg if test $stat -eq 0; then : 32670f7c90cSmrg else 32770f7c90cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" 32870f7c90cSmrg exit $stat 32970f7c90cSmrg fi 33070f7c90cSmrg 33170f7c90cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 33270f7c90cSmrg do 33370f7c90cSmrg test -f "$tmpdepfile" && break 33470f7c90cSmrg done 33570f7c90cSmrg if test -f "$tmpdepfile"; then 33670f7c90cSmrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 33770f7c90cSmrg # Add `dependent.h:' lines. 33870f7c90cSmrg sed -ne '2,${ 33970f7c90cSmrg s/^ *// 34070f7c90cSmrg s/ \\*$// 34170f7c90cSmrg s/$/:/ 34270f7c90cSmrg p 34370f7c90cSmrg }' "$tmpdepfile" >> "$depfile" 34470f7c90cSmrg else 34570f7c90cSmrg echo "#dummy" > "$depfile" 34670f7c90cSmrg fi 34770f7c90cSmrg rm -f "$tmpdepfile" "$tmpdepfile2" 34870f7c90cSmrg ;; 34970f7c90cSmrg 350a850946eSmrgtru64) 351a850946eSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 352a850946eSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353a850946eSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354a850946eSmrg # dependencies in `foo.d' instead, so we check for that too. 355a850946eSmrg # Subdirectories are respected. 356a850946eSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357a850946eSmrg test "x$dir" = "x$object" && dir= 358a850946eSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359a850946eSmrg 360a850946eSmrg if test "$libtool" = yes; then 36170f7c90cSmrg # With Tru64 cc, shared objects can also be used to make a 36270f7c90cSmrg # static library. This mechanism is used in libtool 1.4 series to 36370f7c90cSmrg # handle both shared and static libraries in a single compilation. 36470f7c90cSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 36570f7c90cSmrg # 36670f7c90cSmrg # With libtool 1.5 this exception was removed, and libtool now 36770f7c90cSmrg # generates 2 separate objects for the 2 libraries. These two 36870f7c90cSmrg # compilations output dependencies in $dir.libs/$base.o.d and 36970f7c90cSmrg # in $dir$base.o.d. We have to check for both files, because 37070f7c90cSmrg # one of the two compilations can be disabled. We should prefer 37170f7c90cSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 37270f7c90cSmrg # automatically cleaned when .libs/ is deleted, while ignoring 37370f7c90cSmrg # the former would cause a distcleancheck panic. 37470f7c90cSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 37570f7c90cSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 37670f7c90cSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 37770f7c90cSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378a850946eSmrg "$@" -Wc,-MD 379a850946eSmrg else 38070f7c90cSmrg tmpdepfile1=$dir$base.o.d 38170f7c90cSmrg tmpdepfile2=$dir$base.d 38270f7c90cSmrg tmpdepfile3=$dir$base.d 38370f7c90cSmrg tmpdepfile4=$dir$base.d 384a850946eSmrg "$@" -MD 385a850946eSmrg fi 386a850946eSmrg 387a850946eSmrg stat=$? 388a850946eSmrg if test $stat -eq 0; then : 389a850946eSmrg else 39070f7c90cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391a850946eSmrg exit $stat 392a850946eSmrg fi 393a850946eSmrg 39470f7c90cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 39570f7c90cSmrg do 39670f7c90cSmrg test -f "$tmpdepfile" && break 39770f7c90cSmrg done 398a850946eSmrg if test -f "$tmpdepfile"; then 399a850946eSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400a850946eSmrg # That's a tab and a space in the []. 401a850946eSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402a850946eSmrg else 403a850946eSmrg echo "#dummy" > "$depfile" 404a850946eSmrg fi 405a850946eSmrg rm -f "$tmpdepfile" 406a850946eSmrg ;; 407a850946eSmrg 408a850946eSmrg#nosideeffect) 409a850946eSmrg # This comment above is used by automake to tell side-effect 410a850946eSmrg # dependency tracking mechanisms from slower ones. 411a850946eSmrg 412a850946eSmrgdashmstdout) 413a850946eSmrg # Important note: in order to support this mode, a compiler *must* 414a850946eSmrg # always write the preprocessed file to stdout, regardless of -o. 415a850946eSmrg "$@" || exit $? 416a850946eSmrg 417a850946eSmrg # Remove the call to Libtool. 418a850946eSmrg if test "$libtool" = yes; then 41970f7c90cSmrg while test "X$1" != 'X--mode=compile'; do 420a850946eSmrg shift 421a850946eSmrg done 422a850946eSmrg shift 423a850946eSmrg fi 424a850946eSmrg 425a850946eSmrg # Remove `-o $object'. 426a850946eSmrg IFS=" " 427a850946eSmrg for arg 428a850946eSmrg do 429a850946eSmrg case $arg in 430a850946eSmrg -o) 431a850946eSmrg shift 432a850946eSmrg ;; 433a850946eSmrg $object) 434a850946eSmrg shift 435a850946eSmrg ;; 436a850946eSmrg *) 437a850946eSmrg set fnord "$@" "$arg" 438a850946eSmrg shift # fnord 439a850946eSmrg shift # $arg 440a850946eSmrg ;; 441a850946eSmrg esac 442a850946eSmrg done 443a850946eSmrg 444a850946eSmrg test -z "$dashmflag" && dashmflag=-M 445a850946eSmrg # Require at least two characters before searching for `:' 446a850946eSmrg # in the target name. This is to cope with DOS-style filenames: 447a850946eSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448a850946eSmrg "$@" $dashmflag | 449a850946eSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450a850946eSmrg rm -f "$depfile" 451a850946eSmrg cat < "$tmpdepfile" > "$depfile" 452a850946eSmrg tr ' ' ' 453a850946eSmrg' < "$tmpdepfile" | \ 454a850946eSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 455a850946eSmrg## correctly. Breaking it into two sed invocations is a workaround. 456a850946eSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457a850946eSmrg rm -f "$tmpdepfile" 458a850946eSmrg ;; 459a850946eSmrg 460a850946eSmrgdashXmstdout) 461a850946eSmrg # This case only exists to satisfy depend.m4. It is never actually 462a850946eSmrg # run, as this mode is specially recognized in the preamble. 463a850946eSmrg exit 1 464a850946eSmrg ;; 465a850946eSmrg 466a850946eSmrgmakedepend) 467a850946eSmrg "$@" || exit $? 468a850946eSmrg # Remove any Libtool call 469a850946eSmrg if test "$libtool" = yes; then 47070f7c90cSmrg while test "X$1" != 'X--mode=compile'; do 471a850946eSmrg shift 472a850946eSmrg done 473a850946eSmrg shift 474a850946eSmrg fi 475a850946eSmrg # X makedepend 476a850946eSmrg shift 47770f7c90cSmrg cleared=no eat=no 47870f7c90cSmrg for arg 47970f7c90cSmrg do 480a850946eSmrg case $cleared in 481a850946eSmrg no) 482a850946eSmrg set ""; shift 483a850946eSmrg cleared=yes ;; 484a850946eSmrg esac 48570f7c90cSmrg if test $eat = yes; then 48670f7c90cSmrg eat=no 48770f7c90cSmrg continue 48870f7c90cSmrg fi 489a850946eSmrg case "$arg" in 490a850946eSmrg -D*|-I*) 491a850946eSmrg set fnord "$@" "$arg"; shift ;; 492a850946eSmrg # Strip any option that makedepend may not understand. Remove 493a850946eSmrg # the object too, otherwise makedepend will parse it as a source file. 49470f7c90cSmrg -arch) 49570f7c90cSmrg eat=yes ;; 496a850946eSmrg -*|$object) 497a850946eSmrg ;; 498a850946eSmrg *) 499a850946eSmrg set fnord "$@" "$arg"; shift ;; 500a850946eSmrg esac 501a850946eSmrg done 50270f7c90cSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 503a850946eSmrg touch "$tmpdepfile" 504a850946eSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505a850946eSmrg rm -f "$depfile" 506a850946eSmrg cat < "$tmpdepfile" > "$depfile" 507a850946eSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 508a850946eSmrg' | \ 509a850946eSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 510a850946eSmrg## correctly. Breaking it into two sed invocations is a workaround. 511a850946eSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512a850946eSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 513a850946eSmrg ;; 514a850946eSmrg 515a850946eSmrgcpp) 516a850946eSmrg # Important note: in order to support this mode, a compiler *must* 517a850946eSmrg # always write the preprocessed file to stdout. 518a850946eSmrg "$@" || exit $? 519a850946eSmrg 520a850946eSmrg # Remove the call to Libtool. 521a850946eSmrg if test "$libtool" = yes; then 52270f7c90cSmrg while test "X$1" != 'X--mode=compile'; do 523a850946eSmrg shift 524a850946eSmrg done 525a850946eSmrg shift 526a850946eSmrg fi 527a850946eSmrg 528a850946eSmrg # Remove `-o $object'. 529a850946eSmrg IFS=" " 530a850946eSmrg for arg 531a850946eSmrg do 532a850946eSmrg case $arg in 533a850946eSmrg -o) 534a850946eSmrg shift 535a850946eSmrg ;; 536a850946eSmrg $object) 537a850946eSmrg shift 538a850946eSmrg ;; 539a850946eSmrg *) 540a850946eSmrg set fnord "$@" "$arg" 541a850946eSmrg shift # fnord 542a850946eSmrg shift # $arg 543a850946eSmrg ;; 544a850946eSmrg esac 545a850946eSmrg done 546a850946eSmrg 547a850946eSmrg "$@" -E | 54870f7c90cSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 54970f7c90cSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550a850946eSmrg sed '$ s: \\$::' > "$tmpdepfile" 551a850946eSmrg rm -f "$depfile" 552a850946eSmrg echo "$object : \\" > "$depfile" 553a850946eSmrg cat < "$tmpdepfile" >> "$depfile" 554a850946eSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555a850946eSmrg rm -f "$tmpdepfile" 556a850946eSmrg ;; 557a850946eSmrg 558a850946eSmrgmsvisualcpp) 559a850946eSmrg # Important note: in order to support this mode, a compiler *must* 56070f7c90cSmrg # always write the preprocessed file to stdout. 561a850946eSmrg "$@" || exit $? 56270f7c90cSmrg 56370f7c90cSmrg # Remove the call to Libtool. 56470f7c90cSmrg if test "$libtool" = yes; then 56570f7c90cSmrg while test "X$1" != 'X--mode=compile'; do 56670f7c90cSmrg shift 56770f7c90cSmrg done 56870f7c90cSmrg shift 56970f7c90cSmrg fi 57070f7c90cSmrg 571a850946eSmrg IFS=" " 572a850946eSmrg for arg 573a850946eSmrg do 574a850946eSmrg case "$arg" in 57570f7c90cSmrg -o) 57670f7c90cSmrg shift 57770f7c90cSmrg ;; 57870f7c90cSmrg $object) 57970f7c90cSmrg shift 58070f7c90cSmrg ;; 581a850946eSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582a850946eSmrg set fnord "$@" 583a850946eSmrg shift 584a850946eSmrg shift 585a850946eSmrg ;; 586a850946eSmrg *) 587a850946eSmrg set fnord "$@" "$arg" 588a850946eSmrg shift 589a850946eSmrg shift 590a850946eSmrg ;; 591a850946eSmrg esac 592a850946eSmrg done 59370f7c90cSmrg "$@" -E 2>/dev/null | 59470f7c90cSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595a850946eSmrg rm -f "$depfile" 596a850946eSmrg echo "$object : \\" > "$depfile" 59770f7c90cSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598a850946eSmrg echo " " >> "$depfile" 59970f7c90cSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600a850946eSmrg rm -f "$tmpdepfile" 601a850946eSmrg ;; 602a850946eSmrg 60370f7c90cSmrgmsvcmsys) 60470f7c90cSmrg # This case exists only to let depend.m4 do its work. It works by 60570f7c90cSmrg # looking at the text of this script. This case will never be run, 60670f7c90cSmrg # since it is checked for above. 60770f7c90cSmrg exit 1 60870f7c90cSmrg ;; 60970f7c90cSmrg 610a850946eSmrgnone) 611a850946eSmrg exec "$@" 612a850946eSmrg ;; 613a850946eSmrg 614a850946eSmrg*) 615a850946eSmrg echo "Unknown depmode $depmode" 1>&2 616a850946eSmrg exit 1 617a850946eSmrg ;; 618a850946eSmrgesac 619a850946eSmrg 620a850946eSmrgexit 0 62170f7c90cSmrg 62270f7c90cSmrg# Local Variables: 62370f7c90cSmrg# mode: shell-script 62470f7c90cSmrg# sh-indentation: 2 62570f7c90cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 62670f7c90cSmrg# time-stamp-start: "scriptversion=" 62770f7c90cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 62870f7c90cSmrg# time-stamp-time-zone: "UTC" 62970f7c90cSmrg# time-stamp-end: "; # UTC" 63070f7c90cSmrg# End: 631