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