depcomp revision 93493779
16c321187Smrg#! /bin/sh 26c321187Smrg# depcomp - compile a program generating dependencies as side-effects 36c321187Smrg 493493779Smrgscriptversion=2009-04-28.21; # UTC 56c321187Smrg 693493779Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 793493779Smrg# Software Foundation, Inc. 86c321187Smrg 96c321187Smrg# This program is free software; you can redistribute it and/or modify 106c321187Smrg# it under the terms of the GNU General Public License as published by 116c321187Smrg# the Free Software Foundation; either version 2, or (at your option) 126c321187Smrg# any later version. 136c321187Smrg 146c321187Smrg# This program is distributed in the hope that it will be useful, 156c321187Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 166c321187Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 176c321187Smrg# GNU General Public License for more details. 186c321187Smrg 196c321187Smrg# You should have received a copy of the GNU General Public License 2093493779Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 216c321187Smrg 226c321187Smrg# As a special exception to the GNU General Public License, if you 236c321187Smrg# distribute this file as part of a program that contains a 246c321187Smrg# configuration script generated by Autoconf, you may include it under 256c321187Smrg# the same distribution terms that you use for the rest of that program. 266c321187Smrg 276c321187Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 286c321187Smrg 296c321187Smrgcase $1 in 306c321187Smrg '') 316c321187Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 326c321187Smrg exit 1; 336c321187Smrg ;; 346c321187Smrg -h | --h*) 356c321187Smrg cat <<\EOF 366c321187SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 376c321187Smrg 386c321187SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 396c321187Smrgas side-effects. 406c321187Smrg 416c321187SmrgEnvironment variables: 426c321187Smrg depmode Dependency tracking mode. 436c321187Smrg source Source file read by `PROGRAMS ARGS'. 446c321187Smrg object Object file output by `PROGRAMS ARGS'. 456c321187Smrg DEPDIR directory where to store dependencies. 466c321187Smrg depfile Dependency file to output. 476c321187Smrg tmpdepfile Temporary file to use when outputing dependencies. 486c321187Smrg libtool Whether libtool is used (yes/no). 496c321187Smrg 506c321187SmrgReport bugs to <bug-automake@gnu.org>. 516c321187SmrgEOF 526c321187Smrg exit $? 536c321187Smrg ;; 546c321187Smrg -v | --v*) 556c321187Smrg echo "depcomp $scriptversion" 566c321187Smrg exit $? 576c321187Smrg ;; 586c321187Smrgesac 596c321187Smrg 606c321187Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 616c321187Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 626c321187Smrg exit 1 636c321187Smrgfi 646c321187Smrg 656c321187Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 666c321187Smrgdepfile=${depfile-`echo "$object" | 676c321187Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 686c321187Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 696c321187Smrg 706c321187Smrgrm -f "$tmpdepfile" 716c321187Smrg 726c321187Smrg# Some modes work just like other modes, but use different flags. We 736c321187Smrg# parameterize here, but still list the modes in the big case below, 746c321187Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 756c321187Smrg# here, because this file can only contain one case statement. 766c321187Smrgif test "$depmode" = hp; then 776c321187Smrg # HP compiler uses -M and no extra arg. 786c321187Smrg gccflag=-M 796c321187Smrg depmode=gcc 806c321187Smrgfi 816c321187Smrg 826c321187Smrgif test "$depmode" = dashXmstdout; then 836c321187Smrg # This is just like dashmstdout with a different argument. 846c321187Smrg dashmflag=-xM 856c321187Smrg depmode=dashmstdout 866c321187Smrgfi 876c321187Smrg 8893493779Smrgcygpath_u="cygpath -u -f -" 8993493779Smrgif test "$depmode" = msvcmsys; then 9093493779Smrg # This is just like msvisualcpp but w/o cygpath translation. 9193493779Smrg # Just convert the backslash-escaped backslashes to single forward 9293493779Smrg # slashes to satisfy depend.m4 9393493779Smrg cygpath_u="sed s,\\\\\\\\,/,g" 9493493779Smrg depmode=msvisualcpp 9593493779Smrgfi 9693493779Smrg 976c321187Smrgcase "$depmode" in 986c321187Smrggcc3) 996c321187Smrg## gcc 3 implements dependency tracking that does exactly what 1006c321187Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1016c321187Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 1026c321187Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1036c321187Smrg## the command line argument order; so add the flags where they 1046c321187Smrg## appear in depend2.am. Note that the slowdown incurred here 1056c321187Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1066c321187Smrg for arg 1076c321187Smrg do 1086c321187Smrg case $arg in 1096c321187Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1106c321187Smrg *) set fnord "$@" "$arg" ;; 1116c321187Smrg esac 1126c321187Smrg shift # fnord 1136c321187Smrg shift # $arg 1146c321187Smrg done 1156c321187Smrg "$@" 1166c321187Smrg stat=$? 1176c321187Smrg if test $stat -eq 0; then : 1186c321187Smrg else 1196c321187Smrg rm -f "$tmpdepfile" 1206c321187Smrg exit $stat 1216c321187Smrg fi 1226c321187Smrg mv "$tmpdepfile" "$depfile" 1236c321187Smrg ;; 1246c321187Smrg 1256c321187Smrggcc) 1266c321187Smrg## There are various ways to get dependency output from gcc. Here's 1276c321187Smrg## why we pick this rather obscure method: 1286c321187Smrg## - Don't want to use -MD because we'd like the dependencies to end 1296c321187Smrg## up in a subdir. Having to rename by hand is ugly. 1306c321187Smrg## (We might end up doing this anyway to support other compilers.) 1316c321187Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1326c321187Smrg## -MM, not -M (despite what the docs say). 1336c321187Smrg## - Using -M directly means running the compiler twice (even worse 1346c321187Smrg## than renaming). 1356c321187Smrg if test -z "$gccflag"; then 1366c321187Smrg gccflag=-MD, 1376c321187Smrg fi 1386c321187Smrg "$@" -Wp,"$gccflag$tmpdepfile" 1396c321187Smrg stat=$? 1406c321187Smrg if test $stat -eq 0; then : 1416c321187Smrg else 1426c321187Smrg rm -f "$tmpdepfile" 1436c321187Smrg exit $stat 1446c321187Smrg fi 1456c321187Smrg rm -f "$depfile" 1466c321187Smrg echo "$object : \\" > "$depfile" 1476c321187Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1486c321187Smrg## The second -e expression handles DOS-style file names with drive letters. 1496c321187Smrg sed -e 's/^[^:]*: / /' \ 1506c321187Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1516c321187Smrg## This next piece of magic avoids the `deleted header file' problem. 1526c321187Smrg## The problem is that when a header file which appears in a .P file 1536c321187Smrg## is deleted, the dependency causes make to die (because there is 1546c321187Smrg## typically no way to rebuild the header). We avoid this by adding 1556c321187Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 1566c321187Smrg## this for us directly. 1576c321187Smrg tr ' ' ' 1586c321187Smrg' < "$tmpdepfile" | 1596c321187Smrg## Some versions of gcc put a space before the `:'. On the theory 1606c321187Smrg## that the space means something, we add a space to the output as 1616c321187Smrg## well. 1626c321187Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 1636c321187Smrg## correctly. Breaking it into two sed invocations is a workaround. 1646c321187Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1656c321187Smrg rm -f "$tmpdepfile" 1666c321187Smrg ;; 1676c321187Smrg 1686c321187Smrghp) 1696c321187Smrg # This case exists only to let depend.m4 do its work. It works by 1706c321187Smrg # looking at the text of this script. This case will never be run, 1716c321187Smrg # since it is checked for above. 1726c321187Smrg exit 1 1736c321187Smrg ;; 1746c321187Smrg 1756c321187Smrgsgi) 1766c321187Smrg if test "$libtool" = yes; then 1776c321187Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1786c321187Smrg else 1796c321187Smrg "$@" -MDupdate "$tmpdepfile" 1806c321187Smrg fi 1816c321187Smrg stat=$? 1826c321187Smrg if test $stat -eq 0; then : 1836c321187Smrg else 1846c321187Smrg rm -f "$tmpdepfile" 1856c321187Smrg exit $stat 1866c321187Smrg fi 1876c321187Smrg rm -f "$depfile" 1886c321187Smrg 1896c321187Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1906c321187Smrg echo "$object : \\" > "$depfile" 1916c321187Smrg 1926c321187Smrg # Clip off the initial element (the dependent). Don't try to be 1936c321187Smrg # clever and replace this with sed code, as IRIX sed won't handle 1946c321187Smrg # lines with more than a fixed number of characters (4096 in 1956c321187Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1966c321187Smrg # the IRIX cc adds comments like `#:fec' to the end of the 1976c321187Smrg # dependency line. 1986c321187Smrg tr ' ' ' 1996c321187Smrg' < "$tmpdepfile" \ 2006c321187Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 2016c321187Smrg tr ' 20293493779Smrg' ' ' >> "$depfile" 20393493779Smrg echo >> "$depfile" 2046c321187Smrg 2056c321187Smrg # The second pass generates a dummy entry for each header file. 2066c321187Smrg tr ' ' ' 2076c321187Smrg' < "$tmpdepfile" \ 2086c321187Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 20993493779Smrg >> "$depfile" 2106c321187Smrg else 2116c321187Smrg # The sourcefile does not contain any dependencies, so just 2126c321187Smrg # store a dummy comment line, to avoid errors with the Makefile 2136c321187Smrg # "include basename.Plo" scheme. 2146c321187Smrg echo "#dummy" > "$depfile" 2156c321187Smrg fi 2166c321187Smrg rm -f "$tmpdepfile" 2176c321187Smrg ;; 2186c321187Smrg 2196c321187Smrgaix) 2206c321187Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2216c321187Smrg # in a .u file. In older versions, this file always lives in the 2226c321187Smrg # current directory. Also, the AIX compiler puts `$object:' at the 2236c321187Smrg # start of each line; $object doesn't have directory information. 2246c321187Smrg # Version 6 uses the directory in both cases. 22593493779Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 22693493779Smrg test "x$dir" = "x$object" && dir= 22793493779Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2286c321187Smrg if test "$libtool" = yes; then 22993493779Smrg tmpdepfile1=$dir$base.u 23093493779Smrg tmpdepfile2=$base.u 23193493779Smrg tmpdepfile3=$dir.libs/$base.u 2326c321187Smrg "$@" -Wc,-M 2336c321187Smrg else 23493493779Smrg tmpdepfile1=$dir$base.u 23593493779Smrg tmpdepfile2=$dir$base.u 23693493779Smrg tmpdepfile3=$dir$base.u 2376c321187Smrg "$@" -M 2386c321187Smrg fi 2396c321187Smrg stat=$? 2406c321187Smrg 2416c321187Smrg if test $stat -eq 0; then : 2426c321187Smrg else 24393493779Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2446c321187Smrg exit $stat 2456c321187Smrg fi 2466c321187Smrg 24793493779Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 24893493779Smrg do 24993493779Smrg test -f "$tmpdepfile" && break 25093493779Smrg done 2516c321187Smrg if test -f "$tmpdepfile"; then 2526c321187Smrg # Each line is of the form `foo.o: dependent.h'. 2536c321187Smrg # Do two passes, one to just change these to 2546c321187Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 25593493779Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 25693493779Smrg # That's a tab and a space in the []. 25793493779Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 2586c321187Smrg else 2596c321187Smrg # The sourcefile does not contain any dependencies, so just 2606c321187Smrg # store a dummy comment line, to avoid errors with the Makefile 2616c321187Smrg # "include basename.Plo" scheme. 2626c321187Smrg echo "#dummy" > "$depfile" 2636c321187Smrg fi 2646c321187Smrg rm -f "$tmpdepfile" 2656c321187Smrg ;; 2666c321187Smrg 2676c321187Smrgicc) 2686c321187Smrg # Intel's C compiler understands `-MD -MF file'. However on 2696c321187Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2706c321187Smrg # ICC 7.0 will fill foo.d with something like 2716c321187Smrg # foo.o: sub/foo.c 2726c321187Smrg # foo.o: sub/foo.h 2736c321187Smrg # which is wrong. We want: 2746c321187Smrg # sub/foo.o: sub/foo.c 2756c321187Smrg # sub/foo.o: sub/foo.h 2766c321187Smrg # sub/foo.c: 2776c321187Smrg # sub/foo.h: 2786c321187Smrg # ICC 7.1 will output 2796c321187Smrg # foo.o: sub/foo.c sub/foo.h 2806c321187Smrg # and will wrap long lines using \ : 2816c321187Smrg # foo.o: sub/foo.c ... \ 2826c321187Smrg # sub/foo.h ... \ 2836c321187Smrg # ... 2846c321187Smrg 2856c321187Smrg "$@" -MD -MF "$tmpdepfile" 2866c321187Smrg stat=$? 2876c321187Smrg if test $stat -eq 0; then : 2886c321187Smrg else 2896c321187Smrg rm -f "$tmpdepfile" 2906c321187Smrg exit $stat 2916c321187Smrg fi 2926c321187Smrg rm -f "$depfile" 2936c321187Smrg # Each line is of the form `foo.o: dependent.h', 2946c321187Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2956c321187Smrg # Do two passes, one to just change these to 2966c321187Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2976c321187Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2986c321187Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 2996c321187Smrg # correctly. Breaking it into two sed invocations is a workaround. 3006c321187Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 3016c321187Smrg sed -e 's/$/ :/' >> "$depfile" 3026c321187Smrg rm -f "$tmpdepfile" 3036c321187Smrg ;; 3046c321187Smrg 3056c321187Smrghp2) 3066c321187Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3076c321187Smrg # compilers, which have integrated preprocessors. The correct option 3086c321187Smrg # to use with these is +Maked; it writes dependencies to a file named 3096c321187Smrg # 'foo.d', which lands next to the object file, wherever that 3106c321187Smrg # happens to be. 3116c321187Smrg # Much of this is similar to the tru64 case; see comments there. 3126c321187Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3136c321187Smrg test "x$dir" = "x$object" && dir= 3146c321187Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3156c321187Smrg if test "$libtool" = yes; then 3166c321187Smrg tmpdepfile1=$dir$base.d 3176c321187Smrg tmpdepfile2=$dir.libs/$base.d 3186c321187Smrg "$@" -Wc,+Maked 3196c321187Smrg else 3206c321187Smrg tmpdepfile1=$dir$base.d 3216c321187Smrg tmpdepfile2=$dir$base.d 3226c321187Smrg "$@" +Maked 3236c321187Smrg fi 3246c321187Smrg stat=$? 3256c321187Smrg if test $stat -eq 0; then : 3266c321187Smrg else 3276c321187Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3286c321187Smrg exit $stat 3296c321187Smrg fi 3306c321187Smrg 3316c321187Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3326c321187Smrg do 3336c321187Smrg test -f "$tmpdepfile" && break 3346c321187Smrg done 3356c321187Smrg if test -f "$tmpdepfile"; then 3366c321187Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3376c321187Smrg # Add `dependent.h:' lines. 33893493779Smrg sed -ne '2,${ 33993493779Smrg s/^ *// 34093493779Smrg s/ \\*$// 34193493779Smrg s/$/:/ 34293493779Smrg p 34393493779Smrg }' "$tmpdepfile" >> "$depfile" 3446c321187Smrg else 3456c321187Smrg echo "#dummy" > "$depfile" 3466c321187Smrg fi 3476c321187Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3486c321187Smrg ;; 3496c321187Smrg 3506c321187Smrgtru64) 3516c321187Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 3526c321187Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3536c321187Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3546c321187Smrg # dependencies in `foo.d' instead, so we check for that too. 3556c321187Smrg # Subdirectories are respected. 3566c321187Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3576c321187Smrg test "x$dir" = "x$object" && dir= 3586c321187Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3596c321187Smrg 3606c321187Smrg if test "$libtool" = yes; then 3616c321187Smrg # With Tru64 cc, shared objects can also be used to make a 3626c321187Smrg # static library. This mechanism is used in libtool 1.4 series to 3636c321187Smrg # handle both shared and static libraries in a single compilation. 3646c321187Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3656c321187Smrg # 3666c321187Smrg # With libtool 1.5 this exception was removed, and libtool now 3676c321187Smrg # generates 2 separate objects for the 2 libraries. These two 3686c321187Smrg # compilations output dependencies in $dir.libs/$base.o.d and 3696c321187Smrg # in $dir$base.o.d. We have to check for both files, because 3706c321187Smrg # one of the two compilations can be disabled. We should prefer 3716c321187Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3726c321187Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3736c321187Smrg # the former would cause a distcleancheck panic. 3746c321187Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3756c321187Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3766c321187Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3776c321187Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3786c321187Smrg "$@" -Wc,-MD 3796c321187Smrg else 3806c321187Smrg tmpdepfile1=$dir$base.o.d 3816c321187Smrg tmpdepfile2=$dir$base.d 3826c321187Smrg tmpdepfile3=$dir$base.d 3836c321187Smrg tmpdepfile4=$dir$base.d 3846c321187Smrg "$@" -MD 3856c321187Smrg fi 3866c321187Smrg 3876c321187Smrg stat=$? 3886c321187Smrg if test $stat -eq 0; then : 3896c321187Smrg else 3906c321187Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3916c321187Smrg exit $stat 3926c321187Smrg fi 3936c321187Smrg 3946c321187Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3956c321187Smrg do 3966c321187Smrg test -f "$tmpdepfile" && break 3976c321187Smrg done 3986c321187Smrg if test -f "$tmpdepfile"; then 3996c321187Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 4006c321187Smrg # That's a tab and a space in the []. 4016c321187Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 4026c321187Smrg else 4036c321187Smrg echo "#dummy" > "$depfile" 4046c321187Smrg fi 4056c321187Smrg rm -f "$tmpdepfile" 4066c321187Smrg ;; 4076c321187Smrg 4086c321187Smrg#nosideeffect) 4096c321187Smrg # This comment above is used by automake to tell side-effect 4106c321187Smrg # dependency tracking mechanisms from slower ones. 4116c321187Smrg 4126c321187Smrgdashmstdout) 4136c321187Smrg # Important note: in order to support this mode, a compiler *must* 4146c321187Smrg # always write the preprocessed file to stdout, regardless of -o. 4156c321187Smrg "$@" || exit $? 4166c321187Smrg 4176c321187Smrg # Remove the call to Libtool. 4186c321187Smrg if test "$libtool" = yes; then 41993493779Smrg while test "X$1" != 'X--mode=compile'; do 4206c321187Smrg shift 4216c321187Smrg done 4226c321187Smrg shift 4236c321187Smrg fi 4246c321187Smrg 4256c321187Smrg # Remove `-o $object'. 4266c321187Smrg IFS=" " 4276c321187Smrg for arg 4286c321187Smrg do 4296c321187Smrg case $arg in 4306c321187Smrg -o) 4316c321187Smrg shift 4326c321187Smrg ;; 4336c321187Smrg $object) 4346c321187Smrg shift 4356c321187Smrg ;; 4366c321187Smrg *) 4376c321187Smrg set fnord "$@" "$arg" 4386c321187Smrg shift # fnord 4396c321187Smrg shift # $arg 4406c321187Smrg ;; 4416c321187Smrg esac 4426c321187Smrg done 4436c321187Smrg 4446c321187Smrg test -z "$dashmflag" && dashmflag=-M 4456c321187Smrg # Require at least two characters before searching for `:' 4466c321187Smrg # in the target name. This is to cope with DOS-style filenames: 4476c321187Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4486c321187Smrg "$@" $dashmflag | 4496c321187Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4506c321187Smrg rm -f "$depfile" 4516c321187Smrg cat < "$tmpdepfile" > "$depfile" 4526c321187Smrg tr ' ' ' 4536c321187Smrg' < "$tmpdepfile" | \ 4546c321187Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4556c321187Smrg## correctly. Breaking it into two sed invocations is a workaround. 4566c321187Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4576c321187Smrg rm -f "$tmpdepfile" 4586c321187Smrg ;; 4596c321187Smrg 4606c321187SmrgdashXmstdout) 4616c321187Smrg # This case only exists to satisfy depend.m4. It is never actually 4626c321187Smrg # run, as this mode is specially recognized in the preamble. 4636c321187Smrg exit 1 4646c321187Smrg ;; 4656c321187Smrg 4666c321187Smrgmakedepend) 4676c321187Smrg "$@" || exit $? 4686c321187Smrg # Remove any Libtool call 4696c321187Smrg if test "$libtool" = yes; then 47093493779Smrg while test "X$1" != 'X--mode=compile'; do 4716c321187Smrg shift 4726c321187Smrg done 4736c321187Smrg shift 4746c321187Smrg fi 4756c321187Smrg # X makedepend 4766c321187Smrg shift 47793493779Smrg cleared=no eat=no 47893493779Smrg for arg 47993493779Smrg do 4806c321187Smrg case $cleared in 4816c321187Smrg no) 4826c321187Smrg set ""; shift 4836c321187Smrg cleared=yes ;; 4846c321187Smrg esac 48593493779Smrg if test $eat = yes; then 48693493779Smrg eat=no 48793493779Smrg continue 48893493779Smrg fi 4896c321187Smrg case "$arg" in 4906c321187Smrg -D*|-I*) 4916c321187Smrg set fnord "$@" "$arg"; shift ;; 4926c321187Smrg # Strip any option that makedepend may not understand. Remove 4936c321187Smrg # the object too, otherwise makedepend will parse it as a source file. 49493493779Smrg -arch) 49593493779Smrg eat=yes ;; 4966c321187Smrg -*|$object) 4976c321187Smrg ;; 4986c321187Smrg *) 4996c321187Smrg set fnord "$@" "$arg"; shift ;; 5006c321187Smrg esac 5016c321187Smrg done 50293493779Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 5036c321187Smrg touch "$tmpdepfile" 5046c321187Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 5056c321187Smrg rm -f "$depfile" 5066c321187Smrg cat < "$tmpdepfile" > "$depfile" 5076c321187Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 5086c321187Smrg' | \ 5096c321187Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 5106c321187Smrg## correctly. Breaking it into two sed invocations is a workaround. 5116c321187Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 5126c321187Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 5136c321187Smrg ;; 5146c321187Smrg 5156c321187Smrgcpp) 5166c321187Smrg # Important note: in order to support this mode, a compiler *must* 5176c321187Smrg # always write the preprocessed file to stdout. 5186c321187Smrg "$@" || exit $? 5196c321187Smrg 5206c321187Smrg # Remove the call to Libtool. 5216c321187Smrg if test "$libtool" = yes; then 52293493779Smrg while test "X$1" != 'X--mode=compile'; do 5236c321187Smrg shift 5246c321187Smrg done 5256c321187Smrg shift 5266c321187Smrg fi 5276c321187Smrg 5286c321187Smrg # Remove `-o $object'. 5296c321187Smrg IFS=" " 5306c321187Smrg for arg 5316c321187Smrg do 5326c321187Smrg case $arg in 5336c321187Smrg -o) 5346c321187Smrg shift 5356c321187Smrg ;; 5366c321187Smrg $object) 5376c321187Smrg shift 5386c321187Smrg ;; 5396c321187Smrg *) 5406c321187Smrg set fnord "$@" "$arg" 5416c321187Smrg shift # fnord 5426c321187Smrg shift # $arg 5436c321187Smrg ;; 5446c321187Smrg esac 5456c321187Smrg done 5466c321187Smrg 5476c321187Smrg "$@" -E | 5486c321187Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5496c321187Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5506c321187Smrg sed '$ s: \\$::' > "$tmpdepfile" 5516c321187Smrg rm -f "$depfile" 5526c321187Smrg echo "$object : \\" > "$depfile" 5536c321187Smrg cat < "$tmpdepfile" >> "$depfile" 5546c321187Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5556c321187Smrg rm -f "$tmpdepfile" 5566c321187Smrg ;; 5576c321187Smrg 5586c321187Smrgmsvisualcpp) 5596c321187Smrg # Important note: in order to support this mode, a compiler *must* 56093493779Smrg # always write the preprocessed file to stdout. 5616c321187Smrg "$@" || exit $? 56293493779Smrg 56393493779Smrg # Remove the call to Libtool. 56493493779Smrg if test "$libtool" = yes; then 56593493779Smrg while test "X$1" != 'X--mode=compile'; do 56693493779Smrg shift 56793493779Smrg done 56893493779Smrg shift 56993493779Smrg fi 57093493779Smrg 5716c321187Smrg IFS=" " 5726c321187Smrg for arg 5736c321187Smrg do 5746c321187Smrg case "$arg" in 57593493779Smrg -o) 57693493779Smrg shift 57793493779Smrg ;; 57893493779Smrg $object) 57993493779Smrg shift 58093493779Smrg ;; 5816c321187Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5826c321187Smrg set fnord "$@" 5836c321187Smrg shift 5846c321187Smrg shift 5856c321187Smrg ;; 5866c321187Smrg *) 5876c321187Smrg set fnord "$@" "$arg" 5886c321187Smrg shift 5896c321187Smrg shift 5906c321187Smrg ;; 5916c321187Smrg esac 5926c321187Smrg done 59393493779Smrg "$@" -E 2>/dev/null | 59493493779Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 5956c321187Smrg rm -f "$depfile" 5966c321187Smrg echo "$object : \\" > "$depfile" 59793493779Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5986c321187Smrg echo " " >> "$depfile" 59993493779Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 6006c321187Smrg rm -f "$tmpdepfile" 6016c321187Smrg ;; 6026c321187Smrg 60393493779Smrgmsvcmsys) 60493493779Smrg # This case exists only to let depend.m4 do its work. It works by 60593493779Smrg # looking at the text of this script. This case will never be run, 60693493779Smrg # since it is checked for above. 60793493779Smrg exit 1 60893493779Smrg ;; 60993493779Smrg 6106c321187Smrgnone) 6116c321187Smrg exec "$@" 6126c321187Smrg ;; 6136c321187Smrg 6146c321187Smrg*) 6156c321187Smrg echo "Unknown depmode $depmode" 1>&2 6166c321187Smrg exit 1 6176c321187Smrg ;; 6186c321187Smrgesac 6196c321187Smrg 6206c321187Smrgexit 0 6216c321187Smrg 6226c321187Smrg# Local Variables: 6236c321187Smrg# mode: shell-script 6246c321187Smrg# sh-indentation: 2 6256c321187Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 6266c321187Smrg# time-stamp-start: "scriptversion=" 6276c321187Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 62893493779Smrg# time-stamp-time-zone: "UTC" 62993493779Smrg# time-stamp-end: "; # UTC" 6306c321187Smrg# End: 631