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