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