depcomp revision a747113422afaa29ce72d2c5ba7f0b7ea9ec2054
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# depcomp - compile a program generating dependencies as side-effects
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# Copyright (C) 1999-2012 Free Software Foundation, Inc.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# This program is free software; you can redistribute it and/or modify
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# it under the terms of the GNU General Public License as published by
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# the Free Software Foundation; either version 2, or (at your option)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# any later version.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# This program is distributed in the hope that it will be useful,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# but WITHOUT ANY WARRANTY; without even the implied warranty of
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# GNU General Public License for more details.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# You should have received a copy of the GNU General Public License
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# along with this program. If not, see <http://www.gnu.org/licenses/>.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# As a special exception to the GNU General Public License, if you
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# distribute this file as part of a program that contains a
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# configuration script generated by Autoconf, you may include it under
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# the same distribution terms that you use for the rest of that program.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt echo "$0: No command. Try '$0 --help' for more information." 1>&2
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntRun PROGRAMS ARGS to compile a file, generating dependencies
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt tmpdepfile Temporary file to use when outputting dependencies.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt echo "depcomp $scriptversion"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# A tabulation character.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# A newline character.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntif test -z "$depmode" || test -z "$source" || test -z "$object"; then
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt echo "depcomp: Variables source, object and depmode must be set" 1>&2
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunttmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Some modes work just like other modes, but use different flags. We
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# parameterize here, but still list the modes in the big case below,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# to make depend.m4 easier to write. Note that we *cannot* use a case
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# here, because this file can only contain one case statement.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # HP compiler uses -M and no extra arg.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # This is just like dashmstdout with a different argument.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # This is just like msvisualcpp but w/o cygpath translation.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Just convert the backslash-escaped backslashes to single forward
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # slashes to satisfy depend.m4
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # This is just like msvc7 but w/o cygpath translation.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # Just convert the backslash-escaped backslashes to single forward
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # slashes to satisfy depend.m4
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## gcc 3 implements dependency tracking that does exactly what
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## we want. Yay! Note: for some reason libtool 1.4 doesn't like
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## it if -MD -MP comes after the -MF stuff. Hmm.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## Unfortunately, FreeBSD c89 acceptance of flags depends upon
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## the command line argument order; so add the flags where they
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## appear in depend2.am. Note that the slowdown incurred here
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## affects only configure: in makefiles, %FASTDEP% shortcuts this.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt shift # fnord
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt shift # $arg
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## There are various ways to get dependency output from gcc. Here's
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## why we pick this rather obscure method:
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## - Don't want to use -MD because we'd like the dependencies to end
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## up in a subdir. Having to rename by hand is ugly.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## (We might end up doing this anyway to support other compilers.)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## -MM, not -M (despite what the docs say).
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## - Using -M directly means running the compiler twice (even worse
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## than renaming).
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if test -z "$gccflag"; then
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## The second -e expression handles DOS-style file names with drive letters.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt## This next piece of magic avoids the "deleted header file" problem.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## The problem is that when a header file which appears in a .P file
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## is deleted, the dependency causes make to die (because there is
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## typically no way to rebuild the header). We avoid this by adding
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## dummy dependencies for each header file. Too bad gcc doesn't do
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## this for us directly.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt## Some versions of gcc put a space before the ':'. On the theory
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## that the space means something, we add a space to the output as
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt## well. hp depmode also adds that space, but also prefixes the VPATH
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt## to the object. Take care to not repeat it in the output.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## Some versions of the HPUX 10.20 sed can't process this invocation
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## correctly. Breaking it into two sed invocations is a workaround.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # This case exists only to let depend.m4 do its work. It works by
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # looking at the text of this script. This case will never be run,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # since it is checked for above.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "$@" "-Wp,-MDupdate,$tmpdepfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Clip off the initial element (the dependent). Don't try to be
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # clever and replace this with sed code, as IRIX sed won't handle
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # lines with more than a fixed number of characters (4096 in
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # the IRIX cc adds comments like '#:fec' to the end of the
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # dependency line.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # The second pass generates a dummy entry for each header file.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # The sourcefile does not contain any dependencies, so just
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # store a dummy comment line, to avoid errors with the Makefile
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # "include basename.Plo" scheme.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # This case exists only to let depend.m4 do its work. It works by
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # looking at the text of this script. This case will never be run,
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # since it is checked for above.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # The C for AIX Compiler uses -M and outputs the dependencies
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # in a .u file. In older versions, this file always lives in the
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # current directory. Also, the AIX compiler puts '$object:' at the
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # start of each line; $object doesn't have directory information.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Version 6 uses the directory in both cases.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt test -f "$tmpdepfile" && break
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if test -f "$tmpdepfile"; then
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # Each line is of the form 'foo.o: dependent.h'.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Do two passes, one to just change these to
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # '$object: dependent.h' and one to simply 'dependent.h:'.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # The sourcefile does not contain any dependencies, so just
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # store a dummy comment line, to avoid errors with the Makefile
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # "include basename.Plo" scheme.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # However on
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # ICC 7.0 will fill foo.d with something like
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # which is wrong. We want
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # ICC 7.1 will output
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # and will wrap long lines using '\':
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # tcc 0.9.26 (FIXME still under development at the moment of writing)
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # will emit a similar output, but also prepend the continuation lines
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # with horizontal tabulation characters.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # Each line is of the form 'foo.o: dependent.h',
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Do two passes, one to just change these to
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # '$object: dependent.h' and one to simply 'dependent.h:'.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt s/^[^:]*: *//
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # The "hp" stanza above does not work with aCC (C++) and HP's ia64
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # compilers, which have integrated preprocessors. The correct option
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # to use with these is +Maked; it writes dependencies to a file named
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # 'foo.d', which lands next to the object file, wherever that
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # happens to be.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Much of this is similar to the tru64 case; see comments there.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt test -f "$tmpdepfile" && break
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if test -f "$tmpdepfile"; then
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # Add 'dependent.h:' lines.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # The Tru64 compiler uses -MD to generate dependencies as a side
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # dependencies in 'foo.d' instead, so we check for that too.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Subdirectories are respected.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # With Tru64 cc, shared objects can also be used to make a
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # static library. This mechanism is used in libtool 1.4 series to
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # handle both shared and static libraries in a single compilation.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # With libtool 1.5 this exception was removed, and libtool now
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # generates 2 separate objects for the 2 libraries. These two
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # compilations output dependencies in $dir.libs/$base.o.d and
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # in $dir$base.o.d. We have to check for both files, because
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # one of the two compilations can be disabled. We should prefer
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # automatically cleaned when .libs/ is deleted, while ignoring
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # the former would cause a distcleancheck panic.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt test -f "$tmpdepfile" && break
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if test -f "$tmpdepfile"; then
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # The first sed program below extracts the file names and escapes
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # backslashes for cygpath. The second sed program outputs the file
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # name when reading, but also accumulates all include files in the
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # hold buffer in order to output them again at the end. This only
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # works with sed implementations that can handle large buffers.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt/^Note: including file: *\(.*\)/ {
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunts/.\(.*\) \\/\1:/
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # This case exists only to let depend.m4 do its work. It works by
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # looking at the text of this script. This case will never be run,
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # since it is checked for above.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#nosideeffect)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # This comment above is used by automake to tell side-effect
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # dependency tracking mechanisms from slower ones.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Important note: in order to support this mode, a compiler *must*
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # always write the preprocessed file to stdout, regardless of -o.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "$@" || exit $?
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Remove the call to Libtool.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # Remove '-o $object'.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt shift # fnord
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt shift # $arg
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # Require at least two characters before searching for ':'
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # in the target name. This is to cope with DOS-style filenames:
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## Some versions of the HPUX 10.20 sed can't process this invocation
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## correctly. Breaking it into two sed invocations is a workaround.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # This case only exists to satisfy depend.m4. It is never actually
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # run, as this mode is specially recognized in the preamble.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "$@" || exit $?
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Remove any Libtool call
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # X makedepend
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt set ""; shift
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Strip any option that makedepend may not understand. Remove
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # the object too, otherwise makedepend will parse it as a source file.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # makedepend may prepend the VPATH from the source file name to the object.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # No need to regex-escape $object, excess matching of '.' is harmless.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## Some versions of the HPUX 10.20 sed can't process this invocation
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt## correctly. Breaking it into two sed invocations is a workaround.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Important note: in order to support this mode, a compiler *must*
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # always write the preprocessed file to stdout.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "$@" || exit $?
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Remove the call to Libtool.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # Remove '-o $object'.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt shift # fnord
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt shift # $arg
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Important note: in order to support this mode, a compiler *must*
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # always write the preprocessed file to stdout.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt "$@" || exit $?
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # Remove the call to Libtool.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # This case exists only to let depend.m4 do its work. It works by
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # looking at the text of this script. This case will never be run,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # since it is checked for above.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Local Variables:
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# mode: shell-script
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# sh-indentation: 2
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# eval: (add-hook 'write-file-hooks 'time-stamp)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# time-stamp-start: "scriptversion="
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# time-stamp-format: "%:y-%02m-%02d.%02H"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# time-stamp-time-zone: "UTC"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# time-stamp-end: "; # UTC"