depcomp revision 350952b9
1fd7d9bd3Smrg#! /bin/sh 2fd7d9bd3Smrg# depcomp - compile a program generating dependencies as side-effects 3350952b9Smrg 4350952b9Smrgscriptversion=2009-04-28.21; # UTC 5350952b9Smrg 6350952b9Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7350952b9Smrg# Software Foundation, Inc. 8fd7d9bd3Smrg 9fd7d9bd3Smrg# This program is free software; you can redistribute it and/or modify 10fd7d9bd3Smrg# it under the terms of the GNU General Public License as published by 11fd7d9bd3Smrg# the Free Software Foundation; either version 2, or (at your option) 12fd7d9bd3Smrg# any later version. 13fd7d9bd3Smrg 14fd7d9bd3Smrg# This program is distributed in the hope that it will be useful, 15fd7d9bd3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16fd7d9bd3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17fd7d9bd3Smrg# GNU General Public License for more details. 18fd7d9bd3Smrg 19fd7d9bd3Smrg# You should have received a copy of the GNU General Public License 20350952b9Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21fd7d9bd3Smrg 22fd7d9bd3Smrg# As a special exception to the GNU General Public License, if you 23fd7d9bd3Smrg# distribute this file as part of a program that contains a 24fd7d9bd3Smrg# configuration script generated by Autoconf, you may include it under 25fd7d9bd3Smrg# the same distribution terms that you use for the rest of that program. 26fd7d9bd3Smrg 27fd7d9bd3Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28fd7d9bd3Smrg 29350952b9Smrgcase $1 in 30350952b9Smrg '') 31350952b9Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32350952b9Smrg exit 1; 33350952b9Smrg ;; 34350952b9Smrg -h | --h*) 35350952b9Smrg cat <<\EOF 36350952b9SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37350952b9Smrg 38350952b9SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39350952b9Smrgas side-effects. 40350952b9Smrg 41350952b9SmrgEnvironment variables: 42350952b9Smrg depmode Dependency tracking mode. 43350952b9Smrg source Source file read by `PROGRAMS ARGS'. 44350952b9Smrg object Object file output by `PROGRAMS ARGS'. 45350952b9Smrg DEPDIR directory where to store dependencies. 46350952b9Smrg depfile Dependency file to output. 47350952b9Smrg tmpdepfile Temporary file to use when outputing dependencies. 48350952b9Smrg libtool Whether libtool is used (yes/no). 49350952b9Smrg 50350952b9SmrgReport bugs to <bug-automake@gnu.org>. 51350952b9SmrgEOF 52350952b9Smrg exit $? 53350952b9Smrg ;; 54350952b9Smrg -v | --v*) 55350952b9Smrg echo "depcomp $scriptversion" 56350952b9Smrg exit $? 57350952b9Smrg ;; 58350952b9Smrgesac 59350952b9Smrg 60fd7d9bd3Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61fd7d9bd3Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62fd7d9bd3Smrg exit 1 63fd7d9bd3Smrgfi 64fd7d9bd3Smrg 65350952b9Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66350952b9Smrgdepfile=${depfile-`echo "$object" | 67350952b9Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68fd7d9bd3Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69fd7d9bd3Smrg 70fd7d9bd3Smrgrm -f "$tmpdepfile" 71fd7d9bd3Smrg 72fd7d9bd3Smrg# Some modes work just like other modes, but use different flags. We 73fd7d9bd3Smrg# parameterize here, but still list the modes in the big case below, 74fd7d9bd3Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75fd7d9bd3Smrg# here, because this file can only contain one case statement. 76fd7d9bd3Smrgif test "$depmode" = hp; then 77fd7d9bd3Smrg # HP compiler uses -M and no extra arg. 78fd7d9bd3Smrg gccflag=-M 79fd7d9bd3Smrg depmode=gcc 80fd7d9bd3Smrgfi 81fd7d9bd3Smrg 82fd7d9bd3Smrgif test "$depmode" = dashXmstdout; then 83fd7d9bd3Smrg # This is just like dashmstdout with a different argument. 84fd7d9bd3Smrg dashmflag=-xM 85fd7d9bd3Smrg depmode=dashmstdout 86fd7d9bd3Smrgfi 87fd7d9bd3Smrg 88350952b9Smrgcygpath_u="cygpath -u -f -" 89350952b9Smrgif test "$depmode" = msvcmsys; then 90350952b9Smrg # This is just like msvisualcpp but w/o cygpath translation. 91350952b9Smrg # Just convert the backslash-escaped backslashes to single forward 92350952b9Smrg # slashes to satisfy depend.m4 93350952b9Smrg cygpath_u="sed s,\\\\\\\\,/,g" 94350952b9Smrg depmode=msvisualcpp 95350952b9Smrgfi 96350952b9Smrg 97fd7d9bd3Smrgcase "$depmode" in 98fd7d9bd3Smrggcc3) 99fd7d9bd3Smrg## gcc 3 implements dependency tracking that does exactly what 100fd7d9bd3Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101fd7d9bd3Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 102350952b9Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103350952b9Smrg## the command line argument order; so add the flags where they 104350952b9Smrg## appear in depend2.am. Note that the slowdown incurred here 105350952b9Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106350952b9Smrg for arg 107350952b9Smrg do 108350952b9Smrg case $arg in 109350952b9Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110350952b9Smrg *) set fnord "$@" "$arg" ;; 111350952b9Smrg esac 112350952b9Smrg shift # fnord 113350952b9Smrg shift # $arg 114350952b9Smrg done 115350952b9Smrg "$@" 116fd7d9bd3Smrg stat=$? 117fd7d9bd3Smrg if test $stat -eq 0; then : 118fd7d9bd3Smrg else 119fd7d9bd3Smrg rm -f "$tmpdepfile" 120fd7d9bd3Smrg exit $stat 121fd7d9bd3Smrg fi 122fd7d9bd3Smrg mv "$tmpdepfile" "$depfile" 123fd7d9bd3Smrg ;; 124fd7d9bd3Smrg 125fd7d9bd3Smrggcc) 126fd7d9bd3Smrg## There are various ways to get dependency output from gcc. Here's 127fd7d9bd3Smrg## why we pick this rather obscure method: 128fd7d9bd3Smrg## - Don't want to use -MD because we'd like the dependencies to end 129fd7d9bd3Smrg## up in a subdir. Having to rename by hand is ugly. 130fd7d9bd3Smrg## (We might end up doing this anyway to support other compilers.) 131fd7d9bd3Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132fd7d9bd3Smrg## -MM, not -M (despite what the docs say). 133fd7d9bd3Smrg## - Using -M directly means running the compiler twice (even worse 134fd7d9bd3Smrg## than renaming). 135fd7d9bd3Smrg if test -z "$gccflag"; then 136fd7d9bd3Smrg gccflag=-MD, 137fd7d9bd3Smrg fi 138fd7d9bd3Smrg "$@" -Wp,"$gccflag$tmpdepfile" 139fd7d9bd3Smrg stat=$? 140fd7d9bd3Smrg if test $stat -eq 0; then : 141fd7d9bd3Smrg else 142fd7d9bd3Smrg rm -f "$tmpdepfile" 143fd7d9bd3Smrg exit $stat 144fd7d9bd3Smrg fi 145fd7d9bd3Smrg rm -f "$depfile" 146fd7d9bd3Smrg echo "$object : \\" > "$depfile" 147fd7d9bd3Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148fd7d9bd3Smrg## The second -e expression handles DOS-style file names with drive letters. 149fd7d9bd3Smrg sed -e 's/^[^:]*: / /' \ 150fd7d9bd3Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151fd7d9bd3Smrg## This next piece of magic avoids the `deleted header file' problem. 152fd7d9bd3Smrg## The problem is that when a header file which appears in a .P file 153fd7d9bd3Smrg## is deleted, the dependency causes make to die (because there is 154fd7d9bd3Smrg## typically no way to rebuild the header). We avoid this by adding 155fd7d9bd3Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 156fd7d9bd3Smrg## this for us directly. 157fd7d9bd3Smrg tr ' ' ' 158fd7d9bd3Smrg' < "$tmpdepfile" | 159fd7d9bd3Smrg## Some versions of gcc put a space before the `:'. On the theory 160fd7d9bd3Smrg## that the space means something, we add a space to the output as 161fd7d9bd3Smrg## well. 162fd7d9bd3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 163fd7d9bd3Smrg## correctly. Breaking it into two sed invocations is a workaround. 164fd7d9bd3Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165fd7d9bd3Smrg rm -f "$tmpdepfile" 166fd7d9bd3Smrg ;; 167fd7d9bd3Smrg 168fd7d9bd3Smrghp) 169fd7d9bd3Smrg # This case exists only to let depend.m4 do its work. It works by 170fd7d9bd3Smrg # looking at the text of this script. This case will never be run, 171fd7d9bd3Smrg # since it is checked for above. 172fd7d9bd3Smrg exit 1 173fd7d9bd3Smrg ;; 174fd7d9bd3Smrg 175fd7d9bd3Smrgsgi) 176fd7d9bd3Smrg if test "$libtool" = yes; then 177fd7d9bd3Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 178fd7d9bd3Smrg else 179fd7d9bd3Smrg "$@" -MDupdate "$tmpdepfile" 180fd7d9bd3Smrg fi 181fd7d9bd3Smrg stat=$? 182fd7d9bd3Smrg if test $stat -eq 0; then : 183fd7d9bd3Smrg else 184fd7d9bd3Smrg rm -f "$tmpdepfile" 185fd7d9bd3Smrg exit $stat 186fd7d9bd3Smrg fi 187fd7d9bd3Smrg rm -f "$depfile" 188fd7d9bd3Smrg 189fd7d9bd3Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190fd7d9bd3Smrg echo "$object : \\" > "$depfile" 191fd7d9bd3Smrg 192fd7d9bd3Smrg # Clip off the initial element (the dependent). Don't try to be 193fd7d9bd3Smrg # clever and replace this with sed code, as IRIX sed won't handle 194fd7d9bd3Smrg # lines with more than a fixed number of characters (4096 in 195fd7d9bd3Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196fd7d9bd3Smrg # the IRIX cc adds comments like `#:fec' to the end of the 197fd7d9bd3Smrg # dependency line. 198fd7d9bd3Smrg tr ' ' ' 199fd7d9bd3Smrg' < "$tmpdepfile" \ 200fd7d9bd3Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201fd7d9bd3Smrg tr ' 202350952b9Smrg' ' ' >> "$depfile" 203350952b9Smrg echo >> "$depfile" 204fd7d9bd3Smrg 205fd7d9bd3Smrg # The second pass generates a dummy entry for each header file. 206fd7d9bd3Smrg tr ' ' ' 207fd7d9bd3Smrg' < "$tmpdepfile" \ 208fd7d9bd3Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209350952b9Smrg >> "$depfile" 210fd7d9bd3Smrg else 211fd7d9bd3Smrg # The sourcefile does not contain any dependencies, so just 212fd7d9bd3Smrg # store a dummy comment line, to avoid errors with the Makefile 213fd7d9bd3Smrg # "include basename.Plo" scheme. 214fd7d9bd3Smrg echo "#dummy" > "$depfile" 215fd7d9bd3Smrg fi 216fd7d9bd3Smrg rm -f "$tmpdepfile" 217fd7d9bd3Smrg ;; 218fd7d9bd3Smrg 219fd7d9bd3Smrgaix) 220fd7d9bd3Smrg # The C for AIX Compiler uses -M and outputs the dependencies 221fd7d9bd3Smrg # in a .u file. In older versions, this file always lives in the 222fd7d9bd3Smrg # current directory. Also, the AIX compiler puts `$object:' at the 223fd7d9bd3Smrg # start of each line; $object doesn't have directory information. 224fd7d9bd3Smrg # Version 6 uses the directory in both cases. 225350952b9Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226350952b9Smrg test "x$dir" = "x$object" && dir= 227350952b9Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228fd7d9bd3Smrg if test "$libtool" = yes; then 229350952b9Smrg tmpdepfile1=$dir$base.u 230350952b9Smrg tmpdepfile2=$base.u 231350952b9Smrg tmpdepfile3=$dir.libs/$base.u 232fd7d9bd3Smrg "$@" -Wc,-M 233fd7d9bd3Smrg else 234350952b9Smrg tmpdepfile1=$dir$base.u 235350952b9Smrg tmpdepfile2=$dir$base.u 236350952b9Smrg tmpdepfile3=$dir$base.u 237fd7d9bd3Smrg "$@" -M 238fd7d9bd3Smrg fi 239fd7d9bd3Smrg stat=$? 240fd7d9bd3Smrg 241fd7d9bd3Smrg if test $stat -eq 0; then : 242fd7d9bd3Smrg else 243350952b9Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244fd7d9bd3Smrg exit $stat 245fd7d9bd3Smrg fi 246fd7d9bd3Smrg 247350952b9Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248350952b9Smrg do 249350952b9Smrg test -f "$tmpdepfile" && break 250350952b9Smrg done 251fd7d9bd3Smrg if test -f "$tmpdepfile"; then 252fd7d9bd3Smrg # Each line is of the form `foo.o: dependent.h'. 253fd7d9bd3Smrg # Do two passes, one to just change these to 254fd7d9bd3Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 255350952b9Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256350952b9Smrg # That's a tab and a space in the []. 257350952b9Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258fd7d9bd3Smrg else 259fd7d9bd3Smrg # The sourcefile does not contain any dependencies, so just 260fd7d9bd3Smrg # store a dummy comment line, to avoid errors with the Makefile 261fd7d9bd3Smrg # "include basename.Plo" scheme. 262fd7d9bd3Smrg echo "#dummy" > "$depfile" 263fd7d9bd3Smrg fi 264fd7d9bd3Smrg rm -f "$tmpdepfile" 265fd7d9bd3Smrg ;; 266fd7d9bd3Smrg 267fd7d9bd3Smrgicc) 268fd7d9bd3Smrg # Intel's C compiler understands `-MD -MF file'. However on 269fd7d9bd3Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270fd7d9bd3Smrg # ICC 7.0 will fill foo.d with something like 271fd7d9bd3Smrg # foo.o: sub/foo.c 272fd7d9bd3Smrg # foo.o: sub/foo.h 273fd7d9bd3Smrg # which is wrong. We want: 274fd7d9bd3Smrg # sub/foo.o: sub/foo.c 275fd7d9bd3Smrg # sub/foo.o: sub/foo.h 276fd7d9bd3Smrg # sub/foo.c: 277fd7d9bd3Smrg # sub/foo.h: 278fd7d9bd3Smrg # ICC 7.1 will output 279fd7d9bd3Smrg # foo.o: sub/foo.c sub/foo.h 280fd7d9bd3Smrg # and will wrap long lines using \ : 281fd7d9bd3Smrg # foo.o: sub/foo.c ... \ 282fd7d9bd3Smrg # sub/foo.h ... \ 283fd7d9bd3Smrg # ... 284fd7d9bd3Smrg 285fd7d9bd3Smrg "$@" -MD -MF "$tmpdepfile" 286fd7d9bd3Smrg stat=$? 287fd7d9bd3Smrg if test $stat -eq 0; then : 288fd7d9bd3Smrg else 289fd7d9bd3Smrg rm -f "$tmpdepfile" 290fd7d9bd3Smrg exit $stat 291fd7d9bd3Smrg fi 292fd7d9bd3Smrg rm -f "$depfile" 293fd7d9bd3Smrg # Each line is of the form `foo.o: dependent.h', 294fd7d9bd3Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295fd7d9bd3Smrg # Do two passes, one to just change these to 296fd7d9bd3Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 297fd7d9bd3Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298fd7d9bd3Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 299fd7d9bd3Smrg # correctly. Breaking it into two sed invocations is a workaround. 300fd7d9bd3Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301fd7d9bd3Smrg sed -e 's/$/ :/' >> "$depfile" 302fd7d9bd3Smrg rm -f "$tmpdepfile" 303fd7d9bd3Smrg ;; 304fd7d9bd3Smrg 305350952b9Smrghp2) 306350952b9Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307350952b9Smrg # compilers, which have integrated preprocessors. The correct option 308350952b9Smrg # to use with these is +Maked; it writes dependencies to a file named 309350952b9Smrg # 'foo.d', which lands next to the object file, wherever that 310350952b9Smrg # happens to be. 311350952b9Smrg # Much of this is similar to the tru64 case; see comments there. 312350952b9Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313350952b9Smrg test "x$dir" = "x$object" && dir= 314350952b9Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315350952b9Smrg if test "$libtool" = yes; then 316350952b9Smrg tmpdepfile1=$dir$base.d 317350952b9Smrg tmpdepfile2=$dir.libs/$base.d 318350952b9Smrg "$@" -Wc,+Maked 319350952b9Smrg else 320350952b9Smrg tmpdepfile1=$dir$base.d 321350952b9Smrg tmpdepfile2=$dir$base.d 322350952b9Smrg "$@" +Maked 323350952b9Smrg fi 324350952b9Smrg stat=$? 325350952b9Smrg if test $stat -eq 0; then : 326350952b9Smrg else 327350952b9Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 328350952b9Smrg exit $stat 329350952b9Smrg fi 330350952b9Smrg 331350952b9Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332350952b9Smrg do 333350952b9Smrg test -f "$tmpdepfile" && break 334350952b9Smrg done 335350952b9Smrg if test -f "$tmpdepfile"; then 336350952b9Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337350952b9Smrg # Add `dependent.h:' lines. 338350952b9Smrg sed -ne '2,${ 339350952b9Smrg s/^ *// 340350952b9Smrg s/ \\*$// 341350952b9Smrg s/$/:/ 342350952b9Smrg p 343350952b9Smrg }' "$tmpdepfile" >> "$depfile" 344350952b9Smrg else 345350952b9Smrg echo "#dummy" > "$depfile" 346350952b9Smrg fi 347350952b9Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 348350952b9Smrg ;; 349350952b9Smrg 350fd7d9bd3Smrgtru64) 351fd7d9bd3Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 352fd7d9bd3Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353fd7d9bd3Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354fd7d9bd3Smrg # dependencies in `foo.d' instead, so we check for that too. 355fd7d9bd3Smrg # Subdirectories are respected. 356fd7d9bd3Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357fd7d9bd3Smrg test "x$dir" = "x$object" && dir= 358fd7d9bd3Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359fd7d9bd3Smrg 360fd7d9bd3Smrg if test "$libtool" = yes; then 361350952b9Smrg # With Tru64 cc, shared objects can also be used to make a 362350952b9Smrg # static library. This mechanism is used in libtool 1.4 series to 363350952b9Smrg # handle both shared and static libraries in a single compilation. 364350952b9Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365350952b9Smrg # 366350952b9Smrg # With libtool 1.5 this exception was removed, and libtool now 367350952b9Smrg # generates 2 separate objects for the 2 libraries. These two 368350952b9Smrg # compilations output dependencies in $dir.libs/$base.o.d and 369350952b9Smrg # in $dir$base.o.d. We have to check for both files, because 370350952b9Smrg # one of the two compilations can be disabled. We should prefer 371350952b9Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372350952b9Smrg # automatically cleaned when .libs/ is deleted, while ignoring 373350952b9Smrg # the former would cause a distcleancheck panic. 374350952b9Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375350952b9Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 376350952b9Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377350952b9Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378fd7d9bd3Smrg "$@" -Wc,-MD 379fd7d9bd3Smrg else 380350952b9Smrg tmpdepfile1=$dir$base.o.d 381350952b9Smrg tmpdepfile2=$dir$base.d 382350952b9Smrg tmpdepfile3=$dir$base.d 383350952b9Smrg tmpdepfile4=$dir$base.d 384fd7d9bd3Smrg "$@" -MD 385fd7d9bd3Smrg fi 386fd7d9bd3Smrg 387fd7d9bd3Smrg stat=$? 388fd7d9bd3Smrg if test $stat -eq 0; then : 389fd7d9bd3Smrg else 390350952b9Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391fd7d9bd3Smrg exit $stat 392fd7d9bd3Smrg fi 393fd7d9bd3Smrg 394350952b9Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395350952b9Smrg do 396350952b9Smrg test -f "$tmpdepfile" && break 397350952b9Smrg done 398fd7d9bd3Smrg if test -f "$tmpdepfile"; then 399fd7d9bd3Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400fd7d9bd3Smrg # That's a tab and a space in the []. 401fd7d9bd3Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402fd7d9bd3Smrg else 403fd7d9bd3Smrg echo "#dummy" > "$depfile" 404fd7d9bd3Smrg fi 405fd7d9bd3Smrg rm -f "$tmpdepfile" 406fd7d9bd3Smrg ;; 407fd7d9bd3Smrg 408fd7d9bd3Smrg#nosideeffect) 409fd7d9bd3Smrg # This comment above is used by automake to tell side-effect 410fd7d9bd3Smrg # dependency tracking mechanisms from slower ones. 411fd7d9bd3Smrg 412fd7d9bd3Smrgdashmstdout) 413fd7d9bd3Smrg # Important note: in order to support this mode, a compiler *must* 414fd7d9bd3Smrg # always write the preprocessed file to stdout, regardless of -o. 415fd7d9bd3Smrg "$@" || exit $? 416fd7d9bd3Smrg 417fd7d9bd3Smrg # Remove the call to Libtool. 418fd7d9bd3Smrg if test "$libtool" = yes; then 419350952b9Smrg while test "X$1" != 'X--mode=compile'; do 420fd7d9bd3Smrg shift 421fd7d9bd3Smrg done 422fd7d9bd3Smrg shift 423fd7d9bd3Smrg fi 424fd7d9bd3Smrg 425fd7d9bd3Smrg # Remove `-o $object'. 426fd7d9bd3Smrg IFS=" " 427fd7d9bd3Smrg for arg 428fd7d9bd3Smrg do 429fd7d9bd3Smrg case $arg in 430fd7d9bd3Smrg -o) 431fd7d9bd3Smrg shift 432fd7d9bd3Smrg ;; 433fd7d9bd3Smrg $object) 434fd7d9bd3Smrg shift 435fd7d9bd3Smrg ;; 436fd7d9bd3Smrg *) 437fd7d9bd3Smrg set fnord "$@" "$arg" 438fd7d9bd3Smrg shift # fnord 439fd7d9bd3Smrg shift # $arg 440fd7d9bd3Smrg ;; 441fd7d9bd3Smrg esac 442fd7d9bd3Smrg done 443fd7d9bd3Smrg 444fd7d9bd3Smrg test -z "$dashmflag" && dashmflag=-M 445fd7d9bd3Smrg # Require at least two characters before searching for `:' 446fd7d9bd3Smrg # in the target name. This is to cope with DOS-style filenames: 447fd7d9bd3Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448fd7d9bd3Smrg "$@" $dashmflag | 449fd7d9bd3Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450fd7d9bd3Smrg rm -f "$depfile" 451fd7d9bd3Smrg cat < "$tmpdepfile" > "$depfile" 452fd7d9bd3Smrg tr ' ' ' 453fd7d9bd3Smrg' < "$tmpdepfile" | \ 454fd7d9bd3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 455fd7d9bd3Smrg## correctly. Breaking it into two sed invocations is a workaround. 456fd7d9bd3Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457fd7d9bd3Smrg rm -f "$tmpdepfile" 458fd7d9bd3Smrg ;; 459fd7d9bd3Smrg 460fd7d9bd3SmrgdashXmstdout) 461fd7d9bd3Smrg # This case only exists to satisfy depend.m4. It is never actually 462fd7d9bd3Smrg # run, as this mode is specially recognized in the preamble. 463fd7d9bd3Smrg exit 1 464fd7d9bd3Smrg ;; 465fd7d9bd3Smrg 466fd7d9bd3Smrgmakedepend) 467fd7d9bd3Smrg "$@" || exit $? 468fd7d9bd3Smrg # Remove any Libtool call 469fd7d9bd3Smrg if test "$libtool" = yes; then 470350952b9Smrg while test "X$1" != 'X--mode=compile'; do 471fd7d9bd3Smrg shift 472fd7d9bd3Smrg done 473fd7d9bd3Smrg shift 474fd7d9bd3Smrg fi 475fd7d9bd3Smrg # X makedepend 476fd7d9bd3Smrg shift 477350952b9Smrg cleared=no eat=no 478350952b9Smrg for arg 479350952b9Smrg do 480fd7d9bd3Smrg case $cleared in 481fd7d9bd3Smrg no) 482fd7d9bd3Smrg set ""; shift 483fd7d9bd3Smrg cleared=yes ;; 484fd7d9bd3Smrg esac 485350952b9Smrg if test $eat = yes; then 486350952b9Smrg eat=no 487350952b9Smrg continue 488350952b9Smrg fi 489fd7d9bd3Smrg case "$arg" in 490fd7d9bd3Smrg -D*|-I*) 491fd7d9bd3Smrg set fnord "$@" "$arg"; shift ;; 492fd7d9bd3Smrg # Strip any option that makedepend may not understand. Remove 493fd7d9bd3Smrg # the object too, otherwise makedepend will parse it as a source file. 494350952b9Smrg -arch) 495350952b9Smrg eat=yes ;; 496fd7d9bd3Smrg -*|$object) 497fd7d9bd3Smrg ;; 498fd7d9bd3Smrg *) 499fd7d9bd3Smrg set fnord "$@" "$arg"; shift ;; 500fd7d9bd3Smrg esac 501fd7d9bd3Smrg done 502350952b9Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 503fd7d9bd3Smrg touch "$tmpdepfile" 504fd7d9bd3Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505fd7d9bd3Smrg rm -f "$depfile" 506fd7d9bd3Smrg cat < "$tmpdepfile" > "$depfile" 507fd7d9bd3Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 508fd7d9bd3Smrg' | \ 509fd7d9bd3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 510fd7d9bd3Smrg## correctly. Breaking it into two sed invocations is a workaround. 511fd7d9bd3Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512fd7d9bd3Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 513fd7d9bd3Smrg ;; 514fd7d9bd3Smrg 515fd7d9bd3Smrgcpp) 516fd7d9bd3Smrg # Important note: in order to support this mode, a compiler *must* 517fd7d9bd3Smrg # always write the preprocessed file to stdout. 518fd7d9bd3Smrg "$@" || exit $? 519fd7d9bd3Smrg 520fd7d9bd3Smrg # Remove the call to Libtool. 521fd7d9bd3Smrg if test "$libtool" = yes; then 522350952b9Smrg while test "X$1" != 'X--mode=compile'; do 523fd7d9bd3Smrg shift 524fd7d9bd3Smrg done 525fd7d9bd3Smrg shift 526fd7d9bd3Smrg fi 527fd7d9bd3Smrg 528fd7d9bd3Smrg # Remove `-o $object'. 529fd7d9bd3Smrg IFS=" " 530fd7d9bd3Smrg for arg 531fd7d9bd3Smrg do 532fd7d9bd3Smrg case $arg in 533fd7d9bd3Smrg -o) 534fd7d9bd3Smrg shift 535fd7d9bd3Smrg ;; 536fd7d9bd3Smrg $object) 537fd7d9bd3Smrg shift 538fd7d9bd3Smrg ;; 539fd7d9bd3Smrg *) 540fd7d9bd3Smrg set fnord "$@" "$arg" 541fd7d9bd3Smrg shift # fnord 542fd7d9bd3Smrg shift # $arg 543fd7d9bd3Smrg ;; 544fd7d9bd3Smrg esac 545fd7d9bd3Smrg done 546fd7d9bd3Smrg 547fd7d9bd3Smrg "$@" -E | 548350952b9Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549350952b9Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550fd7d9bd3Smrg sed '$ s: \\$::' > "$tmpdepfile" 551fd7d9bd3Smrg rm -f "$depfile" 552fd7d9bd3Smrg echo "$object : \\" > "$depfile" 553fd7d9bd3Smrg cat < "$tmpdepfile" >> "$depfile" 554fd7d9bd3Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555fd7d9bd3Smrg rm -f "$tmpdepfile" 556fd7d9bd3Smrg ;; 557fd7d9bd3Smrg 558fd7d9bd3Smrgmsvisualcpp) 559fd7d9bd3Smrg # Important note: in order to support this mode, a compiler *must* 560350952b9Smrg # always write the preprocessed file to stdout. 561fd7d9bd3Smrg "$@" || exit $? 562350952b9Smrg 563350952b9Smrg # Remove the call to Libtool. 564350952b9Smrg if test "$libtool" = yes; then 565350952b9Smrg while test "X$1" != 'X--mode=compile'; do 566350952b9Smrg shift 567350952b9Smrg done 568350952b9Smrg shift 569350952b9Smrg fi 570350952b9Smrg 571fd7d9bd3Smrg IFS=" " 572fd7d9bd3Smrg for arg 573fd7d9bd3Smrg do 574fd7d9bd3Smrg case "$arg" in 575350952b9Smrg -o) 576350952b9Smrg shift 577350952b9Smrg ;; 578350952b9Smrg $object) 579350952b9Smrg shift 580350952b9Smrg ;; 581fd7d9bd3Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582fd7d9bd3Smrg set fnord "$@" 583fd7d9bd3Smrg shift 584fd7d9bd3Smrg shift 585fd7d9bd3Smrg ;; 586fd7d9bd3Smrg *) 587fd7d9bd3Smrg set fnord "$@" "$arg" 588fd7d9bd3Smrg shift 589fd7d9bd3Smrg shift 590fd7d9bd3Smrg ;; 591fd7d9bd3Smrg esac 592fd7d9bd3Smrg done 593350952b9Smrg "$@" -E 2>/dev/null | 594350952b9Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595fd7d9bd3Smrg rm -f "$depfile" 596fd7d9bd3Smrg echo "$object : \\" > "$depfile" 597350952b9Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598fd7d9bd3Smrg echo " " >> "$depfile" 599350952b9Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600fd7d9bd3Smrg rm -f "$tmpdepfile" 601fd7d9bd3Smrg ;; 602fd7d9bd3Smrg 603350952b9Smrgmsvcmsys) 604350952b9Smrg # This case exists only to let depend.m4 do its work. It works by 605350952b9Smrg # looking at the text of this script. This case will never be run, 606350952b9Smrg # since it is checked for above. 607350952b9Smrg exit 1 608350952b9Smrg ;; 609350952b9Smrg 610fd7d9bd3Smrgnone) 611fd7d9bd3Smrg exec "$@" 612fd7d9bd3Smrg ;; 613fd7d9bd3Smrg 614fd7d9bd3Smrg*) 615fd7d9bd3Smrg echo "Unknown depmode $depmode" 1>&2 616fd7d9bd3Smrg exit 1 617fd7d9bd3Smrg ;; 618fd7d9bd3Smrgesac 619fd7d9bd3Smrg 620fd7d9bd3Smrgexit 0 621350952b9Smrg 622350952b9Smrg# Local Variables: 623350952b9Smrg# mode: shell-script 624350952b9Smrg# sh-indentation: 2 625350952b9Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 626350952b9Smrg# time-stamp-start: "scriptversion=" 627350952b9Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 628350952b9Smrg# time-stamp-time-zone: "UTC" 629350952b9Smrg# time-stamp-end: "; # UTC" 630350952b9Smrg# End: 631