depcomp revision d656433a
1126a8a12Smrg#! /bin/sh 2126a8a12Smrg# depcomp - compile a program generating dependencies as side-effects 3126a8a12Smrg 4d656433aSmrgscriptversion=2009-04-28.21; # UTC 5126a8a12Smrg 6d656433aSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7d656433aSmrg# Software Foundation, Inc. 8126a8a12Smrg 9126a8a12Smrg# This program is free software; you can redistribute it and/or modify 10126a8a12Smrg# it under the terms of the GNU General Public License as published by 11126a8a12Smrg# the Free Software Foundation; either version 2, or (at your option) 12126a8a12Smrg# any later version. 13126a8a12Smrg 14126a8a12Smrg# This program is distributed in the hope that it will be useful, 15126a8a12Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16126a8a12Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17126a8a12Smrg# GNU General Public License for more details. 18126a8a12Smrg 19126a8a12Smrg# You should have received a copy of the GNU General Public License 20d656433aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 21126a8a12Smrg 22126a8a12Smrg# As a special exception to the GNU General Public License, if you 23126a8a12Smrg# distribute this file as part of a program that contains a 24126a8a12Smrg# configuration script generated by Autoconf, you may include it under 25126a8a12Smrg# the same distribution terms that you use for the rest of that program. 26126a8a12Smrg 27126a8a12Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 28126a8a12Smrg 29126a8a12Smrgcase $1 in 30126a8a12Smrg '') 31126a8a12Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32126a8a12Smrg exit 1; 33126a8a12Smrg ;; 34126a8a12Smrg -h | --h*) 35126a8a12Smrg cat <<\EOF 36126a8a12SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 37126a8a12Smrg 38126a8a12SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 39126a8a12Smrgas side-effects. 40126a8a12Smrg 41126a8a12SmrgEnvironment variables: 42126a8a12Smrg depmode Dependency tracking mode. 43126a8a12Smrg source Source file read by `PROGRAMS ARGS'. 44126a8a12Smrg object Object file output by `PROGRAMS ARGS'. 45126a8a12Smrg DEPDIR directory where to store dependencies. 46126a8a12Smrg depfile Dependency file to output. 47126a8a12Smrg tmpdepfile Temporary file to use when outputing dependencies. 48126a8a12Smrg libtool Whether libtool is used (yes/no). 49126a8a12Smrg 50126a8a12SmrgReport bugs to <bug-automake@gnu.org>. 51126a8a12SmrgEOF 52126a8a12Smrg exit $? 53126a8a12Smrg ;; 54126a8a12Smrg -v | --v*) 55126a8a12Smrg echo "depcomp $scriptversion" 56126a8a12Smrg exit $? 57126a8a12Smrg ;; 58126a8a12Smrgesac 59126a8a12Smrg 60126a8a12Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 61126a8a12Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 62126a8a12Smrg exit 1 63126a8a12Smrgfi 64126a8a12Smrg 65126a8a12Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66126a8a12Smrgdepfile=${depfile-`echo "$object" | 67126a8a12Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68126a8a12Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69126a8a12Smrg 70126a8a12Smrgrm -f "$tmpdepfile" 71126a8a12Smrg 72126a8a12Smrg# Some modes work just like other modes, but use different flags. We 73126a8a12Smrg# parameterize here, but still list the modes in the big case below, 74126a8a12Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 75126a8a12Smrg# here, because this file can only contain one case statement. 76126a8a12Smrgif test "$depmode" = hp; then 77126a8a12Smrg # HP compiler uses -M and no extra arg. 78126a8a12Smrg gccflag=-M 79126a8a12Smrg depmode=gcc 80126a8a12Smrgfi 81126a8a12Smrg 82126a8a12Smrgif test "$depmode" = dashXmstdout; then 83126a8a12Smrg # This is just like dashmstdout with a different argument. 84126a8a12Smrg dashmflag=-xM 85126a8a12Smrg depmode=dashmstdout 86126a8a12Smrgfi 87126a8a12Smrg 88d656433aSmrgcygpath_u="cygpath -u -f -" 89d656433aSmrgif test "$depmode" = msvcmsys; then 90d656433aSmrg # This is just like msvisualcpp but w/o cygpath translation. 91d656433aSmrg # Just convert the backslash-escaped backslashes to single forward 92d656433aSmrg # slashes to satisfy depend.m4 93d656433aSmrg cygpath_u="sed s,\\\\\\\\,/,g" 94d656433aSmrg depmode=msvisualcpp 95d656433aSmrgfi 96d656433aSmrg 97126a8a12Smrgcase "$depmode" in 98126a8a12Smrggcc3) 99126a8a12Smrg## gcc 3 implements dependency tracking that does exactly what 100126a8a12Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101126a8a12Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 102126a8a12Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103126a8a12Smrg## the command line argument order; so add the flags where they 104126a8a12Smrg## appear in depend2.am. Note that the slowdown incurred here 105126a8a12Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106126a8a12Smrg for arg 107126a8a12Smrg do 108126a8a12Smrg case $arg in 109126a8a12Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110126a8a12Smrg *) set fnord "$@" "$arg" ;; 111126a8a12Smrg esac 112126a8a12Smrg shift # fnord 113126a8a12Smrg shift # $arg 114126a8a12Smrg done 115126a8a12Smrg "$@" 116126a8a12Smrg stat=$? 117126a8a12Smrg if test $stat -eq 0; then : 118126a8a12Smrg else 119126a8a12Smrg rm -f "$tmpdepfile" 120126a8a12Smrg exit $stat 121126a8a12Smrg fi 122126a8a12Smrg mv "$tmpdepfile" "$depfile" 123126a8a12Smrg ;; 124126a8a12Smrg 125126a8a12Smrggcc) 126126a8a12Smrg## There are various ways to get dependency output from gcc. Here's 127126a8a12Smrg## why we pick this rather obscure method: 128126a8a12Smrg## - Don't want to use -MD because we'd like the dependencies to end 129126a8a12Smrg## up in a subdir. Having to rename by hand is ugly. 130126a8a12Smrg## (We might end up doing this anyway to support other compilers.) 131126a8a12Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132126a8a12Smrg## -MM, not -M (despite what the docs say). 133126a8a12Smrg## - Using -M directly means running the compiler twice (even worse 134126a8a12Smrg## than renaming). 135126a8a12Smrg if test -z "$gccflag"; then 136126a8a12Smrg gccflag=-MD, 137126a8a12Smrg fi 138126a8a12Smrg "$@" -Wp,"$gccflag$tmpdepfile" 139126a8a12Smrg stat=$? 140126a8a12Smrg if test $stat -eq 0; then : 141126a8a12Smrg else 142126a8a12Smrg rm -f "$tmpdepfile" 143126a8a12Smrg exit $stat 144126a8a12Smrg fi 145126a8a12Smrg rm -f "$depfile" 146126a8a12Smrg echo "$object : \\" > "$depfile" 147126a8a12Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148126a8a12Smrg## The second -e expression handles DOS-style file names with drive letters. 149126a8a12Smrg sed -e 's/^[^:]*: / /' \ 150126a8a12Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151126a8a12Smrg## This next piece of magic avoids the `deleted header file' problem. 152126a8a12Smrg## The problem is that when a header file which appears in a .P file 153126a8a12Smrg## is deleted, the dependency causes make to die (because there is 154126a8a12Smrg## typically no way to rebuild the header). We avoid this by adding 155126a8a12Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 156126a8a12Smrg## this for us directly. 157126a8a12Smrg tr ' ' ' 158126a8a12Smrg' < "$tmpdepfile" | 159126a8a12Smrg## Some versions of gcc put a space before the `:'. On the theory 160126a8a12Smrg## that the space means something, we add a space to the output as 161126a8a12Smrg## well. 162126a8a12Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 163126a8a12Smrg## correctly. Breaking it into two sed invocations is a workaround. 164126a8a12Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165126a8a12Smrg rm -f "$tmpdepfile" 166126a8a12Smrg ;; 167126a8a12Smrg 168126a8a12Smrghp) 169126a8a12Smrg # This case exists only to let depend.m4 do its work. It works by 170126a8a12Smrg # looking at the text of this script. This case will never be run, 171126a8a12Smrg # since it is checked for above. 172126a8a12Smrg exit 1 173126a8a12Smrg ;; 174126a8a12Smrg 175126a8a12Smrgsgi) 176126a8a12Smrg if test "$libtool" = yes; then 177126a8a12Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 178126a8a12Smrg else 179126a8a12Smrg "$@" -MDupdate "$tmpdepfile" 180126a8a12Smrg fi 181126a8a12Smrg stat=$? 182126a8a12Smrg if test $stat -eq 0; then : 183126a8a12Smrg else 184126a8a12Smrg rm -f "$tmpdepfile" 185126a8a12Smrg exit $stat 186126a8a12Smrg fi 187126a8a12Smrg rm -f "$depfile" 188126a8a12Smrg 189126a8a12Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190126a8a12Smrg echo "$object : \\" > "$depfile" 191126a8a12Smrg 192126a8a12Smrg # Clip off the initial element (the dependent). Don't try to be 193126a8a12Smrg # clever and replace this with sed code, as IRIX sed won't handle 194126a8a12Smrg # lines with more than a fixed number of characters (4096 in 195126a8a12Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196126a8a12Smrg # the IRIX cc adds comments like `#:fec' to the end of the 197126a8a12Smrg # dependency line. 198126a8a12Smrg tr ' ' ' 199126a8a12Smrg' < "$tmpdepfile" \ 200126a8a12Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201126a8a12Smrg tr ' 202d656433aSmrg' ' ' >> "$depfile" 203d656433aSmrg echo >> "$depfile" 204126a8a12Smrg 205126a8a12Smrg # The second pass generates a dummy entry for each header file. 206126a8a12Smrg tr ' ' ' 207126a8a12Smrg' < "$tmpdepfile" \ 208126a8a12Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209d656433aSmrg >> "$depfile" 210126a8a12Smrg else 211126a8a12Smrg # The sourcefile does not contain any dependencies, so just 212126a8a12Smrg # store a dummy comment line, to avoid errors with the Makefile 213126a8a12Smrg # "include basename.Plo" scheme. 214126a8a12Smrg echo "#dummy" > "$depfile" 215126a8a12Smrg fi 216126a8a12Smrg rm -f "$tmpdepfile" 217126a8a12Smrg ;; 218126a8a12Smrg 219126a8a12Smrgaix) 220126a8a12Smrg # The C for AIX Compiler uses -M and outputs the dependencies 221126a8a12Smrg # in a .u file. In older versions, this file always lives in the 222126a8a12Smrg # current directory. Also, the AIX compiler puts `$object:' at the 223126a8a12Smrg # start of each line; $object doesn't have directory information. 224126a8a12Smrg # Version 6 uses the directory in both cases. 225d656433aSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226d656433aSmrg test "x$dir" = "x$object" && dir= 227d656433aSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228126a8a12Smrg if test "$libtool" = yes; then 229d656433aSmrg tmpdepfile1=$dir$base.u 230d656433aSmrg tmpdepfile2=$base.u 231d656433aSmrg tmpdepfile3=$dir.libs/$base.u 232126a8a12Smrg "$@" -Wc,-M 233126a8a12Smrg else 234d656433aSmrg tmpdepfile1=$dir$base.u 235d656433aSmrg tmpdepfile2=$dir$base.u 236d656433aSmrg tmpdepfile3=$dir$base.u 237126a8a12Smrg "$@" -M 238126a8a12Smrg fi 239126a8a12Smrg stat=$? 240126a8a12Smrg 241126a8a12Smrg if test $stat -eq 0; then : 242126a8a12Smrg else 243d656433aSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244126a8a12Smrg exit $stat 245126a8a12Smrg fi 246126a8a12Smrg 247d656433aSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248d656433aSmrg do 249d656433aSmrg test -f "$tmpdepfile" && break 250d656433aSmrg done 251126a8a12Smrg if test -f "$tmpdepfile"; then 252126a8a12Smrg # Each line is of the form `foo.o: dependent.h'. 253126a8a12Smrg # Do two passes, one to just change these to 254126a8a12Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 255d656433aSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256d656433aSmrg # That's a tab and a space in the []. 257d656433aSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258126a8a12Smrg else 259126a8a12Smrg # The sourcefile does not contain any dependencies, so just 260126a8a12Smrg # store a dummy comment line, to avoid errors with the Makefile 261126a8a12Smrg # "include basename.Plo" scheme. 262126a8a12Smrg echo "#dummy" > "$depfile" 263126a8a12Smrg fi 264126a8a12Smrg rm -f "$tmpdepfile" 265126a8a12Smrg ;; 266126a8a12Smrg 267126a8a12Smrgicc) 268126a8a12Smrg # Intel's C compiler understands `-MD -MF file'. However on 269126a8a12Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270126a8a12Smrg # ICC 7.0 will fill foo.d with something like 271126a8a12Smrg # foo.o: sub/foo.c 272126a8a12Smrg # foo.o: sub/foo.h 273126a8a12Smrg # which is wrong. We want: 274126a8a12Smrg # sub/foo.o: sub/foo.c 275126a8a12Smrg # sub/foo.o: sub/foo.h 276126a8a12Smrg # sub/foo.c: 277126a8a12Smrg # sub/foo.h: 278126a8a12Smrg # ICC 7.1 will output 279126a8a12Smrg # foo.o: sub/foo.c sub/foo.h 280126a8a12Smrg # and will wrap long lines using \ : 281126a8a12Smrg # foo.o: sub/foo.c ... \ 282126a8a12Smrg # sub/foo.h ... \ 283126a8a12Smrg # ... 284126a8a12Smrg 285126a8a12Smrg "$@" -MD -MF "$tmpdepfile" 286126a8a12Smrg stat=$? 287126a8a12Smrg if test $stat -eq 0; then : 288126a8a12Smrg else 289126a8a12Smrg rm -f "$tmpdepfile" 290126a8a12Smrg exit $stat 291126a8a12Smrg fi 292126a8a12Smrg rm -f "$depfile" 293126a8a12Smrg # Each line is of the form `foo.o: dependent.h', 294126a8a12Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295126a8a12Smrg # Do two passes, one to just change these to 296126a8a12Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 297126a8a12Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298126a8a12Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 299126a8a12Smrg # correctly. Breaking it into two sed invocations is a workaround. 300126a8a12Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301126a8a12Smrg sed -e 's/$/ :/' >> "$depfile" 302126a8a12Smrg rm -f "$tmpdepfile" 303126a8a12Smrg ;; 304126a8a12Smrg 305126a8a12Smrghp2) 306126a8a12Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307126a8a12Smrg # compilers, which have integrated preprocessors. The correct option 308126a8a12Smrg # to use with these is +Maked; it writes dependencies to a file named 309126a8a12Smrg # 'foo.d', which lands next to the object file, wherever that 310126a8a12Smrg # happens to be. 311126a8a12Smrg # Much of this is similar to the tru64 case; see comments there. 312126a8a12Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313126a8a12Smrg test "x$dir" = "x$object" && dir= 314126a8a12Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315126a8a12Smrg if test "$libtool" = yes; then 316126a8a12Smrg tmpdepfile1=$dir$base.d 317126a8a12Smrg tmpdepfile2=$dir.libs/$base.d 318126a8a12Smrg "$@" -Wc,+Maked 319126a8a12Smrg else 320126a8a12Smrg tmpdepfile1=$dir$base.d 321126a8a12Smrg tmpdepfile2=$dir$base.d 322126a8a12Smrg "$@" +Maked 323126a8a12Smrg fi 324126a8a12Smrg stat=$? 325126a8a12Smrg if test $stat -eq 0; then : 326126a8a12Smrg else 327126a8a12Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 328126a8a12Smrg exit $stat 329126a8a12Smrg fi 330126a8a12Smrg 331126a8a12Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332126a8a12Smrg do 333126a8a12Smrg test -f "$tmpdepfile" && break 334126a8a12Smrg done 335126a8a12Smrg if test -f "$tmpdepfile"; then 336126a8a12Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337126a8a12Smrg # Add `dependent.h:' lines. 338d656433aSmrg sed -ne '2,${ 339d656433aSmrg s/^ *// 340d656433aSmrg s/ \\*$// 341d656433aSmrg s/$/:/ 342d656433aSmrg p 343d656433aSmrg }' "$tmpdepfile" >> "$depfile" 344126a8a12Smrg else 345126a8a12Smrg echo "#dummy" > "$depfile" 346126a8a12Smrg fi 347126a8a12Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 348126a8a12Smrg ;; 349126a8a12Smrg 350126a8a12Smrgtru64) 351126a8a12Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 352126a8a12Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353126a8a12Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354126a8a12Smrg # dependencies in `foo.d' instead, so we check for that too. 355126a8a12Smrg # Subdirectories are respected. 356126a8a12Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357126a8a12Smrg test "x$dir" = "x$object" && dir= 358126a8a12Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359126a8a12Smrg 360126a8a12Smrg if test "$libtool" = yes; then 361126a8a12Smrg # With Tru64 cc, shared objects can also be used to make a 362126a8a12Smrg # static library. This mechanism is used in libtool 1.4 series to 363126a8a12Smrg # handle both shared and static libraries in a single compilation. 364126a8a12Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365126a8a12Smrg # 366126a8a12Smrg # With libtool 1.5 this exception was removed, and libtool now 367126a8a12Smrg # generates 2 separate objects for the 2 libraries. These two 368126a8a12Smrg # compilations output dependencies in $dir.libs/$base.o.d and 369126a8a12Smrg # in $dir$base.o.d. We have to check for both files, because 370126a8a12Smrg # one of the two compilations can be disabled. We should prefer 371126a8a12Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372126a8a12Smrg # automatically cleaned when .libs/ is deleted, while ignoring 373126a8a12Smrg # the former would cause a distcleancheck panic. 374126a8a12Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375126a8a12Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 376126a8a12Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377126a8a12Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378126a8a12Smrg "$@" -Wc,-MD 379126a8a12Smrg else 380126a8a12Smrg tmpdepfile1=$dir$base.o.d 381126a8a12Smrg tmpdepfile2=$dir$base.d 382126a8a12Smrg tmpdepfile3=$dir$base.d 383126a8a12Smrg tmpdepfile4=$dir$base.d 384126a8a12Smrg "$@" -MD 385126a8a12Smrg fi 386126a8a12Smrg 387126a8a12Smrg stat=$? 388126a8a12Smrg if test $stat -eq 0; then : 389126a8a12Smrg else 390126a8a12Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391126a8a12Smrg exit $stat 392126a8a12Smrg fi 393126a8a12Smrg 394126a8a12Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395126a8a12Smrg do 396126a8a12Smrg test -f "$tmpdepfile" && break 397126a8a12Smrg done 398126a8a12Smrg if test -f "$tmpdepfile"; then 399126a8a12Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400126a8a12Smrg # That's a tab and a space in the []. 401126a8a12Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402126a8a12Smrg else 403126a8a12Smrg echo "#dummy" > "$depfile" 404126a8a12Smrg fi 405126a8a12Smrg rm -f "$tmpdepfile" 406126a8a12Smrg ;; 407126a8a12Smrg 408126a8a12Smrg#nosideeffect) 409126a8a12Smrg # This comment above is used by automake to tell side-effect 410126a8a12Smrg # dependency tracking mechanisms from slower ones. 411126a8a12Smrg 412126a8a12Smrgdashmstdout) 413126a8a12Smrg # Important note: in order to support this mode, a compiler *must* 414126a8a12Smrg # always write the preprocessed file to stdout, regardless of -o. 415126a8a12Smrg "$@" || exit $? 416126a8a12Smrg 417126a8a12Smrg # Remove the call to Libtool. 418126a8a12Smrg if test "$libtool" = yes; then 419d656433aSmrg while test "X$1" != 'X--mode=compile'; do 420126a8a12Smrg shift 421126a8a12Smrg done 422126a8a12Smrg shift 423126a8a12Smrg fi 424126a8a12Smrg 425126a8a12Smrg # Remove `-o $object'. 426126a8a12Smrg IFS=" " 427126a8a12Smrg for arg 428126a8a12Smrg do 429126a8a12Smrg case $arg in 430126a8a12Smrg -o) 431126a8a12Smrg shift 432126a8a12Smrg ;; 433126a8a12Smrg $object) 434126a8a12Smrg shift 435126a8a12Smrg ;; 436126a8a12Smrg *) 437126a8a12Smrg set fnord "$@" "$arg" 438126a8a12Smrg shift # fnord 439126a8a12Smrg shift # $arg 440126a8a12Smrg ;; 441126a8a12Smrg esac 442126a8a12Smrg done 443126a8a12Smrg 444126a8a12Smrg test -z "$dashmflag" && dashmflag=-M 445126a8a12Smrg # Require at least two characters before searching for `:' 446126a8a12Smrg # in the target name. This is to cope with DOS-style filenames: 447126a8a12Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448126a8a12Smrg "$@" $dashmflag | 449126a8a12Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450126a8a12Smrg rm -f "$depfile" 451126a8a12Smrg cat < "$tmpdepfile" > "$depfile" 452126a8a12Smrg tr ' ' ' 453126a8a12Smrg' < "$tmpdepfile" | \ 454126a8a12Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 455126a8a12Smrg## correctly. Breaking it into two sed invocations is a workaround. 456126a8a12Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457126a8a12Smrg rm -f "$tmpdepfile" 458126a8a12Smrg ;; 459126a8a12Smrg 460126a8a12SmrgdashXmstdout) 461126a8a12Smrg # This case only exists to satisfy depend.m4. It is never actually 462126a8a12Smrg # run, as this mode is specially recognized in the preamble. 463126a8a12Smrg exit 1 464126a8a12Smrg ;; 465126a8a12Smrg 466126a8a12Smrgmakedepend) 467126a8a12Smrg "$@" || exit $? 468126a8a12Smrg # Remove any Libtool call 469126a8a12Smrg if test "$libtool" = yes; then 470d656433aSmrg while test "X$1" != 'X--mode=compile'; do 471126a8a12Smrg shift 472126a8a12Smrg done 473126a8a12Smrg shift 474126a8a12Smrg fi 475126a8a12Smrg # X makedepend 476126a8a12Smrg shift 477d656433aSmrg cleared=no eat=no 478d656433aSmrg for arg 479d656433aSmrg do 480126a8a12Smrg case $cleared in 481126a8a12Smrg no) 482126a8a12Smrg set ""; shift 483126a8a12Smrg cleared=yes ;; 484126a8a12Smrg esac 485d656433aSmrg if test $eat = yes; then 486d656433aSmrg eat=no 487d656433aSmrg continue 488d656433aSmrg fi 489126a8a12Smrg case "$arg" in 490126a8a12Smrg -D*|-I*) 491126a8a12Smrg set fnord "$@" "$arg"; shift ;; 492126a8a12Smrg # Strip any option that makedepend may not understand. Remove 493126a8a12Smrg # the object too, otherwise makedepend will parse it as a source file. 494d656433aSmrg -arch) 495d656433aSmrg eat=yes ;; 496126a8a12Smrg -*|$object) 497126a8a12Smrg ;; 498126a8a12Smrg *) 499126a8a12Smrg set fnord "$@" "$arg"; shift ;; 500126a8a12Smrg esac 501126a8a12Smrg done 502d656433aSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 503126a8a12Smrg touch "$tmpdepfile" 504126a8a12Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505126a8a12Smrg rm -f "$depfile" 506126a8a12Smrg cat < "$tmpdepfile" > "$depfile" 507126a8a12Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 508126a8a12Smrg' | \ 509126a8a12Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 510126a8a12Smrg## correctly. Breaking it into two sed invocations is a workaround. 511126a8a12Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512126a8a12Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 513126a8a12Smrg ;; 514126a8a12Smrg 515126a8a12Smrgcpp) 516126a8a12Smrg # Important note: in order to support this mode, a compiler *must* 517126a8a12Smrg # always write the preprocessed file to stdout. 518126a8a12Smrg "$@" || exit $? 519126a8a12Smrg 520126a8a12Smrg # Remove the call to Libtool. 521126a8a12Smrg if test "$libtool" = yes; then 522d656433aSmrg while test "X$1" != 'X--mode=compile'; do 523126a8a12Smrg shift 524126a8a12Smrg done 525126a8a12Smrg shift 526126a8a12Smrg fi 527126a8a12Smrg 528126a8a12Smrg # Remove `-o $object'. 529126a8a12Smrg IFS=" " 530126a8a12Smrg for arg 531126a8a12Smrg do 532126a8a12Smrg case $arg in 533126a8a12Smrg -o) 534126a8a12Smrg shift 535126a8a12Smrg ;; 536126a8a12Smrg $object) 537126a8a12Smrg shift 538126a8a12Smrg ;; 539126a8a12Smrg *) 540126a8a12Smrg set fnord "$@" "$arg" 541126a8a12Smrg shift # fnord 542126a8a12Smrg shift # $arg 543126a8a12Smrg ;; 544126a8a12Smrg esac 545126a8a12Smrg done 546126a8a12Smrg 547126a8a12Smrg "$@" -E | 548126a8a12Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549126a8a12Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550126a8a12Smrg sed '$ s: \\$::' > "$tmpdepfile" 551126a8a12Smrg rm -f "$depfile" 552126a8a12Smrg echo "$object : \\" > "$depfile" 553126a8a12Smrg cat < "$tmpdepfile" >> "$depfile" 554126a8a12Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555126a8a12Smrg rm -f "$tmpdepfile" 556126a8a12Smrg ;; 557126a8a12Smrg 558126a8a12Smrgmsvisualcpp) 559126a8a12Smrg # Important note: in order to support this mode, a compiler *must* 560d656433aSmrg # always write the preprocessed file to stdout. 561126a8a12Smrg "$@" || exit $? 562d656433aSmrg 563d656433aSmrg # Remove the call to Libtool. 564d656433aSmrg if test "$libtool" = yes; then 565d656433aSmrg while test "X$1" != 'X--mode=compile'; do 566d656433aSmrg shift 567d656433aSmrg done 568d656433aSmrg shift 569d656433aSmrg fi 570d656433aSmrg 571126a8a12Smrg IFS=" " 572126a8a12Smrg for arg 573126a8a12Smrg do 574126a8a12Smrg case "$arg" in 575d656433aSmrg -o) 576d656433aSmrg shift 577d656433aSmrg ;; 578d656433aSmrg $object) 579d656433aSmrg shift 580d656433aSmrg ;; 581126a8a12Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582126a8a12Smrg set fnord "$@" 583126a8a12Smrg shift 584126a8a12Smrg shift 585126a8a12Smrg ;; 586126a8a12Smrg *) 587126a8a12Smrg set fnord "$@" "$arg" 588126a8a12Smrg shift 589126a8a12Smrg shift 590126a8a12Smrg ;; 591126a8a12Smrg esac 592126a8a12Smrg done 593d656433aSmrg "$@" -E 2>/dev/null | 594d656433aSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595126a8a12Smrg rm -f "$depfile" 596126a8a12Smrg echo "$object : \\" > "$depfile" 597d656433aSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598126a8a12Smrg echo " " >> "$depfile" 599d656433aSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600126a8a12Smrg rm -f "$tmpdepfile" 601126a8a12Smrg ;; 602126a8a12Smrg 603d656433aSmrgmsvcmsys) 604d656433aSmrg # This case exists only to let depend.m4 do its work. It works by 605d656433aSmrg # looking at the text of this script. This case will never be run, 606d656433aSmrg # since it is checked for above. 607d656433aSmrg exit 1 608d656433aSmrg ;; 609d656433aSmrg 610126a8a12Smrgnone) 611126a8a12Smrg exec "$@" 612126a8a12Smrg ;; 613126a8a12Smrg 614126a8a12Smrg*) 615126a8a12Smrg echo "Unknown depmode $depmode" 1>&2 616126a8a12Smrg exit 1 617126a8a12Smrg ;; 618126a8a12Smrgesac 619126a8a12Smrg 620126a8a12Smrgexit 0 621126a8a12Smrg 622126a8a12Smrg# Local Variables: 623126a8a12Smrg# mode: shell-script 624126a8a12Smrg# sh-indentation: 2 625126a8a12Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 626126a8a12Smrg# time-stamp-start: "scriptversion=" 627126a8a12Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 628d656433aSmrg# time-stamp-time-zone: "UTC" 629d656433aSmrg# time-stamp-end: "; # UTC" 630126a8a12Smrg# End: 631