depcomp revision 8650bb69
12c7c4e3dSmrg#! /bin/sh 22c7c4e3dSmrg# depcomp - compile a program generating dependencies as side-effects 38650bb69Smrg 48650bb69Smrgscriptversion=2009-04-28.21; # UTC 58650bb69Smrg 68650bb69Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 78650bb69Smrg# Software Foundation, Inc. 82c7c4e3dSmrg 92c7c4e3dSmrg# This program is free software; you can redistribute it and/or modify 102c7c4e3dSmrg# it under the terms of the GNU General Public License as published by 112c7c4e3dSmrg# the Free Software Foundation; either version 2, or (at your option) 122c7c4e3dSmrg# any later version. 132c7c4e3dSmrg 142c7c4e3dSmrg# This program is distributed in the hope that it will be useful, 152c7c4e3dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 162c7c4e3dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 172c7c4e3dSmrg# GNU General Public License for more details. 182c7c4e3dSmrg 192c7c4e3dSmrg# You should have received a copy of the GNU General Public License 208650bb69Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 212c7c4e3dSmrg 222c7c4e3dSmrg# As a special exception to the GNU General Public License, if you 232c7c4e3dSmrg# distribute this file as part of a program that contains a 242c7c4e3dSmrg# configuration script generated by Autoconf, you may include it under 252c7c4e3dSmrg# the same distribution terms that you use for the rest of that program. 262c7c4e3dSmrg 272c7c4e3dSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 282c7c4e3dSmrg 298650bb69Smrgcase $1 in 308650bb69Smrg '') 318650bb69Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 328650bb69Smrg exit 1; 338650bb69Smrg ;; 348650bb69Smrg -h | --h*) 358650bb69Smrg cat <<\EOF 368650bb69SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS] 378650bb69Smrg 388650bb69SmrgRun PROGRAMS ARGS to compile a file, generating dependencies 398650bb69Smrgas side-effects. 408650bb69Smrg 418650bb69SmrgEnvironment variables: 428650bb69Smrg depmode Dependency tracking mode. 438650bb69Smrg source Source file read by `PROGRAMS ARGS'. 448650bb69Smrg object Object file output by `PROGRAMS ARGS'. 458650bb69Smrg DEPDIR directory where to store dependencies. 468650bb69Smrg depfile Dependency file to output. 478650bb69Smrg tmpdepfile Temporary file to use when outputing dependencies. 488650bb69Smrg libtool Whether libtool is used (yes/no). 498650bb69Smrg 508650bb69SmrgReport bugs to <bug-automake@gnu.org>. 518650bb69SmrgEOF 528650bb69Smrg exit $? 538650bb69Smrg ;; 548650bb69Smrg -v | --v*) 558650bb69Smrg echo "depcomp $scriptversion" 568650bb69Smrg exit $? 578650bb69Smrg ;; 588650bb69Smrgesac 598650bb69Smrg 602c7c4e3dSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then 612c7c4e3dSmrg echo "depcomp: Variables source, object and depmode must be set" 1>&2 622c7c4e3dSmrg exit 1 632c7c4e3dSmrgfi 642c7c4e3dSmrg 658650bb69Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 668650bb69Smrgdepfile=${depfile-`echo "$object" | 678650bb69Smrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 682c7c4e3dSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 692c7c4e3dSmrg 702c7c4e3dSmrgrm -f "$tmpdepfile" 712c7c4e3dSmrg 722c7c4e3dSmrg# Some modes work just like other modes, but use different flags. We 732c7c4e3dSmrg# parameterize here, but still list the modes in the big case below, 742c7c4e3dSmrg# to make depend.m4 easier to write. Note that we *cannot* use a case 752c7c4e3dSmrg# here, because this file can only contain one case statement. 762c7c4e3dSmrgif test "$depmode" = hp; then 772c7c4e3dSmrg # HP compiler uses -M and no extra arg. 782c7c4e3dSmrg gccflag=-M 792c7c4e3dSmrg depmode=gcc 802c7c4e3dSmrgfi 812c7c4e3dSmrg 822c7c4e3dSmrgif test "$depmode" = dashXmstdout; then 832c7c4e3dSmrg # This is just like dashmstdout with a different argument. 842c7c4e3dSmrg dashmflag=-xM 852c7c4e3dSmrg depmode=dashmstdout 862c7c4e3dSmrgfi 872c7c4e3dSmrg 888650bb69Smrgcygpath_u="cygpath -u -f -" 898650bb69Smrgif test "$depmode" = msvcmsys; then 908650bb69Smrg # This is just like msvisualcpp but w/o cygpath translation. 918650bb69Smrg # Just convert the backslash-escaped backslashes to single forward 928650bb69Smrg # slashes to satisfy depend.m4 938650bb69Smrg cygpath_u="sed s,\\\\\\\\,/,g" 948650bb69Smrg depmode=msvisualcpp 958650bb69Smrgfi 968650bb69Smrg 972c7c4e3dSmrgcase "$depmode" in 982c7c4e3dSmrggcc3) 992c7c4e3dSmrg## gcc 3 implements dependency tracking that does exactly what 1002c7c4e3dSmrg## we want. Yay! Note: for some reason libtool 1.4 doesn't like 1012c7c4e3dSmrg## it if -MD -MP comes after the -MF stuff. Hmm. 1028650bb69Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon 1038650bb69Smrg## the command line argument order; so add the flags where they 1048650bb69Smrg## appear in depend2.am. Note that the slowdown incurred here 1058650bb69Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this. 1068650bb69Smrg for arg 1078650bb69Smrg do 1088650bb69Smrg case $arg in 1098650bb69Smrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1108650bb69Smrg *) set fnord "$@" "$arg" ;; 1118650bb69Smrg esac 1128650bb69Smrg shift # fnord 1138650bb69Smrg shift # $arg 1148650bb69Smrg done 1158650bb69Smrg "$@" 1162c7c4e3dSmrg stat=$? 1172c7c4e3dSmrg if test $stat -eq 0; then : 1182c7c4e3dSmrg else 1192c7c4e3dSmrg rm -f "$tmpdepfile" 1202c7c4e3dSmrg exit $stat 1212c7c4e3dSmrg fi 1222c7c4e3dSmrg mv "$tmpdepfile" "$depfile" 1232c7c4e3dSmrg ;; 1242c7c4e3dSmrg 1252c7c4e3dSmrggcc) 1262c7c4e3dSmrg## There are various ways to get dependency output from gcc. Here's 1272c7c4e3dSmrg## why we pick this rather obscure method: 1282c7c4e3dSmrg## - Don't want to use -MD because we'd like the dependencies to end 1292c7c4e3dSmrg## up in a subdir. Having to rename by hand is ugly. 1302c7c4e3dSmrg## (We might end up doing this anyway to support other compilers.) 1312c7c4e3dSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1322c7c4e3dSmrg## -MM, not -M (despite what the docs say). 1332c7c4e3dSmrg## - Using -M directly means running the compiler twice (even worse 1342c7c4e3dSmrg## than renaming). 1352c7c4e3dSmrg if test -z "$gccflag"; then 1362c7c4e3dSmrg gccflag=-MD, 1372c7c4e3dSmrg fi 1382c7c4e3dSmrg "$@" -Wp,"$gccflag$tmpdepfile" 1392c7c4e3dSmrg stat=$? 1402c7c4e3dSmrg if test $stat -eq 0; then : 1412c7c4e3dSmrg else 1422c7c4e3dSmrg rm -f "$tmpdepfile" 1432c7c4e3dSmrg exit $stat 1442c7c4e3dSmrg fi 1452c7c4e3dSmrg rm -f "$depfile" 1462c7c4e3dSmrg echo "$object : \\" > "$depfile" 1472c7c4e3dSmrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1482c7c4e3dSmrg## The second -e expression handles DOS-style file names with drive letters. 1492c7c4e3dSmrg sed -e 's/^[^:]*: / /' \ 1502c7c4e3dSmrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1512c7c4e3dSmrg## This next piece of magic avoids the `deleted header file' problem. 1522c7c4e3dSmrg## The problem is that when a header file which appears in a .P file 1532c7c4e3dSmrg## is deleted, the dependency causes make to die (because there is 1542c7c4e3dSmrg## typically no way to rebuild the header). We avoid this by adding 1552c7c4e3dSmrg## dummy dependencies for each header file. Too bad gcc doesn't do 1562c7c4e3dSmrg## this for us directly. 1572c7c4e3dSmrg tr ' ' ' 1582c7c4e3dSmrg' < "$tmpdepfile" | 1592c7c4e3dSmrg## Some versions of gcc put a space before the `:'. On the theory 1602c7c4e3dSmrg## that the space means something, we add a space to the output as 1612c7c4e3dSmrg## well. 1622c7c4e3dSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 1632c7c4e3dSmrg## correctly. Breaking it into two sed invocations is a workaround. 1642c7c4e3dSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1652c7c4e3dSmrg rm -f "$tmpdepfile" 1662c7c4e3dSmrg ;; 1672c7c4e3dSmrg 1682c7c4e3dSmrghp) 1692c7c4e3dSmrg # This case exists only to let depend.m4 do its work. It works by 1702c7c4e3dSmrg # looking at the text of this script. This case will never be run, 1712c7c4e3dSmrg # since it is checked for above. 1722c7c4e3dSmrg exit 1 1732c7c4e3dSmrg ;; 1742c7c4e3dSmrg 1752c7c4e3dSmrgsgi) 1762c7c4e3dSmrg if test "$libtool" = yes; then 1772c7c4e3dSmrg "$@" "-Wp,-MDupdate,$tmpdepfile" 1782c7c4e3dSmrg else 1792c7c4e3dSmrg "$@" -MDupdate "$tmpdepfile" 1802c7c4e3dSmrg fi 1812c7c4e3dSmrg stat=$? 1822c7c4e3dSmrg if test $stat -eq 0; then : 1832c7c4e3dSmrg else 1842c7c4e3dSmrg rm -f "$tmpdepfile" 1852c7c4e3dSmrg exit $stat 1862c7c4e3dSmrg fi 1872c7c4e3dSmrg rm -f "$depfile" 1882c7c4e3dSmrg 1892c7c4e3dSmrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1902c7c4e3dSmrg echo "$object : \\" > "$depfile" 1912c7c4e3dSmrg 1922c7c4e3dSmrg # Clip off the initial element (the dependent). Don't try to be 1932c7c4e3dSmrg # clever and replace this with sed code, as IRIX sed won't handle 1942c7c4e3dSmrg # lines with more than a fixed number of characters (4096 in 1952c7c4e3dSmrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1962c7c4e3dSmrg # the IRIX cc adds comments like `#:fec' to the end of the 1972c7c4e3dSmrg # dependency line. 1982c7c4e3dSmrg tr ' ' ' 1992c7c4e3dSmrg' < "$tmpdepfile" \ 2002c7c4e3dSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 2012c7c4e3dSmrg tr ' 2028650bb69Smrg' ' ' >> "$depfile" 2038650bb69Smrg echo >> "$depfile" 2042c7c4e3dSmrg 2052c7c4e3dSmrg # The second pass generates a dummy entry for each header file. 2062c7c4e3dSmrg tr ' ' ' 2072c7c4e3dSmrg' < "$tmpdepfile" \ 2082c7c4e3dSmrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2098650bb69Smrg >> "$depfile" 2102c7c4e3dSmrg else 2112c7c4e3dSmrg # The sourcefile does not contain any dependencies, so just 2122c7c4e3dSmrg # store a dummy comment line, to avoid errors with the Makefile 2132c7c4e3dSmrg # "include basename.Plo" scheme. 2142c7c4e3dSmrg echo "#dummy" > "$depfile" 2152c7c4e3dSmrg fi 2162c7c4e3dSmrg rm -f "$tmpdepfile" 2172c7c4e3dSmrg ;; 2182c7c4e3dSmrg 2192c7c4e3dSmrgaix) 2202c7c4e3dSmrg # The C for AIX Compiler uses -M and outputs the dependencies 2212c7c4e3dSmrg # in a .u file. In older versions, this file always lives in the 2222c7c4e3dSmrg # current directory. Also, the AIX compiler puts `$object:' at the 2232c7c4e3dSmrg # start of each line; $object doesn't have directory information. 2242c7c4e3dSmrg # Version 6 uses the directory in both cases. 2258650bb69Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2268650bb69Smrg test "x$dir" = "x$object" && dir= 2278650bb69Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2282c7c4e3dSmrg if test "$libtool" = yes; then 2298650bb69Smrg tmpdepfile1=$dir$base.u 2308650bb69Smrg tmpdepfile2=$base.u 2318650bb69Smrg tmpdepfile3=$dir.libs/$base.u 2322c7c4e3dSmrg "$@" -Wc,-M 2332c7c4e3dSmrg else 2348650bb69Smrg tmpdepfile1=$dir$base.u 2358650bb69Smrg tmpdepfile2=$dir$base.u 2368650bb69Smrg tmpdepfile3=$dir$base.u 2372c7c4e3dSmrg "$@" -M 2382c7c4e3dSmrg fi 2392c7c4e3dSmrg stat=$? 2402c7c4e3dSmrg 2412c7c4e3dSmrg if test $stat -eq 0; then : 2422c7c4e3dSmrg else 2438650bb69Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2442c7c4e3dSmrg exit $stat 2452c7c4e3dSmrg fi 2462c7c4e3dSmrg 2478650bb69Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2488650bb69Smrg do 2498650bb69Smrg test -f "$tmpdepfile" && break 2508650bb69Smrg done 2512c7c4e3dSmrg if test -f "$tmpdepfile"; then 2522c7c4e3dSmrg # Each line is of the form `foo.o: dependent.h'. 2532c7c4e3dSmrg # Do two passes, one to just change these to 2542c7c4e3dSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 2558650bb69Smrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2568650bb69Smrg # That's a tab and a space in the []. 2578650bb69Smrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 2582c7c4e3dSmrg else 2592c7c4e3dSmrg # The sourcefile does not contain any dependencies, so just 2602c7c4e3dSmrg # store a dummy comment line, to avoid errors with the Makefile 2612c7c4e3dSmrg # "include basename.Plo" scheme. 2622c7c4e3dSmrg echo "#dummy" > "$depfile" 2632c7c4e3dSmrg fi 2642c7c4e3dSmrg rm -f "$tmpdepfile" 2652c7c4e3dSmrg ;; 2662c7c4e3dSmrg 2672c7c4e3dSmrgicc) 2682c7c4e3dSmrg # Intel's C compiler understands `-MD -MF file'. However on 2692c7c4e3dSmrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2702c7c4e3dSmrg # ICC 7.0 will fill foo.d with something like 2712c7c4e3dSmrg # foo.o: sub/foo.c 2722c7c4e3dSmrg # foo.o: sub/foo.h 2732c7c4e3dSmrg # which is wrong. We want: 2742c7c4e3dSmrg # sub/foo.o: sub/foo.c 2752c7c4e3dSmrg # sub/foo.o: sub/foo.h 2762c7c4e3dSmrg # sub/foo.c: 2772c7c4e3dSmrg # sub/foo.h: 2782c7c4e3dSmrg # ICC 7.1 will output 2792c7c4e3dSmrg # foo.o: sub/foo.c sub/foo.h 2802c7c4e3dSmrg # and will wrap long lines using \ : 2812c7c4e3dSmrg # foo.o: sub/foo.c ... \ 2822c7c4e3dSmrg # sub/foo.h ... \ 2832c7c4e3dSmrg # ... 2842c7c4e3dSmrg 2852c7c4e3dSmrg "$@" -MD -MF "$tmpdepfile" 2862c7c4e3dSmrg stat=$? 2872c7c4e3dSmrg if test $stat -eq 0; then : 2882c7c4e3dSmrg else 2892c7c4e3dSmrg rm -f "$tmpdepfile" 2902c7c4e3dSmrg exit $stat 2912c7c4e3dSmrg fi 2922c7c4e3dSmrg rm -f "$depfile" 2932c7c4e3dSmrg # Each line is of the form `foo.o: dependent.h', 2942c7c4e3dSmrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2952c7c4e3dSmrg # Do two passes, one to just change these to 2962c7c4e3dSmrg # `$object: dependent.h' and one to simply `dependent.h:'. 2972c7c4e3dSmrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2982c7c4e3dSmrg # Some versions of the HPUX 10.20 sed can't process this invocation 2992c7c4e3dSmrg # correctly. Breaking it into two sed invocations is a workaround. 3002c7c4e3dSmrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 3012c7c4e3dSmrg sed -e 's/$/ :/' >> "$depfile" 3022c7c4e3dSmrg rm -f "$tmpdepfile" 3032c7c4e3dSmrg ;; 3042c7c4e3dSmrg 3058650bb69Smrghp2) 3068650bb69Smrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3078650bb69Smrg # compilers, which have integrated preprocessors. The correct option 3088650bb69Smrg # to use with these is +Maked; it writes dependencies to a file named 3098650bb69Smrg # 'foo.d', which lands next to the object file, wherever that 3108650bb69Smrg # happens to be. 3118650bb69Smrg # Much of this is similar to the tru64 case; see comments there. 3128650bb69Smrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3138650bb69Smrg test "x$dir" = "x$object" && dir= 3148650bb69Smrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3158650bb69Smrg if test "$libtool" = yes; then 3168650bb69Smrg tmpdepfile1=$dir$base.d 3178650bb69Smrg tmpdepfile2=$dir.libs/$base.d 3188650bb69Smrg "$@" -Wc,+Maked 3198650bb69Smrg else 3208650bb69Smrg tmpdepfile1=$dir$base.d 3218650bb69Smrg tmpdepfile2=$dir$base.d 3228650bb69Smrg "$@" +Maked 3238650bb69Smrg fi 3248650bb69Smrg stat=$? 3258650bb69Smrg if test $stat -eq 0; then : 3268650bb69Smrg else 3278650bb69Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" 3288650bb69Smrg exit $stat 3298650bb69Smrg fi 3308650bb69Smrg 3318650bb69Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3328650bb69Smrg do 3338650bb69Smrg test -f "$tmpdepfile" && break 3348650bb69Smrg done 3358650bb69Smrg if test -f "$tmpdepfile"; then 3368650bb69Smrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3378650bb69Smrg # Add `dependent.h:' lines. 3388650bb69Smrg sed -ne '2,${ 3398650bb69Smrg s/^ *// 3408650bb69Smrg s/ \\*$// 3418650bb69Smrg s/$/:/ 3428650bb69Smrg p 3438650bb69Smrg }' "$tmpdepfile" >> "$depfile" 3448650bb69Smrg else 3458650bb69Smrg echo "#dummy" > "$depfile" 3468650bb69Smrg fi 3478650bb69Smrg rm -f "$tmpdepfile" "$tmpdepfile2" 3488650bb69Smrg ;; 3498650bb69Smrg 3502c7c4e3dSmrgtru64) 3512c7c4e3dSmrg # The Tru64 compiler uses -MD to generate dependencies as a side 3522c7c4e3dSmrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3532c7c4e3dSmrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3542c7c4e3dSmrg # dependencies in `foo.d' instead, so we check for that too. 3552c7c4e3dSmrg # Subdirectories are respected. 3562c7c4e3dSmrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3572c7c4e3dSmrg test "x$dir" = "x$object" && dir= 3582c7c4e3dSmrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3592c7c4e3dSmrg 3602c7c4e3dSmrg if test "$libtool" = yes; then 3618650bb69Smrg # With Tru64 cc, shared objects can also be used to make a 3628650bb69Smrg # static library. This mechanism is used in libtool 1.4 series to 3638650bb69Smrg # handle both shared and static libraries in a single compilation. 3648650bb69Smrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3658650bb69Smrg # 3668650bb69Smrg # With libtool 1.5 this exception was removed, and libtool now 3678650bb69Smrg # generates 2 separate objects for the 2 libraries. These two 3688650bb69Smrg # compilations output dependencies in $dir.libs/$base.o.d and 3698650bb69Smrg # in $dir$base.o.d. We have to check for both files, because 3708650bb69Smrg # one of the two compilations can be disabled. We should prefer 3718650bb69Smrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3728650bb69Smrg # automatically cleaned when .libs/ is deleted, while ignoring 3738650bb69Smrg # the former would cause a distcleancheck panic. 3748650bb69Smrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3758650bb69Smrg tmpdepfile2=$dir$base.o.d # libtool 1.5 3768650bb69Smrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3778650bb69Smrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3782c7c4e3dSmrg "$@" -Wc,-MD 3792c7c4e3dSmrg else 3808650bb69Smrg tmpdepfile1=$dir$base.o.d 3818650bb69Smrg tmpdepfile2=$dir$base.d 3828650bb69Smrg tmpdepfile3=$dir$base.d 3838650bb69Smrg tmpdepfile4=$dir$base.d 3842c7c4e3dSmrg "$@" -MD 3852c7c4e3dSmrg fi 3862c7c4e3dSmrg 3872c7c4e3dSmrg stat=$? 3882c7c4e3dSmrg if test $stat -eq 0; then : 3892c7c4e3dSmrg else 3908650bb69Smrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3912c7c4e3dSmrg exit $stat 3922c7c4e3dSmrg fi 3932c7c4e3dSmrg 3948650bb69Smrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3958650bb69Smrg do 3968650bb69Smrg test -f "$tmpdepfile" && break 3978650bb69Smrg done 3982c7c4e3dSmrg if test -f "$tmpdepfile"; then 3992c7c4e3dSmrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 4002c7c4e3dSmrg # That's a tab and a space in the []. 4012c7c4e3dSmrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 4022c7c4e3dSmrg else 4032c7c4e3dSmrg echo "#dummy" > "$depfile" 4042c7c4e3dSmrg fi 4052c7c4e3dSmrg rm -f "$tmpdepfile" 4062c7c4e3dSmrg ;; 4072c7c4e3dSmrg 4082c7c4e3dSmrg#nosideeffect) 4092c7c4e3dSmrg # This comment above is used by automake to tell side-effect 4102c7c4e3dSmrg # dependency tracking mechanisms from slower ones. 4112c7c4e3dSmrg 4122c7c4e3dSmrgdashmstdout) 4132c7c4e3dSmrg # Important note: in order to support this mode, a compiler *must* 4142c7c4e3dSmrg # always write the preprocessed file to stdout, regardless of -o. 4152c7c4e3dSmrg "$@" || exit $? 4162c7c4e3dSmrg 4172c7c4e3dSmrg # Remove the call to Libtool. 4182c7c4e3dSmrg if test "$libtool" = yes; then 4198650bb69Smrg while test "X$1" != 'X--mode=compile'; do 4202c7c4e3dSmrg shift 4212c7c4e3dSmrg done 4222c7c4e3dSmrg shift 4232c7c4e3dSmrg fi 4242c7c4e3dSmrg 4252c7c4e3dSmrg # Remove `-o $object'. 4262c7c4e3dSmrg IFS=" " 4272c7c4e3dSmrg for arg 4282c7c4e3dSmrg do 4292c7c4e3dSmrg case $arg in 4302c7c4e3dSmrg -o) 4312c7c4e3dSmrg shift 4322c7c4e3dSmrg ;; 4332c7c4e3dSmrg $object) 4342c7c4e3dSmrg shift 4352c7c4e3dSmrg ;; 4362c7c4e3dSmrg *) 4372c7c4e3dSmrg set fnord "$@" "$arg" 4382c7c4e3dSmrg shift # fnord 4392c7c4e3dSmrg shift # $arg 4402c7c4e3dSmrg ;; 4412c7c4e3dSmrg esac 4422c7c4e3dSmrg done 4432c7c4e3dSmrg 4442c7c4e3dSmrg test -z "$dashmflag" && dashmflag=-M 4452c7c4e3dSmrg # Require at least two characters before searching for `:' 4462c7c4e3dSmrg # in the target name. This is to cope with DOS-style filenames: 4472c7c4e3dSmrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4482c7c4e3dSmrg "$@" $dashmflag | 4492c7c4e3dSmrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4502c7c4e3dSmrg rm -f "$depfile" 4512c7c4e3dSmrg cat < "$tmpdepfile" > "$depfile" 4522c7c4e3dSmrg tr ' ' ' 4532c7c4e3dSmrg' < "$tmpdepfile" | \ 4542c7c4e3dSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 4552c7c4e3dSmrg## correctly. Breaking it into two sed invocations is a workaround. 4562c7c4e3dSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4572c7c4e3dSmrg rm -f "$tmpdepfile" 4582c7c4e3dSmrg ;; 4592c7c4e3dSmrg 4602c7c4e3dSmrgdashXmstdout) 4612c7c4e3dSmrg # This case only exists to satisfy depend.m4. It is never actually 4622c7c4e3dSmrg # run, as this mode is specially recognized in the preamble. 4632c7c4e3dSmrg exit 1 4642c7c4e3dSmrg ;; 4652c7c4e3dSmrg 4662c7c4e3dSmrgmakedepend) 4672c7c4e3dSmrg "$@" || exit $? 4682c7c4e3dSmrg # Remove any Libtool call 4692c7c4e3dSmrg if test "$libtool" = yes; then 4708650bb69Smrg while test "X$1" != 'X--mode=compile'; do 4712c7c4e3dSmrg shift 4722c7c4e3dSmrg done 4732c7c4e3dSmrg shift 4742c7c4e3dSmrg fi 4752c7c4e3dSmrg # X makedepend 4762c7c4e3dSmrg shift 4778650bb69Smrg cleared=no eat=no 4788650bb69Smrg for arg 4798650bb69Smrg do 4802c7c4e3dSmrg case $cleared in 4812c7c4e3dSmrg no) 4822c7c4e3dSmrg set ""; shift 4832c7c4e3dSmrg cleared=yes ;; 4842c7c4e3dSmrg esac 4858650bb69Smrg if test $eat = yes; then 4868650bb69Smrg eat=no 4878650bb69Smrg continue 4888650bb69Smrg fi 4892c7c4e3dSmrg case "$arg" in 4902c7c4e3dSmrg -D*|-I*) 4912c7c4e3dSmrg set fnord "$@" "$arg"; shift ;; 4922c7c4e3dSmrg # Strip any option that makedepend may not understand. Remove 4932c7c4e3dSmrg # the object too, otherwise makedepend will parse it as a source file. 4948650bb69Smrg -arch) 4958650bb69Smrg eat=yes ;; 4962c7c4e3dSmrg -*|$object) 4972c7c4e3dSmrg ;; 4982c7c4e3dSmrg *) 4992c7c4e3dSmrg set fnord "$@" "$arg"; shift ;; 5002c7c4e3dSmrg esac 5012c7c4e3dSmrg done 5028650bb69Smrg obj_suffix=`echo "$object" | sed 's/^.*\././'` 5032c7c4e3dSmrg touch "$tmpdepfile" 5042c7c4e3dSmrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 5052c7c4e3dSmrg rm -f "$depfile" 5062c7c4e3dSmrg cat < "$tmpdepfile" > "$depfile" 5072c7c4e3dSmrg sed '1,2d' "$tmpdepfile" | tr ' ' ' 5082c7c4e3dSmrg' | \ 5092c7c4e3dSmrg## Some versions of the HPUX 10.20 sed can't process this invocation 5102c7c4e3dSmrg## correctly. Breaking it into two sed invocations is a workaround. 5112c7c4e3dSmrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 5122c7c4e3dSmrg rm -f "$tmpdepfile" "$tmpdepfile".bak 5132c7c4e3dSmrg ;; 5142c7c4e3dSmrg 5152c7c4e3dSmrgcpp) 5162c7c4e3dSmrg # Important note: in order to support this mode, a compiler *must* 5172c7c4e3dSmrg # always write the preprocessed file to stdout. 5182c7c4e3dSmrg "$@" || exit $? 5192c7c4e3dSmrg 5202c7c4e3dSmrg # Remove the call to Libtool. 5212c7c4e3dSmrg if test "$libtool" = yes; then 5228650bb69Smrg while test "X$1" != 'X--mode=compile'; do 5232c7c4e3dSmrg shift 5242c7c4e3dSmrg done 5252c7c4e3dSmrg shift 5262c7c4e3dSmrg fi 5272c7c4e3dSmrg 5282c7c4e3dSmrg # Remove `-o $object'. 5292c7c4e3dSmrg IFS=" " 5302c7c4e3dSmrg for arg 5312c7c4e3dSmrg do 5322c7c4e3dSmrg case $arg in 5332c7c4e3dSmrg -o) 5342c7c4e3dSmrg shift 5352c7c4e3dSmrg ;; 5362c7c4e3dSmrg $object) 5372c7c4e3dSmrg shift 5382c7c4e3dSmrg ;; 5392c7c4e3dSmrg *) 5402c7c4e3dSmrg set fnord "$@" "$arg" 5412c7c4e3dSmrg shift # fnord 5422c7c4e3dSmrg shift # $arg 5432c7c4e3dSmrg ;; 5442c7c4e3dSmrg esac 5452c7c4e3dSmrg done 5462c7c4e3dSmrg 5472c7c4e3dSmrg "$@" -E | 5488650bb69Smrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5498650bb69Smrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5502c7c4e3dSmrg sed '$ s: \\$::' > "$tmpdepfile" 5512c7c4e3dSmrg rm -f "$depfile" 5522c7c4e3dSmrg echo "$object : \\" > "$depfile" 5532c7c4e3dSmrg cat < "$tmpdepfile" >> "$depfile" 5542c7c4e3dSmrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5552c7c4e3dSmrg rm -f "$tmpdepfile" 5562c7c4e3dSmrg ;; 5572c7c4e3dSmrg 5582c7c4e3dSmrgmsvisualcpp) 5592c7c4e3dSmrg # Important note: in order to support this mode, a compiler *must* 5608650bb69Smrg # always write the preprocessed file to stdout. 5612c7c4e3dSmrg "$@" || exit $? 5628650bb69Smrg 5638650bb69Smrg # Remove the call to Libtool. 5648650bb69Smrg if test "$libtool" = yes; then 5658650bb69Smrg while test "X$1" != 'X--mode=compile'; do 5668650bb69Smrg shift 5678650bb69Smrg done 5688650bb69Smrg shift 5698650bb69Smrg fi 5708650bb69Smrg 5712c7c4e3dSmrg IFS=" " 5722c7c4e3dSmrg for arg 5732c7c4e3dSmrg do 5742c7c4e3dSmrg case "$arg" in 5758650bb69Smrg -o) 5768650bb69Smrg shift 5778650bb69Smrg ;; 5788650bb69Smrg $object) 5798650bb69Smrg shift 5808650bb69Smrg ;; 5812c7c4e3dSmrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5822c7c4e3dSmrg set fnord "$@" 5832c7c4e3dSmrg shift 5842c7c4e3dSmrg shift 5852c7c4e3dSmrg ;; 5862c7c4e3dSmrg *) 5872c7c4e3dSmrg set fnord "$@" "$arg" 5882c7c4e3dSmrg shift 5892c7c4e3dSmrg shift 5902c7c4e3dSmrg ;; 5912c7c4e3dSmrg esac 5922c7c4e3dSmrg done 5938650bb69Smrg "$@" -E 2>/dev/null | 5948650bb69Smrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 5952c7c4e3dSmrg rm -f "$depfile" 5962c7c4e3dSmrg echo "$object : \\" > "$depfile" 5978650bb69Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5982c7c4e3dSmrg echo " " >> "$depfile" 5998650bb69Smrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 6002c7c4e3dSmrg rm -f "$tmpdepfile" 6012c7c4e3dSmrg ;; 6022c7c4e3dSmrg 6038650bb69Smrgmsvcmsys) 6048650bb69Smrg # This case exists only to let depend.m4 do its work. It works by 6058650bb69Smrg # looking at the text of this script. This case will never be run, 6068650bb69Smrg # since it is checked for above. 6078650bb69Smrg exit 1 6088650bb69Smrg ;; 6098650bb69Smrg 6102c7c4e3dSmrgnone) 6112c7c4e3dSmrg exec "$@" 6122c7c4e3dSmrg ;; 6132c7c4e3dSmrg 6142c7c4e3dSmrg*) 6152c7c4e3dSmrg echo "Unknown depmode $depmode" 1>&2 6162c7c4e3dSmrg exit 1 6172c7c4e3dSmrg ;; 6182c7c4e3dSmrgesac 6192c7c4e3dSmrg 6202c7c4e3dSmrgexit 0 6218650bb69Smrg 6228650bb69Smrg# Local Variables: 6238650bb69Smrg# mode: shell-script 6248650bb69Smrg# sh-indentation: 2 6258650bb69Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 6268650bb69Smrg# time-stamp-start: "scriptversion=" 6278650bb69Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 6288650bb69Smrg# time-stamp-time-zone: "UTC" 6298650bb69Smrg# time-stamp-end: "; # UTC" 6308650bb69Smrg# End: 631