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