depcomp revision 4a041c5b
14a041c5bSmacallan#! /bin/sh 24a041c5bSmacallan# depcomp - compile a program generating dependencies as side-effects 34a041c5bSmacallan 44a041c5bSmacallanscriptversion=2007-03-29.01 54a041c5bSmacallan 64a041c5bSmacallan# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software 74a041c5bSmacallan# Foundation, Inc. 84a041c5bSmacallan 94a041c5bSmacallan# This program is free software; you can redistribute it and/or modify 104a041c5bSmacallan# it under the terms of the GNU General Public License as published by 114a041c5bSmacallan# the Free Software Foundation; either version 2, or (at your option) 124a041c5bSmacallan# any later version. 134a041c5bSmacallan 144a041c5bSmacallan# This program is distributed in the hope that it will be useful, 154a041c5bSmacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of 164a041c5bSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 174a041c5bSmacallan# GNU General Public License for more details. 184a041c5bSmacallan 194a041c5bSmacallan# You should have received a copy of the GNU General Public License 204a041c5bSmacallan# along with this program; if not, write to the Free Software 214a041c5bSmacallan# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 224a041c5bSmacallan# 02110-1301, USA. 234a041c5bSmacallan 244a041c5bSmacallan# As a special exception to the GNU General Public License, if you 254a041c5bSmacallan# distribute this file as part of a program that contains a 264a041c5bSmacallan# configuration script generated by Autoconf, you may include it under 274a041c5bSmacallan# the same distribution terms that you use for the rest of that program. 284a041c5bSmacallan 294a041c5bSmacallan# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. 304a041c5bSmacallan 314a041c5bSmacallancase $1 in 324a041c5bSmacallan '') 334a041c5bSmacallan echo "$0: No command. Try \`$0 --help' for more information." 1>&2 344a041c5bSmacallan exit 1; 354a041c5bSmacallan ;; 364a041c5bSmacallan -h | --h*) 374a041c5bSmacallan cat <<\EOF 384a041c5bSmacallanUsage: depcomp [--help] [--version] PROGRAM [ARGS] 394a041c5bSmacallan 404a041c5bSmacallanRun PROGRAMS ARGS to compile a file, generating dependencies 414a041c5bSmacallanas side-effects. 424a041c5bSmacallan 434a041c5bSmacallanEnvironment variables: 444a041c5bSmacallan depmode Dependency tracking mode. 454a041c5bSmacallan source Source file read by `PROGRAMS ARGS'. 464a041c5bSmacallan object Object file output by `PROGRAMS ARGS'. 474a041c5bSmacallan DEPDIR directory where to store dependencies. 484a041c5bSmacallan depfile Dependency file to output. 494a041c5bSmacallan tmpdepfile Temporary file to use when outputing dependencies. 504a041c5bSmacallan libtool Whether libtool is used (yes/no). 514a041c5bSmacallan 524a041c5bSmacallanReport bugs to <bug-automake@gnu.org>. 534a041c5bSmacallanEOF 544a041c5bSmacallan exit $? 554a041c5bSmacallan ;; 564a041c5bSmacallan -v | --v*) 574a041c5bSmacallan echo "depcomp $scriptversion" 584a041c5bSmacallan exit $? 594a041c5bSmacallan ;; 604a041c5bSmacallanesac 614a041c5bSmacallan 624a041c5bSmacallanif test -z "$depmode" || test -z "$source" || test -z "$object"; then 634a041c5bSmacallan echo "depcomp: Variables source, object and depmode must be set" 1>&2 644a041c5bSmacallan exit 1 654a041c5bSmacallanfi 664a041c5bSmacallan 674a041c5bSmacallan# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 684a041c5bSmacallandepfile=${depfile-`echo "$object" | 694a041c5bSmacallan sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 704a041c5bSmacallantmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 714a041c5bSmacallan 724a041c5bSmacallanrm -f "$tmpdepfile" 734a041c5bSmacallan 744a041c5bSmacallan# Some modes work just like other modes, but use different flags. We 754a041c5bSmacallan# parameterize here, but still list the modes in the big case below, 764a041c5bSmacallan# to make depend.m4 easier to write. Note that we *cannot* use a case 774a041c5bSmacallan# here, because this file can only contain one case statement. 784a041c5bSmacallanif test "$depmode" = hp; then 794a041c5bSmacallan # HP compiler uses -M and no extra arg. 804a041c5bSmacallan gccflag=-M 814a041c5bSmacallan depmode=gcc 824a041c5bSmacallanfi 834a041c5bSmacallan 844a041c5bSmacallanif test "$depmode" = dashXmstdout; then 854a041c5bSmacallan # This is just like dashmstdout with a different argument. 864a041c5bSmacallan dashmflag=-xM 874a041c5bSmacallan depmode=dashmstdout 884a041c5bSmacallanfi 894a041c5bSmacallan 904a041c5bSmacallancase "$depmode" in 914a041c5bSmacallangcc3) 924a041c5bSmacallan## gcc 3 implements dependency tracking that does exactly what 934a041c5bSmacallan## we want. Yay! Note: for some reason libtool 1.4 doesn't like 944a041c5bSmacallan## it if -MD -MP comes after the -MF stuff. Hmm. 954a041c5bSmacallan## Unfortunately, FreeBSD c89 acceptance of flags depends upon 964a041c5bSmacallan## the command line argument order; so add the flags where they 974a041c5bSmacallan## appear in depend2.am. Note that the slowdown incurred here 984a041c5bSmacallan## affects only configure: in makefiles, %FASTDEP% shortcuts this. 994a041c5bSmacallan for arg 1004a041c5bSmacallan do 1014a041c5bSmacallan case $arg in 1024a041c5bSmacallan -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 1034a041c5bSmacallan *) set fnord "$@" "$arg" ;; 1044a041c5bSmacallan esac 1054a041c5bSmacallan shift # fnord 1064a041c5bSmacallan shift # $arg 1074a041c5bSmacallan done 1084a041c5bSmacallan "$@" 1094a041c5bSmacallan stat=$? 1104a041c5bSmacallan if test $stat -eq 0; then : 1114a041c5bSmacallan else 1124a041c5bSmacallan rm -f "$tmpdepfile" 1134a041c5bSmacallan exit $stat 1144a041c5bSmacallan fi 1154a041c5bSmacallan mv "$tmpdepfile" "$depfile" 1164a041c5bSmacallan ;; 1174a041c5bSmacallan 1184a041c5bSmacallangcc) 1194a041c5bSmacallan## There are various ways to get dependency output from gcc. Here's 1204a041c5bSmacallan## why we pick this rather obscure method: 1214a041c5bSmacallan## - Don't want to use -MD because we'd like the dependencies to end 1224a041c5bSmacallan## up in a subdir. Having to rename by hand is ugly. 1234a041c5bSmacallan## (We might end up doing this anyway to support other compilers.) 1244a041c5bSmacallan## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 1254a041c5bSmacallan## -MM, not -M (despite what the docs say). 1264a041c5bSmacallan## - Using -M directly means running the compiler twice (even worse 1274a041c5bSmacallan## than renaming). 1284a041c5bSmacallan if test -z "$gccflag"; then 1294a041c5bSmacallan gccflag=-MD, 1304a041c5bSmacallan fi 1314a041c5bSmacallan "$@" -Wp,"$gccflag$tmpdepfile" 1324a041c5bSmacallan stat=$? 1334a041c5bSmacallan if test $stat -eq 0; then : 1344a041c5bSmacallan else 1354a041c5bSmacallan rm -f "$tmpdepfile" 1364a041c5bSmacallan exit $stat 1374a041c5bSmacallan fi 1384a041c5bSmacallan rm -f "$depfile" 1394a041c5bSmacallan echo "$object : \\" > "$depfile" 1404a041c5bSmacallan alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 1414a041c5bSmacallan## The second -e expression handles DOS-style file names with drive letters. 1424a041c5bSmacallan sed -e 's/^[^:]*: / /' \ 1434a041c5bSmacallan -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 1444a041c5bSmacallan## This next piece of magic avoids the `deleted header file' problem. 1454a041c5bSmacallan## The problem is that when a header file which appears in a .P file 1464a041c5bSmacallan## is deleted, the dependency causes make to die (because there is 1474a041c5bSmacallan## typically no way to rebuild the header). We avoid this by adding 1484a041c5bSmacallan## dummy dependencies for each header file. Too bad gcc doesn't do 1494a041c5bSmacallan## this for us directly. 1504a041c5bSmacallan tr ' ' ' 1514a041c5bSmacallan' < "$tmpdepfile" | 1524a041c5bSmacallan## Some versions of gcc put a space before the `:'. On the theory 1534a041c5bSmacallan## that the space means something, we add a space to the output as 1544a041c5bSmacallan## well. 1554a041c5bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation 1564a041c5bSmacallan## correctly. Breaking it into two sed invocations is a workaround. 1574a041c5bSmacallan sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 1584a041c5bSmacallan rm -f "$tmpdepfile" 1594a041c5bSmacallan ;; 1604a041c5bSmacallan 1614a041c5bSmacallanhp) 1624a041c5bSmacallan # This case exists only to let depend.m4 do its work. It works by 1634a041c5bSmacallan # looking at the text of this script. This case will never be run, 1644a041c5bSmacallan # since it is checked for above. 1654a041c5bSmacallan exit 1 1664a041c5bSmacallan ;; 1674a041c5bSmacallan 1684a041c5bSmacallansgi) 1694a041c5bSmacallan if test "$libtool" = yes; then 1704a041c5bSmacallan "$@" "-Wp,-MDupdate,$tmpdepfile" 1714a041c5bSmacallan else 1724a041c5bSmacallan "$@" -MDupdate "$tmpdepfile" 1734a041c5bSmacallan fi 1744a041c5bSmacallan stat=$? 1754a041c5bSmacallan if test $stat -eq 0; then : 1764a041c5bSmacallan else 1774a041c5bSmacallan rm -f "$tmpdepfile" 1784a041c5bSmacallan exit $stat 1794a041c5bSmacallan fi 1804a041c5bSmacallan rm -f "$depfile" 1814a041c5bSmacallan 1824a041c5bSmacallan if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 1834a041c5bSmacallan echo "$object : \\" > "$depfile" 1844a041c5bSmacallan 1854a041c5bSmacallan # Clip off the initial element (the dependent). Don't try to be 1864a041c5bSmacallan # clever and replace this with sed code, as IRIX sed won't handle 1874a041c5bSmacallan # lines with more than a fixed number of characters (4096 in 1884a041c5bSmacallan # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 1894a041c5bSmacallan # the IRIX cc adds comments like `#:fec' to the end of the 1904a041c5bSmacallan # dependency line. 1914a041c5bSmacallan tr ' ' ' 1924a041c5bSmacallan' < "$tmpdepfile" \ 1934a041c5bSmacallan | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 1944a041c5bSmacallan tr ' 1954a041c5bSmacallan' ' ' >> $depfile 1964a041c5bSmacallan echo >> $depfile 1974a041c5bSmacallan 1984a041c5bSmacallan # The second pass generates a dummy entry for each header file. 1994a041c5bSmacallan tr ' ' ' 2004a041c5bSmacallan' < "$tmpdepfile" \ 2014a041c5bSmacallan | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 2024a041c5bSmacallan >> $depfile 2034a041c5bSmacallan else 2044a041c5bSmacallan # The sourcefile does not contain any dependencies, so just 2054a041c5bSmacallan # store a dummy comment line, to avoid errors with the Makefile 2064a041c5bSmacallan # "include basename.Plo" scheme. 2074a041c5bSmacallan echo "#dummy" > "$depfile" 2084a041c5bSmacallan fi 2094a041c5bSmacallan rm -f "$tmpdepfile" 2104a041c5bSmacallan ;; 2114a041c5bSmacallan 2124a041c5bSmacallanaix) 2134a041c5bSmacallan # The C for AIX Compiler uses -M and outputs the dependencies 2144a041c5bSmacallan # in a .u file. In older versions, this file always lives in the 2154a041c5bSmacallan # current directory. Also, the AIX compiler puts `$object:' at the 2164a041c5bSmacallan # start of each line; $object doesn't have directory information. 2174a041c5bSmacallan # Version 6 uses the directory in both cases. 2184a041c5bSmacallan dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 2194a041c5bSmacallan test "x$dir" = "x$object" && dir= 2204a041c5bSmacallan base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 2214a041c5bSmacallan if test "$libtool" = yes; then 2224a041c5bSmacallan tmpdepfile1=$dir$base.u 2234a041c5bSmacallan tmpdepfile2=$base.u 2244a041c5bSmacallan tmpdepfile3=$dir.libs/$base.u 2254a041c5bSmacallan "$@" -Wc,-M 2264a041c5bSmacallan else 2274a041c5bSmacallan tmpdepfile1=$dir$base.u 2284a041c5bSmacallan tmpdepfile2=$dir$base.u 2294a041c5bSmacallan tmpdepfile3=$dir$base.u 2304a041c5bSmacallan "$@" -M 2314a041c5bSmacallan fi 2324a041c5bSmacallan stat=$? 2334a041c5bSmacallan 2344a041c5bSmacallan if test $stat -eq 0; then : 2354a041c5bSmacallan else 2364a041c5bSmacallan rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2374a041c5bSmacallan exit $stat 2384a041c5bSmacallan fi 2394a041c5bSmacallan 2404a041c5bSmacallan for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 2414a041c5bSmacallan do 2424a041c5bSmacallan test -f "$tmpdepfile" && break 2434a041c5bSmacallan done 2444a041c5bSmacallan if test -f "$tmpdepfile"; then 2454a041c5bSmacallan # Each line is of the form `foo.o: dependent.h'. 2464a041c5bSmacallan # Do two passes, one to just change these to 2474a041c5bSmacallan # `$object: dependent.h' and one to simply `dependent.h:'. 2484a041c5bSmacallan sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 2494a041c5bSmacallan # That's a tab and a space in the []. 2504a041c5bSmacallan sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 2514a041c5bSmacallan else 2524a041c5bSmacallan # The sourcefile does not contain any dependencies, so just 2534a041c5bSmacallan # store a dummy comment line, to avoid errors with the Makefile 2544a041c5bSmacallan # "include basename.Plo" scheme. 2554a041c5bSmacallan echo "#dummy" > "$depfile" 2564a041c5bSmacallan fi 2574a041c5bSmacallan rm -f "$tmpdepfile" 2584a041c5bSmacallan ;; 2594a041c5bSmacallan 2604a041c5bSmacallanicc) 2614a041c5bSmacallan # Intel's C compiler understands `-MD -MF file'. However on 2624a041c5bSmacallan # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 2634a041c5bSmacallan # ICC 7.0 will fill foo.d with something like 2644a041c5bSmacallan # foo.o: sub/foo.c 2654a041c5bSmacallan # foo.o: sub/foo.h 2664a041c5bSmacallan # which is wrong. We want: 2674a041c5bSmacallan # sub/foo.o: sub/foo.c 2684a041c5bSmacallan # sub/foo.o: sub/foo.h 2694a041c5bSmacallan # sub/foo.c: 2704a041c5bSmacallan # sub/foo.h: 2714a041c5bSmacallan # ICC 7.1 will output 2724a041c5bSmacallan # foo.o: sub/foo.c sub/foo.h 2734a041c5bSmacallan # and will wrap long lines using \ : 2744a041c5bSmacallan # foo.o: sub/foo.c ... \ 2754a041c5bSmacallan # sub/foo.h ... \ 2764a041c5bSmacallan # ... 2774a041c5bSmacallan 2784a041c5bSmacallan "$@" -MD -MF "$tmpdepfile" 2794a041c5bSmacallan stat=$? 2804a041c5bSmacallan if test $stat -eq 0; then : 2814a041c5bSmacallan else 2824a041c5bSmacallan rm -f "$tmpdepfile" 2834a041c5bSmacallan exit $stat 2844a041c5bSmacallan fi 2854a041c5bSmacallan rm -f "$depfile" 2864a041c5bSmacallan # Each line is of the form `foo.o: dependent.h', 2874a041c5bSmacallan # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 2884a041c5bSmacallan # Do two passes, one to just change these to 2894a041c5bSmacallan # `$object: dependent.h' and one to simply `dependent.h:'. 2904a041c5bSmacallan sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 2914a041c5bSmacallan # Some versions of the HPUX 10.20 sed can't process this invocation 2924a041c5bSmacallan # correctly. Breaking it into two sed invocations is a workaround. 2934a041c5bSmacallan sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 2944a041c5bSmacallan sed -e 's/$/ :/' >> "$depfile" 2954a041c5bSmacallan rm -f "$tmpdepfile" 2964a041c5bSmacallan ;; 2974a041c5bSmacallan 2984a041c5bSmacallanhp2) 2994a041c5bSmacallan # The "hp" stanza above does not work with aCC (C++) and HP's ia64 3004a041c5bSmacallan # compilers, which have integrated preprocessors. The correct option 3014a041c5bSmacallan # to use with these is +Maked; it writes dependencies to a file named 3024a041c5bSmacallan # 'foo.d', which lands next to the object file, wherever that 3034a041c5bSmacallan # happens to be. 3044a041c5bSmacallan # Much of this is similar to the tru64 case; see comments there. 3054a041c5bSmacallan dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3064a041c5bSmacallan test "x$dir" = "x$object" && dir= 3074a041c5bSmacallan base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3084a041c5bSmacallan if test "$libtool" = yes; then 3094a041c5bSmacallan tmpdepfile1=$dir$base.d 3104a041c5bSmacallan tmpdepfile2=$dir.libs/$base.d 3114a041c5bSmacallan "$@" -Wc,+Maked 3124a041c5bSmacallan else 3134a041c5bSmacallan tmpdepfile1=$dir$base.d 3144a041c5bSmacallan tmpdepfile2=$dir$base.d 3154a041c5bSmacallan "$@" +Maked 3164a041c5bSmacallan fi 3174a041c5bSmacallan stat=$? 3184a041c5bSmacallan if test $stat -eq 0; then : 3194a041c5bSmacallan else 3204a041c5bSmacallan rm -f "$tmpdepfile1" "$tmpdepfile2" 3214a041c5bSmacallan exit $stat 3224a041c5bSmacallan fi 3234a041c5bSmacallan 3244a041c5bSmacallan for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 3254a041c5bSmacallan do 3264a041c5bSmacallan test -f "$tmpdepfile" && break 3274a041c5bSmacallan done 3284a041c5bSmacallan if test -f "$tmpdepfile"; then 3294a041c5bSmacallan sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 3304a041c5bSmacallan # Add `dependent.h:' lines. 3314a041c5bSmacallan sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" 3324a041c5bSmacallan else 3334a041c5bSmacallan echo "#dummy" > "$depfile" 3344a041c5bSmacallan fi 3354a041c5bSmacallan rm -f "$tmpdepfile" "$tmpdepfile2" 3364a041c5bSmacallan ;; 3374a041c5bSmacallan 3384a041c5bSmacallantru64) 3394a041c5bSmacallan # The Tru64 compiler uses -MD to generate dependencies as a side 3404a041c5bSmacallan # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 3414a041c5bSmacallan # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 3424a041c5bSmacallan # dependencies in `foo.d' instead, so we check for that too. 3434a041c5bSmacallan # Subdirectories are respected. 3444a041c5bSmacallan dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 3454a041c5bSmacallan test "x$dir" = "x$object" && dir= 3464a041c5bSmacallan base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 3474a041c5bSmacallan 3484a041c5bSmacallan if test "$libtool" = yes; then 3494a041c5bSmacallan # With Tru64 cc, shared objects can also be used to make a 3504a041c5bSmacallan # static library. This mechanism is used in libtool 1.4 series to 3514a041c5bSmacallan # handle both shared and static libraries in a single compilation. 3524a041c5bSmacallan # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 3534a041c5bSmacallan # 3544a041c5bSmacallan # With libtool 1.5 this exception was removed, and libtool now 3554a041c5bSmacallan # generates 2 separate objects for the 2 libraries. These two 3564a041c5bSmacallan # compilations output dependencies in $dir.libs/$base.o.d and 3574a041c5bSmacallan # in $dir$base.o.d. We have to check for both files, because 3584a041c5bSmacallan # one of the two compilations can be disabled. We should prefer 3594a041c5bSmacallan # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 3604a041c5bSmacallan # automatically cleaned when .libs/ is deleted, while ignoring 3614a041c5bSmacallan # the former would cause a distcleancheck panic. 3624a041c5bSmacallan tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 3634a041c5bSmacallan tmpdepfile2=$dir$base.o.d # libtool 1.5 3644a041c5bSmacallan tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 3654a041c5bSmacallan tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 3664a041c5bSmacallan "$@" -Wc,-MD 3674a041c5bSmacallan else 3684a041c5bSmacallan tmpdepfile1=$dir$base.o.d 3694a041c5bSmacallan tmpdepfile2=$dir$base.d 3704a041c5bSmacallan tmpdepfile3=$dir$base.d 3714a041c5bSmacallan tmpdepfile4=$dir$base.d 3724a041c5bSmacallan "$@" -MD 3734a041c5bSmacallan fi 3744a041c5bSmacallan 3754a041c5bSmacallan stat=$? 3764a041c5bSmacallan if test $stat -eq 0; then : 3774a041c5bSmacallan else 3784a041c5bSmacallan rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3794a041c5bSmacallan exit $stat 3804a041c5bSmacallan fi 3814a041c5bSmacallan 3824a041c5bSmacallan for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 3834a041c5bSmacallan do 3844a041c5bSmacallan test -f "$tmpdepfile" && break 3854a041c5bSmacallan done 3864a041c5bSmacallan if test -f "$tmpdepfile"; then 3874a041c5bSmacallan sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 3884a041c5bSmacallan # That's a tab and a space in the []. 3894a041c5bSmacallan sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 3904a041c5bSmacallan else 3914a041c5bSmacallan echo "#dummy" > "$depfile" 3924a041c5bSmacallan fi 3934a041c5bSmacallan rm -f "$tmpdepfile" 3944a041c5bSmacallan ;; 3954a041c5bSmacallan 3964a041c5bSmacallan#nosideeffect) 3974a041c5bSmacallan # This comment above is used by automake to tell side-effect 3984a041c5bSmacallan # dependency tracking mechanisms from slower ones. 3994a041c5bSmacallan 4004a041c5bSmacallandashmstdout) 4014a041c5bSmacallan # Important note: in order to support this mode, a compiler *must* 4024a041c5bSmacallan # always write the preprocessed file to stdout, regardless of -o. 4034a041c5bSmacallan "$@" || exit $? 4044a041c5bSmacallan 4054a041c5bSmacallan # Remove the call to Libtool. 4064a041c5bSmacallan if test "$libtool" = yes; then 4074a041c5bSmacallan while test $1 != '--mode=compile'; do 4084a041c5bSmacallan shift 4094a041c5bSmacallan done 4104a041c5bSmacallan shift 4114a041c5bSmacallan fi 4124a041c5bSmacallan 4134a041c5bSmacallan # Remove `-o $object'. 4144a041c5bSmacallan IFS=" " 4154a041c5bSmacallan for arg 4164a041c5bSmacallan do 4174a041c5bSmacallan case $arg in 4184a041c5bSmacallan -o) 4194a041c5bSmacallan shift 4204a041c5bSmacallan ;; 4214a041c5bSmacallan $object) 4224a041c5bSmacallan shift 4234a041c5bSmacallan ;; 4244a041c5bSmacallan *) 4254a041c5bSmacallan set fnord "$@" "$arg" 4264a041c5bSmacallan shift # fnord 4274a041c5bSmacallan shift # $arg 4284a041c5bSmacallan ;; 4294a041c5bSmacallan esac 4304a041c5bSmacallan done 4314a041c5bSmacallan 4324a041c5bSmacallan test -z "$dashmflag" && dashmflag=-M 4334a041c5bSmacallan # Require at least two characters before searching for `:' 4344a041c5bSmacallan # in the target name. This is to cope with DOS-style filenames: 4354a041c5bSmacallan # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 4364a041c5bSmacallan "$@" $dashmflag | 4374a041c5bSmacallan sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 4384a041c5bSmacallan rm -f "$depfile" 4394a041c5bSmacallan cat < "$tmpdepfile" > "$depfile" 4404a041c5bSmacallan tr ' ' ' 4414a041c5bSmacallan' < "$tmpdepfile" | \ 4424a041c5bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation 4434a041c5bSmacallan## correctly. Breaking it into two sed invocations is a workaround. 4444a041c5bSmacallan sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4454a041c5bSmacallan rm -f "$tmpdepfile" 4464a041c5bSmacallan ;; 4474a041c5bSmacallan 4484a041c5bSmacallandashXmstdout) 4494a041c5bSmacallan # This case only exists to satisfy depend.m4. It is never actually 4504a041c5bSmacallan # run, as this mode is specially recognized in the preamble. 4514a041c5bSmacallan exit 1 4524a041c5bSmacallan ;; 4534a041c5bSmacallan 4544a041c5bSmacallanmakedepend) 4554a041c5bSmacallan "$@" || exit $? 4564a041c5bSmacallan # Remove any Libtool call 4574a041c5bSmacallan if test "$libtool" = yes; then 4584a041c5bSmacallan while test $1 != '--mode=compile'; do 4594a041c5bSmacallan shift 4604a041c5bSmacallan done 4614a041c5bSmacallan shift 4624a041c5bSmacallan fi 4634a041c5bSmacallan # X makedepend 4644a041c5bSmacallan shift 4654a041c5bSmacallan cleared=no 4664a041c5bSmacallan for arg in "$@"; do 4674a041c5bSmacallan case $cleared in 4684a041c5bSmacallan no) 4694a041c5bSmacallan set ""; shift 4704a041c5bSmacallan cleared=yes ;; 4714a041c5bSmacallan esac 4724a041c5bSmacallan case "$arg" in 4734a041c5bSmacallan -D*|-I*) 4744a041c5bSmacallan set fnord "$@" "$arg"; shift ;; 4754a041c5bSmacallan # Strip any option that makedepend may not understand. Remove 4764a041c5bSmacallan # the object too, otherwise makedepend will parse it as a source file. 4774a041c5bSmacallan -*|$object) 4784a041c5bSmacallan ;; 4794a041c5bSmacallan *) 4804a041c5bSmacallan set fnord "$@" "$arg"; shift ;; 4814a041c5bSmacallan esac 4824a041c5bSmacallan done 4834a041c5bSmacallan obj_suffix="`echo $object | sed 's/^.*\././'`" 4844a041c5bSmacallan touch "$tmpdepfile" 4854a041c5bSmacallan ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 4864a041c5bSmacallan rm -f "$depfile" 4874a041c5bSmacallan cat < "$tmpdepfile" > "$depfile" 4884a041c5bSmacallan sed '1,2d' "$tmpdepfile" | tr ' ' ' 4894a041c5bSmacallan' | \ 4904a041c5bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation 4914a041c5bSmacallan## correctly. Breaking it into two sed invocations is a workaround. 4924a041c5bSmacallan sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 4934a041c5bSmacallan rm -f "$tmpdepfile" "$tmpdepfile".bak 4944a041c5bSmacallan ;; 4954a041c5bSmacallan 4964a041c5bSmacallancpp) 4974a041c5bSmacallan # Important note: in order to support this mode, a compiler *must* 4984a041c5bSmacallan # always write the preprocessed file to stdout. 4994a041c5bSmacallan "$@" || exit $? 5004a041c5bSmacallan 5014a041c5bSmacallan # Remove the call to Libtool. 5024a041c5bSmacallan if test "$libtool" = yes; then 5034a041c5bSmacallan while test $1 != '--mode=compile'; do 5044a041c5bSmacallan shift 5054a041c5bSmacallan done 5064a041c5bSmacallan shift 5074a041c5bSmacallan fi 5084a041c5bSmacallan 5094a041c5bSmacallan # Remove `-o $object'. 5104a041c5bSmacallan IFS=" " 5114a041c5bSmacallan for arg 5124a041c5bSmacallan do 5134a041c5bSmacallan case $arg in 5144a041c5bSmacallan -o) 5154a041c5bSmacallan shift 5164a041c5bSmacallan ;; 5174a041c5bSmacallan $object) 5184a041c5bSmacallan shift 5194a041c5bSmacallan ;; 5204a041c5bSmacallan *) 5214a041c5bSmacallan set fnord "$@" "$arg" 5224a041c5bSmacallan shift # fnord 5234a041c5bSmacallan shift # $arg 5244a041c5bSmacallan ;; 5254a041c5bSmacallan esac 5264a041c5bSmacallan done 5274a041c5bSmacallan 5284a041c5bSmacallan "$@" -E | 5294a041c5bSmacallan sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 5304a041c5bSmacallan -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 5314a041c5bSmacallan sed '$ s: \\$::' > "$tmpdepfile" 5324a041c5bSmacallan rm -f "$depfile" 5334a041c5bSmacallan echo "$object : \\" > "$depfile" 5344a041c5bSmacallan cat < "$tmpdepfile" >> "$depfile" 5354a041c5bSmacallan sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 5364a041c5bSmacallan rm -f "$tmpdepfile" 5374a041c5bSmacallan ;; 5384a041c5bSmacallan 5394a041c5bSmacallanmsvisualcpp) 5404a041c5bSmacallan # Important note: in order to support this mode, a compiler *must* 5414a041c5bSmacallan # always write the preprocessed file to stdout, regardless of -o, 5424a041c5bSmacallan # because we must use -o when running libtool. 5434a041c5bSmacallan "$@" || exit $? 5444a041c5bSmacallan IFS=" " 5454a041c5bSmacallan for arg 5464a041c5bSmacallan do 5474a041c5bSmacallan case "$arg" in 5484a041c5bSmacallan "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 5494a041c5bSmacallan set fnord "$@" 5504a041c5bSmacallan shift 5514a041c5bSmacallan shift 5524a041c5bSmacallan ;; 5534a041c5bSmacallan *) 5544a041c5bSmacallan set fnord "$@" "$arg" 5554a041c5bSmacallan shift 5564a041c5bSmacallan shift 5574a041c5bSmacallan ;; 5584a041c5bSmacallan esac 5594a041c5bSmacallan done 5604a041c5bSmacallan "$@" -E | 5614a041c5bSmacallan sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" 5624a041c5bSmacallan rm -f "$depfile" 5634a041c5bSmacallan echo "$object : \\" > "$depfile" 5644a041c5bSmacallan . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 5654a041c5bSmacallan echo " " >> "$depfile" 5664a041c5bSmacallan . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" 5674a041c5bSmacallan rm -f "$tmpdepfile" 5684a041c5bSmacallan ;; 5694a041c5bSmacallan 5704a041c5bSmacallannone) 5714a041c5bSmacallan exec "$@" 5724a041c5bSmacallan ;; 5734a041c5bSmacallan 5744a041c5bSmacallan*) 5754a041c5bSmacallan echo "Unknown depmode $depmode" 1>&2 5764a041c5bSmacallan exit 1 5774a041c5bSmacallan ;; 5784a041c5bSmacallanesac 5794a041c5bSmacallan 5804a041c5bSmacallanexit 0 5814a041c5bSmacallan 5824a041c5bSmacallan# Local Variables: 5834a041c5bSmacallan# mode: shell-script 5844a041c5bSmacallan# sh-indentation: 2 5854a041c5bSmacallan# eval: (add-hook 'write-file-hooks 'time-stamp) 5864a041c5bSmacallan# time-stamp-start: "scriptversion=" 5874a041c5bSmacallan# time-stamp-format: "%:y-%02m-%02d.%02H" 5884a041c5bSmacallan# time-stamp-end: "$" 5894a041c5bSmacallan# End: 590