depcomp revision 988795be
133c89af1Smrg#! /bin/sh 233c89af1Smrg# depcomp - compile a program generating dependencies as side-effects 333c89af1Smrg 4988795beSmrgscriptversion=2011-12-04.11; # UTC 533c89af1Smrg 6988795beSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 7988795beSmrg# 2011 Free Software Foundation, Inc. 833c89af1Smrg 933c89af1Smrg# This program is free software; you can redistribute it and/or modify 1033c89af1Smrg# it under the terms of the GNU General Public License as published by 1133c89af1Smrg# the Free Software Foundation; either version 2, or (at your option) 1233c89af1Smrg# any later version. 1333c89af1Smrg 1433c89af1Smrg# This program is distributed in the hope that it will be useful, 1533c89af1Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1633c89af1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1733c89af1Smrg# GNU General Public License for more details. 1833c89af1Smrg 1933c89af1Smrg# You should have received a copy of the GNU General Public License 20278eca22Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2133c89af1Smrg 2233c89af1Smrg# As a special exception to the GNU General Public License, if you 2333c89af1Smrg# distribute this file as part of a program that contains a 2433c89af1Smrg# configuration script generated by Autoconf, you may include it under 2533c89af1Smrg# the same distribution terms that you use for the rest of that program. 2633c89af1Smrg 2733c89af1Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2833c89af1Smrg 2933c89af1Smrgcase $1 in 3033c89af1Smrg '') 3133c89af1Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3233c89af1Smrg exit 1; 3333c89af1Smrg ;; 3433c89af1Smrg -h | --h*) 3533c89af1Smrg cat <<\EOF 3633c89af1SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3733c89af1Smrg 3833c89af1SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3933c89af1Smrgas side-effects. 4033c89af1Smrg 4133c89af1SmrgEnvironment variables: 4233c89af1Smrg depmode Dependency tracking mode. 4333c89af1Smrg source Source file read by `PROGRAMS ARGS'. 4433c89af1Smrg object Object file output by `PROGRAMS ARGS'. 4533c89af1Smrg DEPDIR directory where to store dependencies. 4633c89af1Smrg depfile Dependency file to output. 47988795beSmrg tmpdepfile Temporary file to use when outputting dependencies. 4833c89af1Smrg libtool Whether libtool is used (yes/no). 4933c89af1Smrg 5033c89af1SmrgReport bugs to <bug-automake@gnu.org>. 5133c89af1SmrgEOF 5233c89af1Smrg exit $? 5333c89af1Smrg ;; 5433c89af1Smrg -v | --v*) 5533c89af1Smrg echo "depcomp $scriptversion" 5633c89af1Smrg exit $? 5733c89af1Smrg ;; 5833c89af1Smrgesac 5933c89af1Smrg 6033c89af1Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6133c89af1Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6233c89af1Smrg exit 1 6333c89af1Smrgfi 6433c89af1Smrg 6533c89af1Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6633c89af1Smrgdepfile=${depfile-`echo "$object" | 6733c89af1Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6833c89af1Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 6933c89af1Smrg 7033c89af1Smrgrm -f "$tmpdepfile" 7133c89af1Smrg 7233c89af1Smrg# Some modes work just like other modes, but use different flags. We 7333c89af1Smrg# parameterize here, but still list the modes in the big case below, 7433c89af1Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7533c89af1Smrg# here, because this file can only contain one case statement. 7633c89af1Smrgif test "$depmode" = hp; then 7733c89af1Smrg # HP compiler uses -M and no extra arg. 7833c89af1Smrg gccflag=-M 7933c89af1Smrg depmode=gcc 8033c89af1Smrgfi 8133c89af1Smrg 8233c89af1Smrgif test "$depmode" = dashXmstdout; then 8333c89af1Smrg # This is just like dashmstdout with a different argument. 8433c89af1Smrg dashmflag=-xM 8533c89af1Smrg depmode=dashmstdout 8633c89af1Smrgfi 8733c89af1Smrg 88278eca22Smrgcygpath_u="cygpath -u -f -" 89278eca22Smrgif test "$depmode" = msvcmsys; then 90278eca22Smrg # This is just like msvisualcpp but w/o cygpath translation. 91278eca22Smrg # Just convert the backslash-escaped backslashes to single forward 92278eca22Smrg # slashes to satisfy depend.m4 93988795beSmrg cygpath_u='sed s,\\\\,/,g' 94278eca22Smrg depmode=msvisualcpp 95278eca22Smrgfi 96278eca22Smrg 97988795beSmrgif test "$depmode" = msvc7msys; then 98988795beSmrg # This is just like msvc7 but w/o cygpath translation. 99988795beSmrg # Just convert the backslash-escaped backslashes to single forward 100988795beSmrg # slashes to satisfy depend.m4 101988795beSmrg cygpath_u='sed s,\\\\,/,g' 102988795beSmrg depmode=msvc7 103988795beSmrgfi 104988795beSmrg 10533c89af1Smrgcase "$depmode" in 10633c89af1Smrggcc3) 10733c89af1Smrg## gcc 3 implements dependency tracking that does exactly what 10833c89af1Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 10933c89af1Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 110278eca22Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 111278eca22Smrg## the command line argument order; so add the flags where they 112278eca22Smrg## appear in depend2.am. Note that the slowdown incurred here 113278eca22Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 114278eca22Smrg for arg 115278eca22Smrg do 116278eca22Smrg case $arg in 117278eca22Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 118278eca22Smrg *) set fnord "$@" "$arg" ;; 119278eca22Smrg esac 120278eca22Smrg shift # fnord 121278eca22Smrg shift # $arg 122278eca22Smrg done 123278eca22Smrg "$@" 12433c89af1Smrg stat=$? 12533c89af1Smrg if test $stat -eq 0; then : 12633c89af1Smrg else 12733c89af1Smrg rm -f "$tmpdepfile" 12833c89af1Smrg exit $stat 12933c89af1Smrg fi 13033c89af1Smrg mv "$tmpdepfile" "$depfile" 13133c89af1Smrg ;; 13233c89af1Smrg 13333c89af1Smrggcc) 13433c89af1Smrg## There are various ways to get dependency output from gcc. Here's 13533c89af1Smrg## why we pick this rather obscure method: 13633c89af1Smrg## - Don't want to use -MD because we'd like the dependencies to end 13733c89af1Smrg## up in a subdir. Having to rename by hand is ugly. 13833c89af1Smrg## (We might end up doing this anyway to support other compilers.) 13933c89af1Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 14033c89af1Smrg## -MM, not -M (despite what the docs say). 14133c89af1Smrg## - Using -M directly means running the compiler twice (even worse 14233c89af1Smrg## than renaming). 14333c89af1Smrg if test -z "$gccflag"; then 14433c89af1Smrg gccflag=-MD, 14533c89af1Smrg fi 14633c89af1Smrg "$@" -Wp,"$gccflag$tmpdepfile" 14733c89af1Smrg stat=$? 14833c89af1Smrg if test $stat -eq 0; then : 14933c89af1Smrg else 15033c89af1Smrg rm -f "$tmpdepfile" 15133c89af1Smrg exit $stat 15233c89af1Smrg fi 15333c89af1Smrg rm -f "$depfile" 15433c89af1Smrg echo "$object : \\" > "$depfile" 15533c89af1Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 15633c89af1Smrg## The second -e expression handles DOS-style file names with drive letters. 15733c89af1Smrg sed -e 's/^[^:]*: / /' \ 15833c89af1Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 15933c89af1Smrg## This next piece of magic avoids the `deleted header file' problem. 16033c89af1Smrg## The problem is that when a header file which appears in a .P file 16133c89af1Smrg## is deleted, the dependency causes make to die (because there is 16233c89af1Smrg## typically no way to rebuild the header). We avoid this by adding 16333c89af1Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 16433c89af1Smrg## this for us directly. 16533c89af1Smrg tr ' ' ' 16633c89af1Smrg' < "$tmpdepfile" | 16733c89af1Smrg## Some versions of gcc put a space before the `:'. On the theory 16833c89af1Smrg## that the space means something, we add a space to the output as 169988795beSmrg## well. hp depmode also adds that space, but also prefixes the VPATH 170988795beSmrg## to the object. Take care to not repeat it in the output. 17133c89af1Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 17233c89af1Smrg## correctly. Breaking it into two sed invocations is a workaround. 173988795beSmrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 174988795beSmrg | sed -e 's/$/ :/' >> "$depfile" 17533c89af1Smrg rm -f "$tmpdepfile" 17633c89af1Smrg ;; 17733c89af1Smrg 17833c89af1Smrghp) 17933c89af1Smrg # This case exists only to let depend.m4 do its work. It works by 18033c89af1Smrg # looking at the text of this script. This case will never be run, 18133c89af1Smrg # since it is checked for above. 18233c89af1Smrg exit 1 18333c89af1Smrg ;; 18433c89af1Smrg 18533c89af1Smrgsgi) 18633c89af1Smrg if test "$libtool" = yes; then 18733c89af1Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 18833c89af1Smrg else 18933c89af1Smrg "$@" -MDupdate "$tmpdepfile" 19033c89af1Smrg fi 19133c89af1Smrg stat=$? 19233c89af1Smrg if test $stat -eq 0; then : 19333c89af1Smrg else 19433c89af1Smrg rm -f "$tmpdepfile" 19533c89af1Smrg exit $stat 19633c89af1Smrg fi 19733c89af1Smrg rm -f "$depfile" 19833c89af1Smrg 19933c89af1Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 20033c89af1Smrg echo "$object : \\" > "$depfile" 20133c89af1Smrg 20233c89af1Smrg # Clip off the initial element (the dependent). Don't try to be 20333c89af1Smrg # clever and replace this with sed code, as IRIX sed won't handle 20433c89af1Smrg # lines with more than a fixed number of characters (4096 in 20533c89af1Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 20633c89af1Smrg # the IRIX cc adds comments like `#:fec' to the end of the 20733c89af1Smrg # dependency line. 20833c89af1Smrg tr ' ' ' 20933c89af1Smrg' < "$tmpdepfile" \ 21033c89af1Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 21133c89af1Smrg tr ' 212278eca22Smrg' ' ' >> "$depfile" 213278eca22Smrg echo >> "$depfile" 21433c89af1Smrg 21533c89af1Smrg # The second pass generates a dummy entry for each header file. 21633c89af1Smrg tr ' ' ' 21733c89af1Smrg' < "$tmpdepfile" \ 21833c89af1Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 219278eca22Smrg >> "$depfile" 22033c89af1Smrg else 22133c89af1Smrg # The sourcefile does not contain any dependencies, so just 22233c89af1Smrg # store a dummy comment line, to avoid errors with the Makefile 22333c89af1Smrg # "include basename.Plo" scheme. 22433c89af1Smrg echo "#dummy" > "$depfile" 22533c89af1Smrg fi 22633c89af1Smrg rm -f "$tmpdepfile" 22733c89af1Smrg ;; 22833c89af1Smrg 22933c89af1Smrgaix) 23033c89af1Smrg # The C for AIX Compiler uses -M and outputs the dependencies 23133c89af1Smrg # in a .u file. In older versions, this file always lives in the 23233c89af1Smrg # current directory. Also, the AIX compiler puts `$object:' at the 23333c89af1Smrg # start of each line; $object doesn't have directory information. 23433c89af1Smrg # Version 6 uses the directory in both cases. 235278eca22Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 236278eca22Smrg test "x$dir" = "x$object" && dir= 237278eca22Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 23833c89af1Smrg if test "$libtool" = yes; then 239278eca22Smrg tmpdepfile1=$dir$base.u 240278eca22Smrg tmpdepfile2=$base.u 241278eca22Smrg tmpdepfile3=$dir.libs/$base.u 24233c89af1Smrg "$@" -Wc,-M 24333c89af1Smrg else 244278eca22Smrg tmpdepfile1=$dir$base.u 245278eca22Smrg tmpdepfile2=$dir$base.u 246278eca22Smrg tmpdepfile3=$dir$base.u 24733c89af1Smrg "$@" -M 24833c89af1Smrg fi 24933c89af1Smrg stat=$? 25033c89af1Smrg 25133c89af1Smrg if test $stat -eq 0; then : 25233c89af1Smrg else 253278eca22Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 25433c89af1Smrg exit $stat 25533c89af1Smrg fi 25633c89af1Smrg 257278eca22Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 258278eca22Smrg do 259278eca22Smrg test -f "$tmpdepfile" && break 260278eca22Smrg done 26133c89af1Smrg if test -f "$tmpdepfile"; then 26233c89af1Smrg # Each line is of the form `foo.o: dependent.h'. 26333c89af1Smrg # Do two passes, one to just change these to 26433c89af1Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 265278eca22Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 266278eca22Smrg # That's a tab and a space in the []. 267278eca22Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 26833c89af1Smrg else 26933c89af1Smrg # The sourcefile does not contain any dependencies, so just 27033c89af1Smrg # store a dummy comment line, to avoid errors with the Makefile 27133c89af1Smrg # "include basename.Plo" scheme. 27233c89af1Smrg echo "#dummy" > "$depfile" 27333c89af1Smrg fi 27433c89af1Smrg rm -f "$tmpdepfile" 27533c89af1Smrg ;; 27633c89af1Smrg 27733c89af1Smrgicc) 27833c89af1Smrg # Intel's C compiler understands `-MD -MF file'. However on 27933c89af1Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 28033c89af1Smrg # ICC 7.0 will fill foo.d with something like 28133c89af1Smrg # foo.o: sub/foo.c 28233c89af1Smrg # foo.o: sub/foo.h 28333c89af1Smrg # which is wrong. We want: 28433c89af1Smrg # sub/foo.o: sub/foo.c 28533c89af1Smrg # sub/foo.o: sub/foo.h 28633c89af1Smrg # sub/foo.c: 28733c89af1Smrg # sub/foo.h: 28833c89af1Smrg # ICC 7.1 will output 28933c89af1Smrg # foo.o: sub/foo.c sub/foo.h 29033c89af1Smrg # and will wrap long lines using \ : 29133c89af1Smrg # foo.o: sub/foo.c ... \ 29233c89af1Smrg # sub/foo.h ... \ 29333c89af1Smrg # ... 29433c89af1Smrg 29533c89af1Smrg "$@" -MD -MF "$tmpdepfile" 29633c89af1Smrg stat=$? 29733c89af1Smrg if test $stat -eq 0; then : 29833c89af1Smrg else 29933c89af1Smrg rm -f "$tmpdepfile" 30033c89af1Smrg exit $stat 30133c89af1Smrg fi 30233c89af1Smrg rm -f "$depfile" 30333c89af1Smrg # Each line is of the form `foo.o: dependent.h', 30433c89af1Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 30533c89af1Smrg # Do two passes, one to just change these to 30633c89af1Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 30733c89af1Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 30833c89af1Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 30933c89af1Smrg # correctly. Breaking it into two sed invocations is a workaround. 31033c89af1Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 31133c89af1Smrg sed -e 's/$/ :/' >> "$depfile" 31233c89af1Smrg rm -f "$tmpdepfile" 31333c89af1Smrg ;; 31433c89af1Smrg 315278eca22Smrghp2) 316278eca22Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 317278eca22Smrg # compilers, which have integrated preprocessors. The correct option 318278eca22Smrg # to use with these is +Maked; it writes dependencies to a file named 319278eca22Smrg # 'foo.d', which lands next to the object file, wherever that 320278eca22Smrg # happens to be. 321278eca22Smrg # Much of this is similar to the tru64 case; see comments there. 322278eca22Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 323278eca22Smrg test "x$dir" = "x$object" && dir= 324278eca22Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 325278eca22Smrg if test "$libtool" = yes; then 326278eca22Smrg tmpdepfile1=$dir$base.d 327278eca22Smrg tmpdepfile2=$dir.libs/$base.d 328278eca22Smrg "$@" -Wc,+Maked 329278eca22Smrg else 330278eca22Smrg tmpdepfile1=$dir$base.d 331278eca22Smrg tmpdepfile2=$dir$base.d 332278eca22Smrg "$@" +Maked 333278eca22Smrg fi 334278eca22Smrg stat=$? 335278eca22Smrg if test $stat -eq 0; then : 336278eca22Smrg else 337278eca22Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 338278eca22Smrg exit $stat 339278eca22Smrg fi 340278eca22Smrg 341278eca22Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 342278eca22Smrg do 343278eca22Smrg test -f "$tmpdepfile" && break 344278eca22Smrg done 345278eca22Smrg if test -f "$tmpdepfile"; then 346278eca22Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 347278eca22Smrg # Add `dependent.h:' lines. 348278eca22Smrg sed -ne '2,${ 349278eca22Smrg s/^ *// 350278eca22Smrg s/ \\*$// 351278eca22Smrg s/$/:/ 352278eca22Smrg p 353278eca22Smrg }' "$tmpdepfile" >> "$depfile" 354278eca22Smrg else 355278eca22Smrg echo "#dummy" > "$depfile" 356278eca22Smrg fi 357278eca22Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 358278eca22Smrg ;; 359278eca22Smrg 36033c89af1Smrgtru64) 36133c89af1Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 36233c89af1Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 36333c89af1Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 36433c89af1Smrg # dependencies in `foo.d' instead, so we check for that too. 36533c89af1Smrg # Subdirectories are respected. 36633c89af1Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 36733c89af1Smrg test "x$dir" = "x$object" && dir= 36833c89af1Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 36933c89af1Smrg 37033c89af1Smrg if test "$libtool" = yes; then 37133c89af1Smrg # With Tru64 cc, shared objects can also be used to make a 372278eca22Smrg # static library. This mechanism is used in libtool 1.4 series to 37333c89af1Smrg # handle both shared and static libraries in a single compilation. 37433c89af1Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 37533c89af1Smrg # 37633c89af1Smrg # With libtool 1.5 this exception was removed, and libtool now 37733c89af1Smrg # generates 2 separate objects for the 2 libraries. These two 378278eca22Smrg # compilations output dependencies in $dir.libs/$base.o.d and 37933c89af1Smrg # in $dir$base.o.d. We have to check for both files, because 38033c89af1Smrg # one of the two compilations can be disabled. We should prefer 38133c89af1Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 38233c89af1Smrg # automatically cleaned when .libs/ is deleted, while ignoring 38333c89af1Smrg # the former would cause a distcleancheck panic. 38433c89af1Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 38533c89af1Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 38633c89af1Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 38733c89af1Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 38833c89af1Smrg "$@" -Wc,-MD 38933c89af1Smrg else 39033c89af1Smrg tmpdepfile1=$dir$base.o.d 39133c89af1Smrg tmpdepfile2=$dir$base.d 39233c89af1Smrg tmpdepfile3=$dir$base.d 39333c89af1Smrg tmpdepfile4=$dir$base.d 39433c89af1Smrg "$@" -MD 39533c89af1Smrg fi 39633c89af1Smrg 39733c89af1Smrg stat=$? 39833c89af1Smrg if test $stat -eq 0; then : 39933c89af1Smrg else 40033c89af1Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40133c89af1Smrg exit $stat 40233c89af1Smrg fi 40333c89af1Smrg 40433c89af1Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40533c89af1Smrg do 40633c89af1Smrg test -f "$tmpdepfile" && break 40733c89af1Smrg done 40833c89af1Smrg if test -f "$tmpdepfile"; then 40933c89af1Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 41033c89af1Smrg # That's a tab and a space in the []. 41133c89af1Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 41233c89af1Smrg else 41333c89af1Smrg echo "#dummy" > "$depfile" 41433c89af1Smrg fi 41533c89af1Smrg rm -f "$tmpdepfile" 41633c89af1Smrg ;; 41733c89af1Smrg 418988795beSmrgmsvc7) 419988795beSmrg if test "$libtool" = yes; then 420988795beSmrg showIncludes=-Wc,-showIncludes 421988795beSmrg else 422988795beSmrg showIncludes=-showIncludes 423988795beSmrg fi 424988795beSmrg "$@" $showIncludes > "$tmpdepfile" 425988795beSmrg stat=$? 426988795beSmrg grep -v '^Note: including file: ' "$tmpdepfile" 427988795beSmrg if test "$stat" = 0; then : 428988795beSmrg else 429988795beSmrg rm -f "$tmpdepfile" 430988795beSmrg exit $stat 431988795beSmrg fi 432988795beSmrg rm -f "$depfile" 433988795beSmrg echo "$object : \\" > "$depfile" 434988795beSmrg # The first sed program below extracts the file names and escapes 435988795beSmrg # backslashes for cygpath. The second sed program outputs the file 436988795beSmrg # name when reading, but also accumulates all include files in the 437988795beSmrg # hold buffer in order to output them again at the end. This only 438988795beSmrg # works with sed implementations that can handle large buffers. 439988795beSmrg sed < "$tmpdepfile" -n ' 440988795beSmrg/^Note: including file: *\(.*\)/ { 441988795beSmrg s//\1/ 442988795beSmrg s/\\/\\\\/g 443988795beSmrg p 444988795beSmrg}' | $cygpath_u | sort -u | sed -n ' 445988795beSmrgs/ /\\ /g 446988795beSmrgs/\(.*\)/ \1 \\/p 447988795beSmrgs/.\(.*\) \\/\1:/ 448988795beSmrgH 449988795beSmrg$ { 450988795beSmrg s/.*/ / 451988795beSmrg G 452988795beSmrg p 453988795beSmrg}' >> "$depfile" 454988795beSmrg rm -f "$tmpdepfile" 455988795beSmrg ;; 456988795beSmrg 457988795beSmrgmsvc7msys) 458988795beSmrg # This case exists only to let depend.m4 do its work. It works by 459988795beSmrg # looking at the text of this script. This case will never be run, 460988795beSmrg # since it is checked for above. 461988795beSmrg exit 1 462988795beSmrg ;; 463988795beSmrg 46433c89af1Smrg#nosideeffect) 46533c89af1Smrg # This comment above is used by automake to tell side-effect 46633c89af1Smrg # dependency tracking mechanisms from slower ones. 46733c89af1Smrg 46833c89af1Smrgdashmstdout) 46933c89af1Smrg # Important note: in order to support this mode, a compiler *must* 47033c89af1Smrg # always write the preprocessed file to stdout, regardless of -o. 47133c89af1Smrg "$@" || exit $? 47233c89af1Smrg 47333c89af1Smrg # Remove the call to Libtool. 47433c89af1Smrg if test "$libtool" = yes; then 475278eca22Smrg while test "X$1" != 'X--mode=compile'; do 47633c89af1Smrg shift 47733c89af1Smrg done 47833c89af1Smrg shift 47933c89af1Smrg fi 48033c89af1Smrg 48133c89af1Smrg # Remove `-o $object'. 48233c89af1Smrg IFS=" " 48333c89af1Smrg for arg 48433c89af1Smrg do 48533c89af1Smrg case $arg in 48633c89af1Smrg -o) 48733c89af1Smrg shift 48833c89af1Smrg ;; 48933c89af1Smrg $object) 49033c89af1Smrg shift 49133c89af1Smrg ;; 49233c89af1Smrg *) 49333c89af1Smrg set fnord "$@" "$arg" 49433c89af1Smrg shift # fnord 49533c89af1Smrg shift # $arg 49633c89af1Smrg ;; 49733c89af1Smrg esac 49833c89af1Smrg done 49933c89af1Smrg 50033c89af1Smrg test -z "$dashmflag" && dashmflag=-M 50133c89af1Smrg # Require at least two characters before searching for `:' 50233c89af1Smrg # in the target name. This is to cope with DOS-style filenames: 50333c89af1Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 50433c89af1Smrg "$@" $dashmflag | 50533c89af1Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 50633c89af1Smrg rm -f "$depfile" 50733c89af1Smrg cat < "$tmpdepfile" > "$depfile" 50833c89af1Smrg tr ' ' ' 50933c89af1Smrg' < "$tmpdepfile" | \ 51033c89af1Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 51133c89af1Smrg## correctly. Breaking it into two sed invocations is a workaround. 51233c89af1Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 51333c89af1Smrg rm -f "$tmpdepfile" 51433c89af1Smrg ;; 51533c89af1Smrg 51633c89af1SmrgdashXmstdout) 51733c89af1Smrg # This case only exists to satisfy depend.m4. It is never actually 51833c89af1Smrg # run, as this mode is specially recognized in the preamble. 51933c89af1Smrg exit 1 52033c89af1Smrg ;; 52133c89af1Smrg 52233c89af1Smrgmakedepend) 52333c89af1Smrg "$@" || exit $? 52433c89af1Smrg # Remove any Libtool call 52533c89af1Smrg if test "$libtool" = yes; then 526278eca22Smrg while test "X$1" != 'X--mode=compile'; do 52733c89af1Smrg shift 52833c89af1Smrg done 52933c89af1Smrg shift 53033c89af1Smrg fi 53133c89af1Smrg # X makedepend 53233c89af1Smrg shift 533278eca22Smrg cleared=no eat=no 534278eca22Smrg for arg 535278eca22Smrg do 53633c89af1Smrg case $cleared in 53733c89af1Smrg no) 53833c89af1Smrg set ""; shift 53933c89af1Smrg cleared=yes ;; 54033c89af1Smrg esac 541278eca22Smrg if test $eat = yes; then 542278eca22Smrg eat=no 543278eca22Smrg continue 544278eca22Smrg fi 54533c89af1Smrg case "$arg" in 54633c89af1Smrg -D*|-I*) 54733c89af1Smrg set fnord "$@" "$arg"; shift ;; 54833c89af1Smrg # Strip any option that makedepend may not understand. Remove 54933c89af1Smrg # the object too, otherwise makedepend will parse it as a source file. 550278eca22Smrg -arch) 551278eca22Smrg eat=yes ;; 55233c89af1Smrg -*|$object) 55333c89af1Smrg ;; 55433c89af1Smrg *) 55533c89af1Smrg set fnord "$@" "$arg"; shift ;; 55633c89af1Smrg esac 55733c89af1Smrg done 558278eca22Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 55933c89af1Smrg touch "$tmpdepfile" 56033c89af1Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 56133c89af1Smrg rm -f "$depfile" 562988795beSmrg # makedepend may prepend the VPATH from the source file name to the object. 563988795beSmrg # No need to regex-escape $object, excess matching of '.' is harmless. 564988795beSmrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 56533c89af1Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 56633c89af1Smrg' | \ 56733c89af1Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 56833c89af1Smrg## correctly. Breaking it into two sed invocations is a workaround. 56933c89af1Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 57033c89af1Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 57133c89af1Smrg ;; 57233c89af1Smrg 57333c89af1Smrgcpp) 57433c89af1Smrg # Important note: in order to support this mode, a compiler *must* 57533c89af1Smrg # always write the preprocessed file to stdout. 57633c89af1Smrg "$@" || exit $? 57733c89af1Smrg 57833c89af1Smrg # Remove the call to Libtool. 57933c89af1Smrg if test "$libtool" = yes; then 580278eca22Smrg while test "X$1" != 'X--mode=compile'; do 58133c89af1Smrg shift 58233c89af1Smrg done 58333c89af1Smrg shift 58433c89af1Smrg fi 58533c89af1Smrg 58633c89af1Smrg # Remove `-o $object'. 58733c89af1Smrg IFS=" " 58833c89af1Smrg for arg 58933c89af1Smrg do 59033c89af1Smrg case $arg in 59133c89af1Smrg -o) 59233c89af1Smrg shift 59333c89af1Smrg ;; 59433c89af1Smrg $object) 59533c89af1Smrg shift 59633c89af1Smrg ;; 59733c89af1Smrg *) 59833c89af1Smrg set fnord "$@" "$arg" 59933c89af1Smrg shift # fnord 60033c89af1Smrg shift # $arg 60133c89af1Smrg ;; 60233c89af1Smrg esac 60333c89af1Smrg done 60433c89af1Smrg 60533c89af1Smrg "$@" -E | 60633c89af1Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 60733c89af1Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 60833c89af1Smrg sed '$ s: \\$::' > "$tmpdepfile" 60933c89af1Smrg rm -f "$depfile" 61033c89af1Smrg echo "$object : \\" > "$depfile" 61133c89af1Smrg cat < "$tmpdepfile" >> "$depfile" 61233c89af1Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 61333c89af1Smrg rm -f "$tmpdepfile" 61433c89af1Smrg ;; 61533c89af1Smrg 61633c89af1Smrgmsvisualcpp) 61733c89af1Smrg # Important note: in order to support this mode, a compiler *must* 618278eca22Smrg # always write the preprocessed file to stdout. 61933c89af1Smrg "$@" || exit $? 620278eca22Smrg 621278eca22Smrg # Remove the call to Libtool. 622278eca22Smrg if test "$libtool" = yes; then 623278eca22Smrg while test "X$1" != 'X--mode=compile'; do 624278eca22Smrg shift 625278eca22Smrg done 626278eca22Smrg shift 627278eca22Smrg fi 628278eca22Smrg 62933c89af1Smrg IFS=" " 63033c89af1Smrg for arg 63133c89af1Smrg do 63233c89af1Smrg case "$arg" in 633278eca22Smrg -o) 634278eca22Smrg shift 635278eca22Smrg ;; 636278eca22Smrg $object) 637278eca22Smrg shift 638278eca22Smrg ;; 63933c89af1Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 64033c89af1Smrg set fnord "$@" 64133c89af1Smrg shift 64233c89af1Smrg shift 64333c89af1Smrg ;; 64433c89af1Smrg *) 64533c89af1Smrg set fnord "$@" "$arg" 64633c89af1Smrg shift 64733c89af1Smrg shift 64833c89af1Smrg ;; 64933c89af1Smrg esac 65033c89af1Smrg done 651278eca22Smrg "$@" -E 2>/dev/null | 652278eca22Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 65333c89af1Smrg rm -f "$depfile" 65433c89af1Smrg echo "$object : \\" > "$depfile" 655278eca22Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 65633c89af1Smrg echo " " >> "$depfile" 657278eca22Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 65833c89af1Smrg rm -f "$tmpdepfile" 65933c89af1Smrg ;; 66033c89af1Smrg 661278eca22Smrgmsvcmsys) 662278eca22Smrg # This case exists only to let depend.m4 do its work. It works by 663278eca22Smrg # looking at the text of this script. This case will never be run, 664278eca22Smrg # since it is checked for above. 665278eca22Smrg exit 1 666278eca22Smrg ;; 667278eca22Smrg 66833c89af1Smrgnone) 66933c89af1Smrg exec "$@" 67033c89af1Smrg ;; 67133c89af1Smrg 67233c89af1Smrg*) 67333c89af1Smrg echo "Unknown depmode $depmode" 1>&2 67433c89af1Smrg exit 1 67533c89af1Smrg ;; 67633c89af1Smrgesac 67733c89af1Smrg 67833c89af1Smrgexit 0 67933c89af1Smrg 68033c89af1Smrg# Local Variables: 68133c89af1Smrg# mode: shell-script 68233c89af1Smrg# sh-indentation: 2 68333c89af1Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 68433c89af1Smrg# time-stamp-start: "scriptversion=" 68533c89af1Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 686278eca22Smrg# time-stamp-time-zone: "UTC" 687278eca22Smrg# time-stamp-end: "; # UTC" 68833c89af1Smrg# End: 689