depcomp revision 1ab64890
11ab64890Smrg#! /bin/sh 21ab64890Smrg# depcomp - compile a program generating dependencies as side-effects 31ab64890Smrg 41ab64890Smrgscriptversion=2007-03-29.01 51ab64890Smrg 61ab64890Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software 71ab64890Smrg# Foundation, Inc. 81ab64890Smrg 91ab64890Smrg# This program is free software; you can redistribute it and/or modify 101ab64890Smrg# it under the terms of the GNU General Public License as published by 111ab64890Smrg# the Free Software Foundation; either version 2, or (at your option) 121ab64890Smrg# any later version. 131ab64890Smrg 141ab64890Smrg# This program is distributed in the hope that it will be useful, 151ab64890Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 161ab64890Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171ab64890Smrg# GNU General Public License for more details. 181ab64890Smrg 191ab64890Smrg# You should have received a copy of the GNU General Public License 201ab64890Smrg# along with this program; if not, write to the Free Software 211ab64890Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 221ab64890Smrg# 02110-1301, USA. 231ab64890Smrg 241ab64890Smrg# As a special exception to the GNU General Public License, if you 251ab64890Smrg# distribute this file as part of a program that contains a 261ab64890Smrg# configuration script generated by Autoconf, you may include it under 271ab64890Smrg# the same distribution terms that you use for the rest of that program. 281ab64890Smrg 291ab64890Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 301ab64890Smrg 311ab64890Smrgcase $1 in 321ab64890Smrg '') 331ab64890Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 341ab64890Smrg exit 1; 351ab64890Smrg ;; 361ab64890Smrg -h | --h*) 371ab64890Smrg cat <<\EOF 381ab64890SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 391ab64890Smrg 401ab64890SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 411ab64890Smrgas side-effects. 421ab64890Smrg 431ab64890SmrgEnvironment variables: 441ab64890Smrg depmode Dependency tracking mode. 451ab64890Smrg source Source file read by `PROGRAMS ARGS'. 461ab64890Smrg object Object file output by `PROGRAMS ARGS'. 471ab64890Smrg DEPDIR directory where to store dependencies. 481ab64890Smrg depfile Dependency file to output. 491ab64890Smrg tmpdepfile Temporary file to use when outputing dependencies. 501ab64890Smrg libtool Whether libtool is used (yes/no). 511ab64890Smrg 521ab64890SmrgReport bugs to <bug-automake@gnu.org>. 531ab64890SmrgEOF 541ab64890Smrg exit $? 551ab64890Smrg ;; 561ab64890Smrg -v | --v*) 571ab64890Smrg echo "depcomp $scriptversion" 581ab64890Smrg exit $? 591ab64890Smrg ;; 601ab64890Smrgesac 611ab64890Smrg 621ab64890Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 631ab64890Smrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 641ab64890Smrg exit 1 651ab64890Smrgfi 661ab64890Smrg 671ab64890Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 681ab64890Smrgdepfile=${depfile-`echo "$object" | 691ab64890Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 701ab64890Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 711ab64890Smrg 721ab64890Smrgrm -f "$tmpdepfile" 731ab64890Smrg 741ab64890Smrg# Some modes work just like other modes, but use different flags. We 751ab64890Smrg# parameterize here, but still list the modes in the big case below, 761ab64890Smrg# to make depend.m4 easier to write. Note that we *cannot* use a case 771ab64890Smrg# here, because this file can only contain one case statement. 781ab64890Smrgif test "$depmode" = hp; then 791ab64890Smrg # HP compiler uses -M and no extra arg. 801ab64890Smrg gccflag=-M 811ab64890Smrg depmode=gcc 821ab64890Smrgfi 831ab64890Smrg 841ab64890Smrgif test "$depmode" = dashXmstdout; then 851ab64890Smrg # This is just like dashmstdout with a different argument. 861ab64890Smrg dashmflag=-xM 871ab64890Smrg depmode=dashmstdout 881ab64890Smrgfi 891ab64890Smrg 901ab64890Smrgcase "$depmode" in 911ab64890Smrggcc3) 921ab64890Smrg## gcc 3 implements dependency tracking that does exactly what 931ab64890Smrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 941ab64890Smrg## it if -MD -MP comes after the -MF stuff. Hmm. 951ab64890Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 961ab64890Smrg## the command line argument order; so add the flags where they 971ab64890Smrg## appear in depend2.am. Note that the slowdown incurred here 981ab64890Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 991ab64890Smrg for arg 1001ab64890Smrg do 1011ab64890Smrg case $arg in 1021ab64890Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1031ab64890Smrg *) set fnord "$@" "$arg" ;; 1041ab64890Smrg esac 1051ab64890Smrg shift # fnord 1061ab64890Smrg shift # $arg 1071ab64890Smrg done 1081ab64890Smrg "$@" 1091ab64890Smrg stat=$? 1101ab64890Smrg if test $stat -eq 0; then : 1111ab64890Smrg else 1121ab64890Smrg rm -f "$tmpdepfile" 1131ab64890Smrg exit $stat 1141ab64890Smrg fi 1151ab64890Smrg mv "$tmpdepfile" "$depfile" 1161ab64890Smrg ;; 1171ab64890Smrg 1181ab64890Smrggcc) 1191ab64890Smrg## There are various ways to get dependency output from gcc. Here's 1201ab64890Smrg## why we pick this rather obscure method: 1211ab64890Smrg## - Don't want to use -MD because we'd like the dependencies to end 1221ab64890Smrg## up in a subdir. Having to rename by hand is ugly. 1231ab64890Smrg## (We might end up doing this anyway to support other compilers.) 1241ab64890Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1251ab64890Smrg## -MM, not -M (despite what the docs say). 1261ab64890Smrg## - Using -M directly means running the compiler twice (even worse 1271ab64890Smrg## than renaming). 1281ab64890Smrg if test -z "$gccflag"; then 1291ab64890Smrg gccflag=-MD, 1301ab64890Smrg fi 1311ab64890Smrg "$@" -Wp,"$gccflag$tmpdepfile" 1321ab64890Smrg stat=$? 1331ab64890Smrg if test $stat -eq 0; then : 1341ab64890Smrg else 1351ab64890Smrg rm -f "$tmpdepfile" 1361ab64890Smrg exit $stat 1371ab64890Smrg fi 1381ab64890Smrg rm -f "$depfile" 1391ab64890Smrg echo "$object : \\" > "$depfile" 1401ab64890Smrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1411ab64890Smrg## The second -e expression handles DOS-style file names with drive letters. 1421ab64890Smrg sed -e 's/^[^:]*: / /' \ 1431ab64890Smrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1441ab64890Smrg## This next piece of magic avoids the `deleted header file' problem. 1451ab64890Smrg## The problem is that when a header file which appears in a .P file 1461ab64890Smrg## is deleted, the dependency causes make to die (because there is 1471ab64890Smrg## typically no way to rebuild the header). We avoid this by adding 1481ab64890Smrg## dummy dependencies for each header file. Too bad gcc doesn't do 1491ab64890Smrg## this for us directly. 1501ab64890Smrg tr ' ' ' 1511ab64890Smrg' < "$tmpdepfile" | 1521ab64890Smrg## Some versions of gcc put a space before the `:'. On the theory 1531ab64890Smrg## that the space means something, we add a space to the output as 1541ab64890Smrg## well. 1551ab64890Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 1561ab64890Smrg## correctly. Breaking it into two sed invocations is a workaround. 1571ab64890Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1581ab64890Smrg rm -f "$tmpdepfile" 1591ab64890Smrg ;; 1601ab64890Smrg 1611ab64890Smrghp) 1621ab64890Smrg # This case exists only to let depend.m4 do its work. It works by 1631ab64890Smrg # looking at the text of this script. This case will never be run, 1641ab64890Smrg # since it is checked for above. 1651ab64890Smrg exit 1 1661ab64890Smrg ;; 1671ab64890Smrg 1681ab64890Smrgsgi) 1691ab64890Smrg if test "$libtool" = yes; then 1701ab64890Smrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1711ab64890Smrg else 1721ab64890Smrg "$@" -MDupdate "$tmpdepfile" 1731ab64890Smrg fi 1741ab64890Smrg stat=$? 1751ab64890Smrg if test $stat -eq 0; then : 1761ab64890Smrg else 1771ab64890Smrg rm -f "$tmpdepfile" 1781ab64890Smrg exit $stat 1791ab64890Smrg fi 1801ab64890Smrg rm -f "$depfile" 1811ab64890Smrg 1821ab64890Smrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1831ab64890Smrg echo "$object : \\" > "$depfile" 1841ab64890Smrg 1851ab64890Smrg # Clip off the initial element (the dependent). Don't try to be 1861ab64890Smrg # clever and replace this with sed code, as IRIX sed won't handle 1871ab64890Smrg # lines with more than a fixed number of characters (4096 in 1881ab64890Smrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1891ab64890Smrg # the IRIX cc adds comments like `#:fec' to the end of the 1901ab64890Smrg # dependency line. 1911ab64890Smrg tr ' ' ' 1921ab64890Smrg' < "$tmpdepfile" \ 1931ab64890Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 1941ab64890Smrg tr ' 1951ab64890Smrg' ' ' >> $depfile 1961ab64890Smrg echo >> $depfile 1971ab64890Smrg 1981ab64890Smrg # The second pass generates a dummy entry for each header file. 1991ab64890Smrg tr ' ' ' 2001ab64890Smrg' < "$tmpdepfile" \ 2011ab64890Smrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2021ab64890Smrg >> $depfile 2031ab64890Smrg else 2041ab64890Smrg # The sourcefile does not contain any dependencies, so just 2051ab64890Smrg # store a dummy comment line, to avoid errors with the Makefile 2061ab64890Smrg # "include basename.Plo" scheme. 2071ab64890Smrg echo "#dummy" > "$depfile" 2081ab64890Smrg fi 2091ab64890Smrg rm -f "$tmpdepfile" 2101ab64890Smrg ;; 2111ab64890Smrg 2121ab64890Smrgaix) 2131ab64890Smrg # The C for AIX Compiler uses -M and outputs the dependencies 2141ab64890Smrg # in a .u file. In older versions, this file always lives in the 2151ab64890Smrg # current directory. Also, the AIX compiler puts `$object:' at the 2161ab64890Smrg # start of each line; $object doesn't have directory information. 2171ab64890Smrg # Version 6 uses the directory in both cases. 2181ab64890Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2191ab64890Smrg test "x$dir" = "x$object" && dir= 2201ab64890Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2211ab64890Smrg if test "$libtool" = yes; then 2221ab64890Smrg tmpdepfile1=$dir$base.u 2231ab64890Smrg tmpdepfile2=$base.u 2241ab64890Smrg tmpdepfile3=$dir.libs/$base.u 2251ab64890Smrg "$@" -Wc,-M 2261ab64890Smrg else 2271ab64890Smrg tmpdepfile1=$dir$base.u 2281ab64890Smrg tmpdepfile2=$dir$base.u 2291ab64890Smrg tmpdepfile3=$dir$base.u 2301ab64890Smrg "$@" -M 2311ab64890Smrg fi 2321ab64890Smrg stat=$? 2331ab64890Smrg 2341ab64890Smrg if test $stat -eq 0; then : 2351ab64890Smrg else 2361ab64890Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2371ab64890Smrg exit $stat 2381ab64890Smrg fi 2391ab64890Smrg 2401ab64890Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2411ab64890Smrg do 2421ab64890Smrg test -f "$tmpdepfile" && break 2431ab64890Smrg done 2441ab64890Smrg if test -f "$tmpdepfile"; then 2451ab64890Smrg # Each line is of the form `foo.o: dependent.h'. 2461ab64890Smrg # Do two passes, one to just change these to 2471ab64890Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2481ab64890Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2491ab64890Smrg # That's a tab and a space in the []. 2501ab64890Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 2511ab64890Smrg else 2521ab64890Smrg # The sourcefile does not contain any dependencies, so just 2531ab64890Smrg # store a dummy comment line, to avoid errors with the Makefile 2541ab64890Smrg # "include basename.Plo" scheme. 2551ab64890Smrg echo "#dummy" > "$depfile" 2561ab64890Smrg fi 2571ab64890Smrg rm -f "$tmpdepfile" 2581ab64890Smrg ;; 2591ab64890Smrg 2601ab64890Smrgicc) 2611ab64890Smrg # Intel's C compiler understands `-MD -MF file'. However on 2621ab64890Smrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2631ab64890Smrg # ICC 7.0 will fill foo.d with something like 2641ab64890Smrg # foo.o: sub/foo.c 2651ab64890Smrg # foo.o: sub/foo.h 2661ab64890Smrg # which is wrong. We want: 2671ab64890Smrg # sub/foo.o: sub/foo.c 2681ab64890Smrg # sub/foo.o: sub/foo.h 2691ab64890Smrg # sub/foo.c: 2701ab64890Smrg # sub/foo.h: 2711ab64890Smrg # ICC 7.1 will output 2721ab64890Smrg # foo.o: sub/foo.c sub/foo.h 2731ab64890Smrg # and will wrap long lines using \ : 2741ab64890Smrg # foo.o: sub/foo.c ... \ 2751ab64890Smrg # sub/foo.h ... \ 2761ab64890Smrg # ... 2771ab64890Smrg 2781ab64890Smrg "$@" -MD -MF "$tmpdepfile" 2791ab64890Smrg stat=$? 2801ab64890Smrg if test $stat -eq 0; then : 2811ab64890Smrg else 2821ab64890Smrg rm -f "$tmpdepfile" 2831ab64890Smrg exit $stat 2841ab64890Smrg fi 2851ab64890Smrg rm -f "$depfile" 2861ab64890Smrg # Each line is of the form `foo.o: dependent.h', 2871ab64890Smrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2881ab64890Smrg # Do two passes, one to just change these to 2891ab64890Smrg # `$object: dependent.h' and one to simply `dependent.h:'. 2901ab64890Smrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2911ab64890Smrg # Some versions of the HPUX 10.20 sed can't process this invocation 2921ab64890Smrg # correctly. Breaking it into two sed invocations is a workaround. 2931ab64890Smrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 2941ab64890Smrg sed -e 's/$/ :/' >> "$depfile" 2951ab64890Smrg rm -f "$tmpdepfile" 2961ab64890Smrg ;; 2971ab64890Smrg 2981ab64890Smrghp2) 2991ab64890Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3001ab64890Smrg # compilers, which have integrated preprocessors. The correct option 3011ab64890Smrg # to use with these is +Maked; it writes dependencies to a file named 3021ab64890Smrg # 'foo.d', which lands next to the object file, wherever that 3031ab64890Smrg # happens to be. 3041ab64890Smrg # Much of this is similar to the tru64 case; see comments there. 3051ab64890Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3061ab64890Smrg test "x$dir" = "x$object" && dir= 3071ab64890Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3081ab64890Smrg if test "$libtool" = yes; then 3091ab64890Smrg tmpdepfile1=$dir$base.d 3101ab64890Smrg tmpdepfile2=$dir.libs/$base.d 3111ab64890Smrg "$@" -Wc,+Maked 3121ab64890Smrg else 3131ab64890Smrg tmpdepfile1=$dir$base.d 3141ab64890Smrg tmpdepfile2=$dir$base.d 3151ab64890Smrg "$@" +Maked 3161ab64890Smrg fi 3171ab64890Smrg stat=$? 3181ab64890Smrg if test $stat -eq 0; then : 3191ab64890Smrg else 3201ab64890Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3211ab64890Smrg exit $stat 3221ab64890Smrg fi 3231ab64890Smrg 3241ab64890Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3251ab64890Smrg do 3261ab64890Smrg test -f "$tmpdepfile" && break 3271ab64890Smrg done 3281ab64890Smrg if test -f "$tmpdepfile"; then 3291ab64890Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3301ab64890Smrg # Add `dependent.h:' lines. 3311ab64890Smrg sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 3321ab64890Smrg else 3331ab64890Smrg echo "#dummy" > "$depfile" 3341ab64890Smrg fi 3351ab64890Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3361ab64890Smrg ;; 3371ab64890Smrg 3381ab64890Smrgtru64) 3391ab64890Smrg # The Tru64 compiler uses -MD to generate dependencies as a side 3401ab64890Smrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3411ab64890Smrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3421ab64890Smrg # dependencies in `foo.d' instead, so we check for that too. 3431ab64890Smrg # Subdirectories are respected. 3441ab64890Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3451ab64890Smrg test "x$dir" = "x$object" && dir= 3461ab64890Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3471ab64890Smrg 3481ab64890Smrg if test "$libtool" = yes; then 3491ab64890Smrg # With Tru64 cc, shared objects can also be used to make a 3501ab64890Smrg # static library. This mechanism is used in libtool 1.4 series to 3511ab64890Smrg # handle both shared and static libraries in a single compilation. 3521ab64890Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3531ab64890Smrg # 3541ab64890Smrg # With libtool 1.5 this exception was removed, and libtool now 3551ab64890Smrg # generates 2 separate objects for the 2 libraries. These two 3561ab64890Smrg # compilations output dependencies in $dir.libs/$base.o.d and 3571ab64890Smrg # in $dir$base.o.d. We have to check for both files, because 3581ab64890Smrg # one of the two compilations can be disabled. We should prefer 3591ab64890Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3601ab64890Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3611ab64890Smrg # the former would cause a distcleancheck panic. 3621ab64890Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3631ab64890Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3641ab64890Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3651ab64890Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3661ab64890Smrg "$@" -Wc,-MD 3671ab64890Smrg else 3681ab64890Smrg tmpdepfile1=$dir$base.o.d 3691ab64890Smrg tmpdepfile2=$dir$base.d 3701ab64890Smrg tmpdepfile3=$dir$base.d 3711ab64890Smrg tmpdepfile4=$dir$base.d 3721ab64890Smrg "$@" -MD 3731ab64890Smrg fi 3741ab64890Smrg 3751ab64890Smrg stat=$? 3761ab64890Smrg if test $stat -eq 0; then : 3771ab64890Smrg else 3781ab64890Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3791ab64890Smrg exit $stat 3801ab64890Smrg fi 3811ab64890Smrg 3821ab64890Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3831ab64890Smrg do 3841ab64890Smrg test -f "$tmpdepfile" && break 3851ab64890Smrg done 3861ab64890Smrg if test -f "$tmpdepfile"; then 3871ab64890Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 3881ab64890Smrg # That's a tab and a space in the []. 3891ab64890Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 3901ab64890Smrg else 3911ab64890Smrg echo "#dummy" > "$depfile" 3921ab64890Smrg fi 3931ab64890Smrg rm -f "$tmpdepfile" 3941ab64890Smrg ;; 3951ab64890Smrg 3961ab64890Smrg#nosideeffect) 3971ab64890Smrg # This comment above is used by automake to tell side-effect 3981ab64890Smrg # dependency tracking mechanisms from slower ones. 3991ab64890Smrg 4001ab64890Smrgdashmstdout) 4011ab64890Smrg # Important note: in order to support this mode, a compiler *must* 4021ab64890Smrg # always write the preprocessed file to stdout, regardless of -o. 4031ab64890Smrg "$@" || exit $? 4041ab64890Smrg 4051ab64890Smrg # Remove the call to Libtool. 4061ab64890Smrg if test "$libtool" = yes; then 4071ab64890Smrg while test $1 != '--mode=compile'; do 4081ab64890Smrg shift 4091ab64890Smrg done 4101ab64890Smrg shift 4111ab64890Smrg fi 4121ab64890Smrg 4131ab64890Smrg # Remove `-o $object'. 4141ab64890Smrg IFS=" " 4151ab64890Smrg for arg 4161ab64890Smrg do 4171ab64890Smrg case $arg in 4181ab64890Smrg -o) 4191ab64890Smrg shift 4201ab64890Smrg ;; 4211ab64890Smrg $object) 4221ab64890Smrg shift 4231ab64890Smrg ;; 4241ab64890Smrg *) 4251ab64890Smrg set fnord "$@" "$arg" 4261ab64890Smrg shift # fnord 4271ab64890Smrg shift # $arg 4281ab64890Smrg ;; 4291ab64890Smrg esac 4301ab64890Smrg done 4311ab64890Smrg 4321ab64890Smrg test -z "$dashmflag" && dashmflag=-M 4331ab64890Smrg # Require at least two characters before searching for `:' 4341ab64890Smrg # in the target name. This is to cope with DOS-style filenames: 4351ab64890Smrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4361ab64890Smrg "$@" $dashmflag | 4371ab64890Smrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4381ab64890Smrg rm -f "$depfile" 4391ab64890Smrg cat < "$tmpdepfile" > "$depfile" 4401ab64890Smrg tr ' ' ' 4411ab64890Smrg' < "$tmpdepfile" | \ 4421ab64890Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4431ab64890Smrg## correctly. Breaking it into two sed invocations is a workaround. 4441ab64890Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4451ab64890Smrg rm -f "$tmpdepfile" 4461ab64890Smrg ;; 4471ab64890Smrg 4481ab64890SmrgdashXmstdout) 4491ab64890Smrg # This case only exists to satisfy depend.m4. It is never actually 4501ab64890Smrg # run, as this mode is specially recognized in the preamble. 4511ab64890Smrg exit 1 4521ab64890Smrg ;; 4531ab64890Smrg 4541ab64890Smrgmakedepend) 4551ab64890Smrg "$@" || exit $? 4561ab64890Smrg # Remove any Libtool call 4571ab64890Smrg if test "$libtool" = yes; then 4581ab64890Smrg while test $1 != '--mode=compile'; do 4591ab64890Smrg shift 4601ab64890Smrg done 4611ab64890Smrg shift 4621ab64890Smrg fi 4631ab64890Smrg # X makedepend 4641ab64890Smrg shift 4651ab64890Smrg cleared=no 4661ab64890Smrg for arg in "$@"; do 4671ab64890Smrg case $cleared in 4681ab64890Smrg no) 4691ab64890Smrg set ""; shift 4701ab64890Smrg cleared=yes ;; 4711ab64890Smrg esac 4721ab64890Smrg case "$arg" in 4731ab64890Smrg -D*|-I*) 4741ab64890Smrg set fnord "$@" "$arg"; shift ;; 4751ab64890Smrg # Strip any option that makedepend may not understand. Remove 4761ab64890Smrg # the object too, otherwise makedepend will parse it as a source file. 4771ab64890Smrg -*|$object) 4781ab64890Smrg ;; 4791ab64890Smrg *) 4801ab64890Smrg set fnord "$@" "$arg"; shift ;; 4811ab64890Smrg esac 4821ab64890Smrg done 4831ab64890Smrg obj_suffix="`echo $object | sed 's/^.*\././'`" 4841ab64890Smrg touch "$tmpdepfile" 4851ab64890Smrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 4861ab64890Smrg rm -f "$depfile" 4871ab64890Smrg cat < "$tmpdepfile" > "$depfile" 4881ab64890Smrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 4891ab64890Smrg' | \ 4901ab64890Smrg## Some versions of the HPUX 10.20 sed can't process this invocation 4911ab64890Smrg## correctly. Breaking it into two sed invocations is a workaround. 4921ab64890Smrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4931ab64890Smrg rm -f "$tmpdepfile" "$tmpdepfile".bak 4941ab64890Smrg ;; 4951ab64890Smrg 4961ab64890Smrgcpp) 4971ab64890Smrg # Important note: in order to support this mode, a compiler *must* 4981ab64890Smrg # always write the preprocessed file to stdout. 4991ab64890Smrg "$@" || exit $? 5001ab64890Smrg 5011ab64890Smrg # Remove the call to Libtool. 5021ab64890Smrg if test "$libtool" = yes; then 5031ab64890Smrg while test $1 != '--mode=compile'; do 5041ab64890Smrg shift 5051ab64890Smrg done 5061ab64890Smrg shift 5071ab64890Smrg fi 5081ab64890Smrg 5091ab64890Smrg # Remove `-o $object'. 5101ab64890Smrg IFS=" " 5111ab64890Smrg for arg 5121ab64890Smrg do 5131ab64890Smrg case $arg in 5141ab64890Smrg -o) 5151ab64890Smrg shift 5161ab64890Smrg ;; 5171ab64890Smrg $object) 5181ab64890Smrg shift 5191ab64890Smrg ;; 5201ab64890Smrg *) 5211ab64890Smrg set fnord "$@" "$arg" 5221ab64890Smrg shift # fnord 5231ab64890Smrg shift # $arg 5241ab64890Smrg ;; 5251ab64890Smrg esac 5261ab64890Smrg done 5271ab64890Smrg 5281ab64890Smrg "$@" -E | 5291ab64890Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5301ab64890Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5311ab64890Smrg sed '$ s: \\$::' > "$tmpdepfile" 5321ab64890Smrg rm -f "$depfile" 5331ab64890Smrg echo "$object : \\" > "$depfile" 5341ab64890Smrg cat < "$tmpdepfile" >> "$depfile" 5351ab64890Smrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5361ab64890Smrg rm -f "$tmpdepfile" 5371ab64890Smrg ;; 5381ab64890Smrg 5391ab64890Smrgmsvisualcpp) 5401ab64890Smrg # Important note: in order to support this mode, a compiler *must* 5411ab64890Smrg # always write the preprocessed file to stdout, regardless of -o, 5421ab64890Smrg # because we must use -o when running libtool. 5431ab64890Smrg "$@" || exit $? 5441ab64890Smrg IFS=" " 5451ab64890Smrg for arg 5461ab64890Smrg do 5471ab64890Smrg case "$arg" in 5481ab64890Smrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5491ab64890Smrg set fnord "$@" 5501ab64890Smrg shift 5511ab64890Smrg shift 5521ab64890Smrg ;; 5531ab64890Smrg *) 5541ab64890Smrg set fnord "$@" "$arg" 5551ab64890Smrg shift 5561ab64890Smrg shift 5571ab64890Smrg ;; 5581ab64890Smrg esac 5591ab64890Smrg done 5601ab64890Smrg "$@" -E | 5611ab64890Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 5621ab64890Smrg rm -f "$depfile" 5631ab64890Smrg echo "$object : \\" > "$depfile" 5641ab64890Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5651ab64890Smrg echo " " >> "$depfile" 5661ab64890Smrg . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 5671ab64890Smrg rm -f "$tmpdepfile" 5681ab64890Smrg ;; 5691ab64890Smrg 5701ab64890Smrgnone) 5711ab64890Smrg exec "$@" 5721ab64890Smrg ;; 5731ab64890Smrg 5741ab64890Smrg*) 5751ab64890Smrg echo "Unknown depmode $depmode" 1>&2 5761ab64890Smrg exit 1 5771ab64890Smrg ;; 5781ab64890Smrgesac 5791ab64890Smrg 5801ab64890Smrgexit 0 5811ab64890Smrg 5821ab64890Smrg# Local Variables: 5831ab64890Smrg# mode: shell-script 5841ab64890Smrg# sh-indentation: 2 5851ab64890Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 5861ab64890Smrg# time-stamp-start: "scriptversion=" 5871ab64890Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 5881ab64890Smrg# time-stamp-end: "$" 5891ab64890Smrg# End: 590