depcomp revision 0dd80ee0
117a48c7cSmrg#! /bin/sh 217a48c7cSmrg# depcomp - compile a program generating dependencies as side-effects 317a48c7cSmrg 40dd80ee0Smrgscriptversion=2011-12-04.11; # UTC 517a48c7cSmrg 60dd80ee0Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 70dd80ee0Smrg# 2011 Free Software Foundation, Inc. 817a48c7cSmrg 917a48c7cSmrg# This program is free software; you can redistribute it and/or modify 1017a48c7cSmrg# it under the terms of the GNU General Public License as published by 1117a48c7cSmrg# the Free Software Foundation; either version 2, or (at your option) 1217a48c7cSmrg# any later version. 1317a48c7cSmrg 1417a48c7cSmrg# This program is distributed in the hope that it will be useful, 1517a48c7cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1617a48c7cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1717a48c7cSmrg# GNU General Public License for more details. 1817a48c7cSmrg 1917a48c7cSmrg# You should have received a copy of the GNU General Public License 20fbed5abfSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 2117a48c7cSmrg 2217a48c7cSmrg# As a special exception to the GNU General Public License, if you 2317a48c7cSmrg# distribute this file as part of a program that contains a 2417a48c7cSmrg# configuration script generated by Autoconf, you may include it under 2517a48c7cSmrg# the same distribution terms that you use for the rest of that program. 2617a48c7cSmrg 2717a48c7cSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 2817a48c7cSmrg 2917a48c7cSmrgcase $1 in 3017a48c7cSmrg '') 3117a48c7cSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3217a48c7cSmrg exit 1; 3317a48c7cSmrg ;; 3417a48c7cSmrg -h | --h*) 3517a48c7cSmrg cat <<\EOF 3617a48c7cSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 3717a48c7cSmrg 3817a48c7cSmrgRun PROGRAMS ARGS to compile a file, generating dependencies 3917a48c7cSmrgas side-effects. 4017a48c7cSmrg 4117a48c7cSmrgEnvironment variables: 4217a48c7cSmrg depmode Dependency tracking mode. 4317a48c7cSmrg source Source file read by `PROGRAMS ARGS'. 4417a48c7cSmrg object Object file output by `PROGRAMS ARGS'. 4517a48c7cSmrg DEPDIR directory where to store dependencies. 4617a48c7cSmrg depfile Dependency file to output. 470dd80ee0Smrg tmpdepfile Temporary file to use when outputting dependencies. 4817a48c7cSmrg libtool Whether libtool is used (yes/no). 4917a48c7cSmrg 5017a48c7cSmrgReport bugs to <bug-automake@gnu.org>. 5117a48c7cSmrgEOF 5217a48c7cSmrg exit $? 5317a48c7cSmrg ;; 5417a48c7cSmrg -v | --v*) 5517a48c7cSmrg echo "depcomp $scriptversion" 5617a48c7cSmrg exit $? 5717a48c7cSmrg ;; 5817a48c7cSmrgesac 5917a48c7cSmrg 6017a48c7cSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 6117a48c7cSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 6217a48c7cSmrg exit 1 6317a48c7cSmrgfi 6417a48c7cSmrg 6517a48c7cSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 6617a48c7cSmrgdepfile=${depfile-`echo "$object" | 6717a48c7cSmrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 6817a48c7cSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 6917a48c7cSmrg 7017a48c7cSmrgrm -f "$tmpdepfile" 7117a48c7cSmrg 7217a48c7cSmrg# Some modes work just like other modes, but use different flags. We 7317a48c7cSmrg# parameterize here, but still list the modes in the big case below, 7417a48c7cSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 7517a48c7cSmrg# here, because this file can only contain one case statement. 7617a48c7cSmrgif test "$depmode" = hp; then 7717a48c7cSmrg # HP compiler uses -M and no extra arg. 7817a48c7cSmrg gccflag=-M 7917a48c7cSmrg depmode=gcc 8017a48c7cSmrgfi 8117a48c7cSmrg 8217a48c7cSmrgif test "$depmode" = dashXmstdout; then 8317a48c7cSmrg # This is just like dashmstdout with a different argument. 8417a48c7cSmrg dashmflag=-xM 8517a48c7cSmrg depmode=dashmstdout 8617a48c7cSmrgfi 8717a48c7cSmrg 88fbed5abfSmrgcygpath_u="cygpath -u -f -" 89fbed5abfSmrgif test "$depmode" = msvcmsys; then 90fbed5abfSmrg # This is just like msvisualcpp but w/o cygpath translation. 91fbed5abfSmrg # Just convert the backslash-escaped backslashes to single forward 92fbed5abfSmrg # slashes to satisfy depend.m4 930dd80ee0Smrg cygpath_u='sed s,\\\\,/,g' 94fbed5abfSmrg depmode=msvisualcpp 95fbed5abfSmrgfi 96fbed5abfSmrg 970dd80ee0Smrgif test "$depmode" = msvc7msys; then 980dd80ee0Smrg # This is just like msvc7 but w/o cygpath translation. 990dd80ee0Smrg # Just convert the backslash-escaped backslashes to single forward 1000dd80ee0Smrg # slashes to satisfy depend.m4 1010dd80ee0Smrg cygpath_u='sed s,\\\\,/,g' 1020dd80ee0Smrg depmode=msvc7 1030dd80ee0Smrgfi 1040dd80ee0Smrg 10517a48c7cSmrgcase "$depmode" in 10617a48c7cSmrggcc3) 10717a48c7cSmrg## gcc 3 implements dependency tracking that does exactly what 10817a48c7cSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 10917a48c7cSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 1108e0ed500Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1118e0ed500Smrg## the command line argument order; so add the flags where they 1128e0ed500Smrg## appear in depend2.am. Note that the slowdown incurred here 1138e0ed500Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1148e0ed500Smrg for arg 1158e0ed500Smrg do 1168e0ed500Smrg case $arg in 1178e0ed500Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1188e0ed500Smrg *) set fnord "$@" "$arg" ;; 1198e0ed500Smrg esac 1208e0ed500Smrg shift # fnord 1218e0ed500Smrg shift # $arg 1228e0ed500Smrg done 1238e0ed500Smrg "$@" 12417a48c7cSmrg stat=$? 12517a48c7cSmrg if test $stat -eq 0; then : 12617a48c7cSmrg else 12717a48c7cSmrg rm -f "$tmpdepfile" 12817a48c7cSmrg exit $stat 12917a48c7cSmrg fi 13017a48c7cSmrg mv "$tmpdepfile" "$depfile" 13117a48c7cSmrg ;; 13217a48c7cSmrg 13317a48c7cSmrggcc) 13417a48c7cSmrg## There are various ways to get dependency output from gcc. Here's 13517a48c7cSmrg## why we pick this rather obscure method: 13617a48c7cSmrg## - Don't want to use -MD because we'd like the dependencies to end 13717a48c7cSmrg## up in a subdir. Having to rename by hand is ugly. 13817a48c7cSmrg## (We might end up doing this anyway to support other compilers.) 13917a48c7cSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 14017a48c7cSmrg## -MM, not -M (despite what the docs say). 14117a48c7cSmrg## - Using -M directly means running the compiler twice (even worse 14217a48c7cSmrg## than renaming). 14317a48c7cSmrg if test -z "$gccflag"; then 14417a48c7cSmrg gccflag=-MD, 14517a48c7cSmrg fi 14617a48c7cSmrg "$@" -Wp,"$gccflag$tmpdepfile" 14717a48c7cSmrg stat=$? 14817a48c7cSmrg if test $stat -eq 0; then : 14917a48c7cSmrg else 15017a48c7cSmrg rm -f "$tmpdepfile" 15117a48c7cSmrg exit $stat 15217a48c7cSmrg fi 15317a48c7cSmrg rm -f "$depfile" 15417a48c7cSmrg echo "$object : \\" > "$depfile" 15517a48c7cSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 15617a48c7cSmrg## The second -e expression handles DOS-style file names with drive letters. 15717a48c7cSmrg sed -e 's/^[^:]*: / /' \ 15817a48c7cSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 15917a48c7cSmrg## This next piece of magic avoids the `deleted header file' problem. 16017a48c7cSmrg## The problem is that when a header file which appears in a .P file 16117a48c7cSmrg## is deleted, the dependency causes make to die (because there is 16217a48c7cSmrg## typically no way to rebuild the header). We avoid this by adding 16317a48c7cSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 16417a48c7cSmrg## this for us directly. 16517a48c7cSmrg tr ' ' ' 16617a48c7cSmrg' < "$tmpdepfile" | 16717a48c7cSmrg## Some versions of gcc put a space before the `:'. On the theory 16817a48c7cSmrg## that the space means something, we add a space to the output as 1690dd80ee0Smrg## well. hp depmode also adds that space, but also prefixes the VPATH 1700dd80ee0Smrg## to the object. Take care to not repeat it in the output. 17117a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 17217a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 1730dd80ee0Smrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 1740dd80ee0Smrg | sed -e 's/$/ :/' >> "$depfile" 17517a48c7cSmrg rm -f "$tmpdepfile" 17617a48c7cSmrg ;; 17717a48c7cSmrg 17817a48c7cSmrghp) 17917a48c7cSmrg # This case exists only to let depend.m4 do its work. It works by 18017a48c7cSmrg # looking at the text of this script. This case will never be run, 18117a48c7cSmrg # since it is checked for above. 18217a48c7cSmrg exit 1 18317a48c7cSmrg ;; 18417a48c7cSmrg 18517a48c7cSmrgsgi) 18617a48c7cSmrg if test "$libtool" = yes; then 18717a48c7cSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 18817a48c7cSmrg else 18917a48c7cSmrg "$@" -MDupdate "$tmpdepfile" 19017a48c7cSmrg fi 19117a48c7cSmrg stat=$? 19217a48c7cSmrg if test $stat -eq 0; then : 19317a48c7cSmrg else 19417a48c7cSmrg rm -f "$tmpdepfile" 19517a48c7cSmrg exit $stat 19617a48c7cSmrg fi 19717a48c7cSmrg rm -f "$depfile" 19817a48c7cSmrg 19917a48c7cSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 20017a48c7cSmrg echo "$object : \\" > "$depfile" 20117a48c7cSmrg 20217a48c7cSmrg # Clip off the initial element (the dependent). Don't try to be 20317a48c7cSmrg # clever and replace this with sed code, as IRIX sed won't handle 20417a48c7cSmrg # lines with more than a fixed number of characters (4096 in 20517a48c7cSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 20617a48c7cSmrg # the IRIX cc adds comments like `#:fec' to the end of the 20717a48c7cSmrg # dependency line. 20817a48c7cSmrg tr ' ' ' 20917a48c7cSmrg' < "$tmpdepfile" \ 21017a48c7cSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 21117a48c7cSmrg tr ' 212fbed5abfSmrg' ' ' >> "$depfile" 213fbed5abfSmrg echo >> "$depfile" 21417a48c7cSmrg 21517a48c7cSmrg # The second pass generates a dummy entry for each header file. 21617a48c7cSmrg tr ' ' ' 21717a48c7cSmrg' < "$tmpdepfile" \ 21817a48c7cSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 219fbed5abfSmrg >> "$depfile" 22017a48c7cSmrg else 22117a48c7cSmrg # The sourcefile does not contain any dependencies, so just 22217a48c7cSmrg # store a dummy comment line, to avoid errors with the Makefile 22317a48c7cSmrg # "include basename.Plo" scheme. 22417a48c7cSmrg echo "#dummy" > "$depfile" 22517a48c7cSmrg fi 22617a48c7cSmrg rm -f "$tmpdepfile" 22717a48c7cSmrg ;; 22817a48c7cSmrg 22917a48c7cSmrgaix) 23017a48c7cSmrg # The C for AIX Compiler uses -M and outputs the dependencies 23117a48c7cSmrg # in a .u file. In older versions, this file always lives in the 23217a48c7cSmrg # current directory. Also, the AIX compiler puts `$object:' at the 23317a48c7cSmrg # start of each line; $object doesn't have directory information. 23417a48c7cSmrg # Version 6 uses the directory in both cases. 235fbed5abfSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 236fbed5abfSmrg test "x$dir" = "x$object" && dir= 237fbed5abfSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 23817a48c7cSmrg if test "$libtool" = yes; then 239fbed5abfSmrg tmpdepfile1=$dir$base.u 240fbed5abfSmrg tmpdepfile2=$base.u 241fbed5abfSmrg tmpdepfile3=$dir.libs/$base.u 24217a48c7cSmrg "$@" -Wc,-M 24317a48c7cSmrg else 244fbed5abfSmrg tmpdepfile1=$dir$base.u 245fbed5abfSmrg tmpdepfile2=$dir$base.u 246fbed5abfSmrg tmpdepfile3=$dir$base.u 24717a48c7cSmrg "$@" -M 24817a48c7cSmrg fi 24917a48c7cSmrg stat=$? 25017a48c7cSmrg 25117a48c7cSmrg if test $stat -eq 0; then : 25217a48c7cSmrg else 253fbed5abfSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 25417a48c7cSmrg exit $stat 25517a48c7cSmrg fi 25617a48c7cSmrg 257fbed5abfSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 258fbed5abfSmrg do 259fbed5abfSmrg test -f "$tmpdepfile" && break 260fbed5abfSmrg done 26117a48c7cSmrg if test -f "$tmpdepfile"; then 26217a48c7cSmrg # Each line is of the form `foo.o: dependent.h'. 26317a48c7cSmrg # Do two passes, one to just change these to 26417a48c7cSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 265fbed5abfSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 266fbed5abfSmrg # That's a tab and a space in the []. 267fbed5abfSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 26817a48c7cSmrg else 26917a48c7cSmrg # The sourcefile does not contain any dependencies, so just 27017a48c7cSmrg # store a dummy comment line, to avoid errors with the Makefile 27117a48c7cSmrg # "include basename.Plo" scheme. 27217a48c7cSmrg echo "#dummy" > "$depfile" 27317a48c7cSmrg fi 27417a48c7cSmrg rm -f "$tmpdepfile" 27517a48c7cSmrg ;; 27617a48c7cSmrg 27717a48c7cSmrgicc) 27817a48c7cSmrg # Intel's C compiler understands `-MD -MF file'. However on 27917a48c7cSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 28017a48c7cSmrg # ICC 7.0 will fill foo.d with something like 28117a48c7cSmrg # foo.o: sub/foo.c 28217a48c7cSmrg # foo.o: sub/foo.h 28317a48c7cSmrg # which is wrong. We want: 28417a48c7cSmrg # sub/foo.o: sub/foo.c 28517a48c7cSmrg # sub/foo.o: sub/foo.h 28617a48c7cSmrg # sub/foo.c: 28717a48c7cSmrg # sub/foo.h: 28817a48c7cSmrg # ICC 7.1 will output 28917a48c7cSmrg # foo.o: sub/foo.c sub/foo.h 29017a48c7cSmrg # and will wrap long lines using \ : 29117a48c7cSmrg # foo.o: sub/foo.c ... \ 29217a48c7cSmrg # sub/foo.h ... \ 29317a48c7cSmrg # ... 29417a48c7cSmrg 29517a48c7cSmrg "$@" -MD -MF "$tmpdepfile" 29617a48c7cSmrg stat=$? 29717a48c7cSmrg if test $stat -eq 0; then : 29817a48c7cSmrg else 29917a48c7cSmrg rm -f "$tmpdepfile" 30017a48c7cSmrg exit $stat 30117a48c7cSmrg fi 30217a48c7cSmrg rm -f "$depfile" 30317a48c7cSmrg # Each line is of the form `foo.o: dependent.h', 30417a48c7cSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 30517a48c7cSmrg # Do two passes, one to just change these to 30617a48c7cSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 30717a48c7cSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 30817a48c7cSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 30917a48c7cSmrg # correctly. Breaking it into two sed invocations is a workaround. 31017a48c7cSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 31117a48c7cSmrg sed -e 's/$/ :/' >> "$depfile" 31217a48c7cSmrg rm -f "$tmpdepfile" 31317a48c7cSmrg ;; 31417a48c7cSmrg 3158e0ed500Smrghp2) 3168e0ed500Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3178e0ed500Smrg # compilers, which have integrated preprocessors. The correct option 3188e0ed500Smrg # to use with these is +Maked; it writes dependencies to a file named 3198e0ed500Smrg # 'foo.d', which lands next to the object file, wherever that 3208e0ed500Smrg # happens to be. 3218e0ed500Smrg # Much of this is similar to the tru64 case; see comments there. 3228e0ed500Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3238e0ed500Smrg test "x$dir" = "x$object" && dir= 3248e0ed500Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3258e0ed500Smrg if test "$libtool" = yes; then 3268e0ed500Smrg tmpdepfile1=$dir$base.d 3278e0ed500Smrg tmpdepfile2=$dir.libs/$base.d 3288e0ed500Smrg "$@" -Wc,+Maked 3298e0ed500Smrg else 3308e0ed500Smrg tmpdepfile1=$dir$base.d 3318e0ed500Smrg tmpdepfile2=$dir$base.d 3328e0ed500Smrg "$@" +Maked 3338e0ed500Smrg fi 3348e0ed500Smrg stat=$? 3358e0ed500Smrg if test $stat -eq 0; then : 3368e0ed500Smrg else 3378e0ed500Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3388e0ed500Smrg exit $stat 3398e0ed500Smrg fi 3408e0ed500Smrg 3418e0ed500Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3428e0ed500Smrg do 3438e0ed500Smrg test -f "$tmpdepfile" && break 3448e0ed500Smrg done 3458e0ed500Smrg if test -f "$tmpdepfile"; then 3468e0ed500Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3478e0ed500Smrg # Add `dependent.h:' lines. 348fbed5abfSmrg sed -ne '2,${ 349fbed5abfSmrg s/^ *// 350fbed5abfSmrg s/ \\*$// 351fbed5abfSmrg s/$/:/ 352fbed5abfSmrg p 353fbed5abfSmrg }' "$tmpdepfile" >> "$depfile" 3548e0ed500Smrg else 3558e0ed500Smrg echo "#dummy" > "$depfile" 3568e0ed500Smrg fi 3578e0ed500Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3588e0ed500Smrg ;; 3598e0ed500Smrg 36017a48c7cSmrgtru64) 36117a48c7cSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 36217a48c7cSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 36317a48c7cSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 36417a48c7cSmrg # dependencies in `foo.d' instead, so we check for that too. 36517a48c7cSmrg # Subdirectories are respected. 36617a48c7cSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 36717a48c7cSmrg test "x$dir" = "x$object" && dir= 36817a48c7cSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 36917a48c7cSmrg 37017a48c7cSmrg if test "$libtool" = yes; then 37117a48c7cSmrg # With Tru64 cc, shared objects can also be used to make a 3728e0ed500Smrg # static library. This mechanism is used in libtool 1.4 series to 37317a48c7cSmrg # handle both shared and static libraries in a single compilation. 37417a48c7cSmrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 37517a48c7cSmrg # 37617a48c7cSmrg # With libtool 1.5 this exception was removed, and libtool now 37717a48c7cSmrg # generates 2 separate objects for the 2 libraries. These two 3788e0ed500Smrg # compilations output dependencies in $dir.libs/$base.o.d and 37917a48c7cSmrg # in $dir$base.o.d. We have to check for both files, because 38017a48c7cSmrg # one of the two compilations can be disabled. We should prefer 38117a48c7cSmrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 38217a48c7cSmrg # automatically cleaned when .libs/ is deleted, while ignoring 38317a48c7cSmrg # the former would cause a distcleancheck panic. 38417a48c7cSmrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 38517a48c7cSmrg tmpdepfile2=$dir$base.o.d # libtool 1.5 38617a48c7cSmrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 38717a48c7cSmrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 38817a48c7cSmrg "$@" -Wc,-MD 38917a48c7cSmrg else 39017a48c7cSmrg tmpdepfile1=$dir$base.o.d 39117a48c7cSmrg tmpdepfile2=$dir$base.d 39217a48c7cSmrg tmpdepfile3=$dir$base.d 39317a48c7cSmrg tmpdepfile4=$dir$base.d 39417a48c7cSmrg "$@" -MD 39517a48c7cSmrg fi 39617a48c7cSmrg 39717a48c7cSmrg stat=$? 39817a48c7cSmrg if test $stat -eq 0; then : 39917a48c7cSmrg else 40017a48c7cSmrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40117a48c7cSmrg exit $stat 40217a48c7cSmrg fi 40317a48c7cSmrg 40417a48c7cSmrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 40517a48c7cSmrg do 40617a48c7cSmrg test -f "$tmpdepfile" && break 40717a48c7cSmrg done 40817a48c7cSmrg if test -f "$tmpdepfile"; then 40917a48c7cSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 41017a48c7cSmrg # That's a tab and a space in the []. 41117a48c7cSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 41217a48c7cSmrg else 41317a48c7cSmrg echo "#dummy" > "$depfile" 41417a48c7cSmrg fi 41517a48c7cSmrg rm -f "$tmpdepfile" 41617a48c7cSmrg ;; 41717a48c7cSmrg 4180dd80ee0Smrgmsvc7) 4190dd80ee0Smrg if test "$libtool" = yes; then 4200dd80ee0Smrg showIncludes=-Wc,-showIncludes 4210dd80ee0Smrg else 4220dd80ee0Smrg showIncludes=-showIncludes 4230dd80ee0Smrg fi 4240dd80ee0Smrg "$@" $showIncludes > "$tmpdepfile" 4250dd80ee0Smrg stat=$? 4260dd80ee0Smrg grep -v '^Note: including file: ' "$tmpdepfile" 4270dd80ee0Smrg if test "$stat" = 0; then : 4280dd80ee0Smrg else 4290dd80ee0Smrg rm -f "$tmpdepfile" 4300dd80ee0Smrg exit $stat 4310dd80ee0Smrg fi 4320dd80ee0Smrg rm -f "$depfile" 4330dd80ee0Smrg echo "$object : \\" > "$depfile" 4340dd80ee0Smrg # The first sed program below extracts the file names and escapes 4350dd80ee0Smrg # backslashes for cygpath. The second sed program outputs the file 4360dd80ee0Smrg # name when reading, but also accumulates all include files in the 4370dd80ee0Smrg # hold buffer in order to output them again at the end. This only 4380dd80ee0Smrg # works with sed implementations that can handle large buffers. 4390dd80ee0Smrg sed < "$tmpdepfile" -n ' 4400dd80ee0Smrg/^Note: including file: *\(.*\)/ { 4410dd80ee0Smrg s//\1/ 4420dd80ee0Smrg s/\\/\\\\/g 4430dd80ee0Smrg p 4440dd80ee0Smrg}' | $cygpath_u | sort -u | sed -n ' 4450dd80ee0Smrgs/ /\\ /g 4460dd80ee0Smrgs/\(.*\)/ \1 \\/p 4470dd80ee0Smrgs/.\(.*\) \\/\1:/ 4480dd80ee0SmrgH 4490dd80ee0Smrg$ { 4500dd80ee0Smrg s/.*/ / 4510dd80ee0Smrg G 4520dd80ee0Smrg p 4530dd80ee0Smrg}' >> "$depfile" 4540dd80ee0Smrg rm -f "$tmpdepfile" 4550dd80ee0Smrg ;; 4560dd80ee0Smrg 4570dd80ee0Smrgmsvc7msys) 4580dd80ee0Smrg # This case exists only to let depend.m4 do its work. It works by 4590dd80ee0Smrg # looking at the text of this script. This case will never be run, 4600dd80ee0Smrg # since it is checked for above. 4610dd80ee0Smrg exit 1 4620dd80ee0Smrg ;; 4630dd80ee0Smrg 46417a48c7cSmrg#nosideeffect) 46517a48c7cSmrg # This comment above is used by automake to tell side-effect 46617a48c7cSmrg # dependency tracking mechanisms from slower ones. 46717a48c7cSmrg 46817a48c7cSmrgdashmstdout) 46917a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 47017a48c7cSmrg # always write the preprocessed file to stdout, regardless of -o. 47117a48c7cSmrg "$@" || exit $? 47217a48c7cSmrg 47317a48c7cSmrg # Remove the call to Libtool. 47417a48c7cSmrg if test "$libtool" = yes; then 475fbed5abfSmrg while test "X$1" != 'X--mode=compile'; do 47617a48c7cSmrg shift 47717a48c7cSmrg done 47817a48c7cSmrg shift 47917a48c7cSmrg fi 48017a48c7cSmrg 48117a48c7cSmrg # Remove `-o $object'. 48217a48c7cSmrg IFS=" " 48317a48c7cSmrg for arg 48417a48c7cSmrg do 48517a48c7cSmrg case $arg in 48617a48c7cSmrg -o) 48717a48c7cSmrg shift 48817a48c7cSmrg ;; 48917a48c7cSmrg $object) 49017a48c7cSmrg shift 49117a48c7cSmrg ;; 49217a48c7cSmrg *) 49317a48c7cSmrg set fnord "$@" "$arg" 49417a48c7cSmrg shift # fnord 49517a48c7cSmrg shift # $arg 49617a48c7cSmrg ;; 49717a48c7cSmrg esac 49817a48c7cSmrg done 49917a48c7cSmrg 50017a48c7cSmrg test -z "$dashmflag" && dashmflag=-M 50117a48c7cSmrg # Require at least two characters before searching for `:' 50217a48c7cSmrg # in the target name. This is to cope with DOS-style filenames: 50317a48c7cSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 50417a48c7cSmrg "$@" $dashmflag | 50517a48c7cSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 50617a48c7cSmrg rm -f "$depfile" 50717a48c7cSmrg cat < "$tmpdepfile" > "$depfile" 50817a48c7cSmrg tr ' ' ' 50917a48c7cSmrg' < "$tmpdepfile" | \ 51017a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 51117a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 51217a48c7cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 51317a48c7cSmrg rm -f "$tmpdepfile" 51417a48c7cSmrg ;; 51517a48c7cSmrg 51617a48c7cSmrgdashXmstdout) 51717a48c7cSmrg # This case only exists to satisfy depend.m4. It is never actually 51817a48c7cSmrg # run, as this mode is specially recognized in the preamble. 51917a48c7cSmrg exit 1 52017a48c7cSmrg ;; 52117a48c7cSmrg 52217a48c7cSmrgmakedepend) 52317a48c7cSmrg "$@" || exit $? 52417a48c7cSmrg # Remove any Libtool call 52517a48c7cSmrg if test "$libtool" = yes; then 526fbed5abfSmrg while test "X$1" != 'X--mode=compile'; do 52717a48c7cSmrg shift 52817a48c7cSmrg done 52917a48c7cSmrg shift 53017a48c7cSmrg fi 53117a48c7cSmrg # X makedepend 53217a48c7cSmrg shift 533fbed5abfSmrg cleared=no eat=no 534fbed5abfSmrg for arg 535fbed5abfSmrg do 53617a48c7cSmrg case $cleared in 53717a48c7cSmrg no) 53817a48c7cSmrg set ""; shift 53917a48c7cSmrg cleared=yes ;; 54017a48c7cSmrg esac 541fbed5abfSmrg if test $eat = yes; then 542fbed5abfSmrg eat=no 543fbed5abfSmrg continue 544fbed5abfSmrg fi 54517a48c7cSmrg case "$arg" in 54617a48c7cSmrg -D*|-I*) 54717a48c7cSmrg set fnord "$@" "$arg"; shift ;; 54817a48c7cSmrg # Strip any option that makedepend may not understand. Remove 54917a48c7cSmrg # the object too, otherwise makedepend will parse it as a source file. 550fbed5abfSmrg -arch) 551fbed5abfSmrg eat=yes ;; 55217a48c7cSmrg -*|$object) 55317a48c7cSmrg ;; 55417a48c7cSmrg *) 55517a48c7cSmrg set fnord "$@" "$arg"; shift ;; 55617a48c7cSmrg esac 55717a48c7cSmrg done 558fbed5abfSmrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 55917a48c7cSmrg touch "$tmpdepfile" 56017a48c7cSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 56117a48c7cSmrg rm -f "$depfile" 5620dd80ee0Smrg # makedepend may prepend the VPATH from the source file name to the object. 5630dd80ee0Smrg # No need to regex-escape $object, excess matching of '.' is harmless. 5640dd80ee0Smrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 56517a48c7cSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 56617a48c7cSmrg' | \ 56717a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 56817a48c7cSmrg## correctly. Breaking it into two sed invocations is a workaround. 56917a48c7cSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 57017a48c7cSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 57117a48c7cSmrg ;; 57217a48c7cSmrg 57317a48c7cSmrgcpp) 57417a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 57517a48c7cSmrg # always write the preprocessed file to stdout. 57617a48c7cSmrg "$@" || exit $? 57717a48c7cSmrg 57817a48c7cSmrg # Remove the call to Libtool. 57917a48c7cSmrg if test "$libtool" = yes; then 580fbed5abfSmrg while test "X$1" != 'X--mode=compile'; do 58117a48c7cSmrg shift 58217a48c7cSmrg done 58317a48c7cSmrg shift 58417a48c7cSmrg fi 58517a48c7cSmrg 58617a48c7cSmrg # Remove `-o $object'. 58717a48c7cSmrg IFS=" " 58817a48c7cSmrg for arg 58917a48c7cSmrg do 59017a48c7cSmrg case $arg in 59117a48c7cSmrg -o) 59217a48c7cSmrg shift 59317a48c7cSmrg ;; 59417a48c7cSmrg $object) 59517a48c7cSmrg shift 59617a48c7cSmrg ;; 59717a48c7cSmrg *) 59817a48c7cSmrg set fnord "$@" "$arg" 59917a48c7cSmrg shift # fnord 60017a48c7cSmrg shift # $arg 60117a48c7cSmrg ;; 60217a48c7cSmrg esac 60317a48c7cSmrg done 60417a48c7cSmrg 60517a48c7cSmrg "$@" -E | 60617a48c7cSmrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 60717a48c7cSmrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 60817a48c7cSmrg sed '$ s: \\$::' > "$tmpdepfile" 60917a48c7cSmrg rm -f "$depfile" 61017a48c7cSmrg echo "$object : \\" > "$depfile" 61117a48c7cSmrg cat < "$tmpdepfile" >> "$depfile" 61217a48c7cSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 61317a48c7cSmrg rm -f "$tmpdepfile" 61417a48c7cSmrg ;; 61517a48c7cSmrg 61617a48c7cSmrgmsvisualcpp) 61717a48c7cSmrg # Important note: in order to support this mode, a compiler *must* 618fbed5abfSmrg # always write the preprocessed file to stdout. 61917a48c7cSmrg "$@" || exit $? 620fbed5abfSmrg 621fbed5abfSmrg # Remove the call to Libtool. 622fbed5abfSmrg if test "$libtool" = yes; then 623fbed5abfSmrg while test "X$1" != 'X--mode=compile'; do 624fbed5abfSmrg shift 625fbed5abfSmrg done 626fbed5abfSmrg shift 627fbed5abfSmrg fi 628fbed5abfSmrg 62917a48c7cSmrg IFS=" " 63017a48c7cSmrg for arg 63117a48c7cSmrg do 63217a48c7cSmrg case "$arg" in 633fbed5abfSmrg -o) 634fbed5abfSmrg shift 635fbed5abfSmrg ;; 636fbed5abfSmrg $object) 637fbed5abfSmrg shift 638fbed5abfSmrg ;; 63917a48c7cSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 64017a48c7cSmrg set fnord "$@" 64117a48c7cSmrg shift 64217a48c7cSmrg shift 64317a48c7cSmrg ;; 64417a48c7cSmrg *) 64517a48c7cSmrg set fnord "$@" "$arg" 64617a48c7cSmrg shift 64717a48c7cSmrg shift 64817a48c7cSmrg ;; 64917a48c7cSmrg esac 65017a48c7cSmrg done 651fbed5abfSmrg "$@" -E 2>/dev/null | 652fbed5abfSmrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 65317a48c7cSmrg rm -f "$depfile" 65417a48c7cSmrg echo "$object : \\" > "$depfile" 655fbed5abfSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 65617a48c7cSmrg echo " " >> "$depfile" 657fbed5abfSmrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 65817a48c7cSmrg rm -f "$tmpdepfile" 65917a48c7cSmrg ;; 66017a48c7cSmrg 661fbed5abfSmrgmsvcmsys) 662fbed5abfSmrg # This case exists only to let depend.m4 do its work. It works by 663fbed5abfSmrg # looking at the text of this script. This case will never be run, 664fbed5abfSmrg # since it is checked for above. 665fbed5abfSmrg exit 1 666fbed5abfSmrg ;; 667fbed5abfSmrg 66817a48c7cSmrgnone) 66917a48c7cSmrg exec "$@" 67017a48c7cSmrg ;; 67117a48c7cSmrg 67217a48c7cSmrg*) 67317a48c7cSmrg echo "Unknown depmode $depmode" 1>&2 67417a48c7cSmrg exit 1 67517a48c7cSmrg ;; 67617a48c7cSmrgesac 67717a48c7cSmrg 67817a48c7cSmrgexit 0 67917a48c7cSmrg 68017a48c7cSmrg# Local Variables: 68117a48c7cSmrg# mode: shell-script 68217a48c7cSmrg# sh-indentation: 2 68317a48c7cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 68417a48c7cSmrg# time-stamp-start: "scriptversion=" 68517a48c7cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 686fbed5abfSmrg# time-stamp-time-zone: "UTC" 687fbed5abfSmrg# time-stamp-end: "; # UTC" 68817a48c7cSmrg# End: 689