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